Skip to content

Types

ChatMessage module-attribute

Union type of possible messages in the chat. These are very similar types currently supported by the OpenAI API.

ChatUserMessage

Bases: TypedDict

Message from the user in the chat.

role instance-attribute

role: Required[Literal['user']]

The role of the message. Always "user" for user messages.

content instance-attribute

content: Required[str]

The content of the message.

ChatAssistantMessage

Bases: TypedDict

Message from the assistant in the chat.

role instance-attribute

role: Required[Literal['assistant']]

The role of the message. Always "assistant" for assistant messages.

content instance-attribute

content: Required[str | None]

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.

content instance-attribute

content: Required[str]

The output of the tool call.

role instance-attribute

role: Required[Literal['tool']]

The role of the message. Always "tool" for tool messages.

tool_call_id instance-attribute

tool_call_id: Required[str | None]

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.

error instance-attribute

error: Required[str | None]

The error message of the tool call. It can be None if there is no error.

ChatSystemMessage

Bases: TypedDict

System message in the chat. This can be set by using the SystemMessage pipeline element in a pipeline.

role instance-attribute

role: Required[Literal['system']]

The role of the message. Always "system" for system messages.

content instance-attribute

content: Required[str]

The content of the message.