Lm output
Defines the LM output schema.
LMOutput
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[Thinking]
|
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. |
attachments
property
Get the attachments from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[Attachment]
|
list[Attachment]: The attachments from the LMOutput. |
citations
property
Get the citations from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[Chunk]
|
list[Chunk]: The citations from the LMOutput. |
code_exec_results
property
Get the code exec results from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[CodeExecResult]
|
list[CodeExecResult]: The code exec results from the LMOutput. |
mcp_calls
property
Get the MCP calls from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[MCPCall]
|
list[MCPCall]: The MCP calls from the LMOutput. |
structured_output
property
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
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
property
Get the first text from the LMOutput.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The first text from the LMOutput. |
texts
property
Get the texts from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: The texts from the LMOutput. |
thinkings
property
Get the thinkings from the LMOutput.
Returns:
| Type | Description |
|---|---|
list[Thinking]
|
list[Thinking]: The thinkings from the LMOutput. |
tool_calls
property
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. |