Lm output
Defines the LM output schema.
References
NONE
LMOutput(*, outputs=None, token_usage=None, duration=None, finish_details=None, response='', structured_output=None, tool_calls=None, reasoning=None, attachments=None, citations=None, code_exec_results=None, mcp_calls=None)
Bases: BaseModel
Defines the output of a language model.
Attributes:
| Name | Type | Description |
|---|---|---|
outputs |
list[LMOutputItem]
|
The outputs of the language model in sequential order. Defaults to an empty list. |
token_usage |
TokenUsage | None
|
The token usage analytics, if requested. Defaults to None. |
duration |
float | None
|
The duration of the invocation in seconds, if requested. Defaults to None. |
finish_details |
dict[str, Any]
|
The details about how the generation finished, if requested. Defaults to an empty dictionary. |
text |
str
|
The first text response. |
structured_output |
dict[str, Any] | BaseModel | None
|
The first structured output. |
texts |
list[str]
|
The texts from the outputs. |
structured_outputs |
list[dict[str, Any] | BaseModel]
|
The structured outputs from the outputs. |
attachments |
list[Attachment]
|
The attachments from the outputs. |
tool_calls |
list[ToolCall]
|
The tool calls from the outputs. |
thinkings |
list[Reasoning]
|
The thinkings from the outputs. |
citations |
list[Chunk]
|
The citations from the outputs. |
code_exec_results |
list[CodeExecResult]
|
The code exec results from the outputs. |
mcp_calls |
list[MCPCall]
|
The MCP calls from the outputs. |
response |
str
|
Deprecated. Replaced by |
reasoning |
list[Reasoning]
|
Deprecated. Replaced by |
Initialize the LMOutput.
This constructor is created for backward compatibility with the legacy method to initialize the LMOutput. This constructor will be removed in v0.6.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outputs |
list[LMOutputItem] | None
|
The output items. Defaults to an empty list. |
None
|
token_usage |
TokenUsage | None
|
The token usage analytics. Defaults to None. |
None
|
duration |
float | None
|
The duration of the invocation in seconds. Defaults to None. |
None
|
finish_details |
dict[str, Any] | None
|
The details about how the generation finished. Defaults to an empty dictionary. |
None
|
response |
str
|
The first text response. Defaults to an empty string. |
''
|
structured_output |
dict[str, Any] | BaseModel | None
|
The first structured output. Defaults to None. |
None
|
tool_calls |
list[ToolCall] | None
|
The tool calls. Defaults to None. |
None
|
reasoning |
list[Reasoning] | None
|
The thinkings. Defaults to None. |
None
|
attachments |
list[Attachment] | None
|
The attachments. Defaults to None. |
None
|
citations |
list[Chunk] | None
|
The citations. Defaults to None. |
None
|
code_exec_results |
list[CodeExecResult] | None
|
The code exec results. Defaults to None. |
None
|
mcp_calls |
list[MCPCall] | None
|
The MCP calls. Defaults to None. |
None
|
attachments: list[Attachment]
property
writable
Get the attachments from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[Attachment]
|
list[Attachment]: The attachments from the LMOutput. |
citations: list[Chunk]
property
writable
Get the citations from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[Chunk]
|
list[Chunk]: The citations from the LMOutput. |
code_exec_results: list[CodeExecResult]
property
writable
Get the code exec results from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[CodeExecResult]
|
list[CodeExecResult]: The code exec results from the LMOutput. |
mcp_calls: list[MCPCall]
property
writable
Get the MCP calls from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[MCPCall]
|
list[MCPCall]: The MCP calls from the LMOutput. |
reasoning: list[Reasoning]
property
writable
Deprecated property to get the thinkings from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[Reasoning]
|
list[Reasoning]: The thinkings from the LMOutput. |
response: str
property
writable
Deprecated property to get the first text response from the LMOutput.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The first text response from the LMOutput. |
structured_output: dict[str, Any] | BaseModel | None
property
writable
Deprecated property to get the first structured output from the LMOutput.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | BaseModel | None
|
dict[str, Any] | BaseModel | None: The first structured output from the LMOutput. |
structured_outputs: list[dict[str, Any] | BaseModel]
property
Get the structured outputs from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any] | BaseModel]
|
list[dict[str, Any] | BaseModel]: The structured outputs from the LMOutput. |
text: str
property
Get the first text from the LMOutput.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The first text from the LMOutput. |
texts: list[str]
property
Get the texts from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: The texts from the LMOutput. |
thinkings: list[Reasoning]
property
Get the thinkings from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[Reasoning]
|
list[Reasoning]: The thinkings from the LMOutput. |
tool_calls: list[ToolCall]
property
writable
Get the tool calls from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[ToolCall]
|
list[ToolCall]: The tool calls from the LMOutput. |
__repr__()
Return string representation of the LMOutput.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The string representation of the LMOutput. |
__str__()
Return string representation of the LMOutput.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The string representation of the LMOutput. |
add_attachment(attachment)
Add an attachment or a list of attachments to the LMOutput.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attachment |
Attachment | list[Attachment]
|
The attachment or a list of attachments to add. |
required |
add_citation(citation)
add_code_exec_result(code_exec_result)
Add a code exec result or a list of code exec results to the LMOutput.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code_exec_result |
CodeExecResult | list[CodeExecResult]
|
The code exec result or a list of code exec results to add. |
required |
add_mcp_call(mcp_call)
add_structured(structured)
Add a structured output or a list of structured outputs to the LMOutput.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structured |
dict[str, Any] | BaseModel | list[dict[str, Any] | BaseModel]
|
The structured output or a list of structured outputs to add. |
required |
add_text(text)
Add an output or a list of outputs to the LMOutput.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text |
str | list[str]
|
The text or a list of texts to add. |
required |
add_thinking(thinking)
LMOutputItem
Bases: BaseModel
Defines the output item of a language model.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
The type of the output item. |
output |
LMOutputData
|
The output data of the output item. |
__repr__()
Return string representation of the LMOutputItem.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The string representation of the LMOutputItem. |
__str__()
Return string representation of the LMOutputItem.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The string representation of the LMOutputItem. |