Types
ChatMessage
module-attribute
¶
ChatMessage = (
ChatUserMessage
| ChatAssistantMessage
| ChatToolResultMessage
| ChatSystemMessage
)
Union type of possible messages in the chat. These are very similar types currently supported by the OpenAI API.
ChatUserMessage
¶
ChatAssistantMessage
¶
Bases: TypedDict
Message from the assistant in the chat.
role
instance-attribute
¶
The role of the message. Always "assistant"
for assistant messages.
content
instance-attribute
¶
The content of the message, which can be a string or None
(if tool_calls
are provided).
tool_calls
instance-attribute
¶
tool_calls: Required[list[FunctionCall] | None]
A list of tool calls that the assistant requests, which can be None
(if no tool calls are requires are provided).
ChatToolResultMessage
¶
Bases: TypedDict
Message from the tool with the result of a function call.
tool_call
instance-attribute
¶
tool_call: Required[FunctionCall]
The function call that was executed.
role
instance-attribute
¶
The role of the message. Always "tool"
for tool messages.
tool_call_id
instance-attribute
¶
The ID of the tool call. It can be None
if the LLM does not provide or required it.
It is used by e.g., OpenAI and Anthropic.
ChatSystemMessage
¶
Bases: TypedDict
System message in the chat. This can be set by using the SystemMessage pipeline element in a pipeline.