Content parts¶
You might be looking for...
- If you're looking for information on the
AIPromptandAIResponseclasses, see AI inputs and outputs: an overview. - If you're looking for information on the
AIMessageclasses, see AI messages. - If you're looking for information on the tool call data structures, see Tool calls.
- If you're looking for information on data structures for streaming (also known as "incompletes"), see Streaming and Incompletes.
Visual explanation¶
This visualization should help you understand the class hierarchy of the messages:
Content parts for UserAIMessage¶
Note
To make this section more readable, we're not showing the full
path of the classes, but they can also be imported from the
conatus.models.messages module.
UserAIMessageContentPart
module-attribute
¶
UserAIMessageContentPart = (
UserAIMessageContentTextPart
| UserAIMessageContentImagePart
)
The content part of a user message.
AI APIs allow a message to consist of multiple parts, such as text and images.
UserAIMessageContentTextPart
dataclass
¶
UserAIMessageContentTextPart(
text: str,
type: Literal["text"] = "text",
linked_to_image: bool = False,
)
The content part of a user message that contains text.
| ATTRIBUTE | DESCRIPTION |
|---|---|
text |
The text of the user message content part.
TYPE:
|
type |
The type of the user message content part. Always
TYPE:
|
linked_to_image |
Whether the text content part is linked to an image. This is useful when removing content parts from a message to make it compatible with an AI model that does not support images; that way, you ensure that you don't have dangling text parts that make no sense on their own.
TYPE:
|
UserAIMessageContentImagePart
dataclass
¶
UserAIMessageContentImagePart(
image_data: str,
is_base64: bool,
detail: Literal["auto", "low", "high"] | None = "auto",
type: Literal["image"] = "image",
)
The content part of a user message that contains an image.
| ATTRIBUTE | DESCRIPTION |
|---|---|
image_data |
The URL of the image or the base64 encoded image data.
TYPE:
|
is_base64 |
Whether the image is base64 encoded.
TYPE:
|
detail |
The detail level of the image.
TYPE:
|
type |
The type of the user message content part. Always
TYPE:
|
to_markdown
¶
to_markdown() -> str
Get the text of the user message content part.
Source code in conatus/models/inputs_outputs/content_parts.py
Content parts for AssistantAIMessage¶
Note
To make this section more readable, we're not showing the full
path of the classes, but they can also be imported from the
conatus.models.messages module.
AssistantAIMessageContentPart
module-attribute
¶
AssistantAIMessageContentPart = (
AssistantAIMessageContentTextPart
| AssistantAIMessageContentToolCallPart
| AssistantAIMessageContentRefusalPart
| AssistantAIMessageContentReasoningPart
)
The content part of an assistant message.
While some AI providers might do it differently, we split up the content of an assistant message into text and tool calls (and potentially other content parts down the road).
AssistantAIMessageContentTextPart
dataclass
¶
AssistantAIMessageContentTextPart(
text: str,
uid: str | None = None,
type: Literal["text"] = "text",
)
The content part of an assistant message that contains text.
| ATTRIBUTE | DESCRIPTION |
|---|---|
text |
The text of the assistant message content part.
TYPE:
|
uid |
The ID of the assistant message content part.
TYPE:
|
type |
The type of the assistant message content part. Always
TYPE:
|
AssistantAIMessageContentToolCallPart
dataclass
¶
AssistantAIMessageContentToolCallPart(
tool_call: AIToolCall | ComputerUseAction,
uid: str | None = None,
type: Literal["tool_call"] = "tool_call",
)
The content part of an assistant message that contains a tool call.
| ATTRIBUTE | DESCRIPTION |
|---|---|
tool_call |
The tool call of the assistant message content part.
TYPE:
|
uid |
The ID of the assistant message content part.
TYPE:
|
type |
The type of the assistant message content part. Always
TYPE:
|
all_text_including_reasoning
property
¶
Get the text of the tool call.
to_markdown
¶
to_markdown() -> str
Get the text of the tool call.
Source code in conatus/models/inputs_outputs/content_parts.py
complete
¶
Convert an incomplete tool call to a complete tool call.
In our case, we don't need to do anything.
| RETURNS | DESCRIPTION |
|---|---|
Self
|
The complete tool call. |
AssistantAIMessageContentRefusalPart
dataclass
¶
AssistantAIMessageContentRefusalPart(
refusal: str,
uid: str | None = None,
type: Literal["refusal"] = "refusal",
)
The content part of an assistant message that contains a refusal.
| ATTRIBUTE | DESCRIPTION |
|---|---|
refusal |
The refusal of the assistant message content part.
TYPE:
|
uid |
The ID of the assistant message content part.
TYPE:
|
type |
The type of the assistant message content part. Always
TYPE:
|
AssistantAIMessageContentReasoningPart
dataclass
¶
AssistantAIMessageContentReasoningPart(
reasoning: str,
uid: str | None = None,
is_redacted: bool = False,
model_name: str | None = None,
index: int | None = None,
type: Literal["reasoning"] = "reasoning",
)
The content part of an assistant message that contains reasoning.
| ATTRIBUTE | DESCRIPTION |
|---|---|
reasoning |
The reasoning of the assistant message content part.
TYPE:
|
uid |
The ID of the assistant message content part.
TYPE:
|
is_redacted |
Whether the reasoning is redacted. Supported by Anthropic.
TYPE:
|
model_name |
The name of the model that produced the reasoning. This is important when switching between models.
TYPE:
|
index |
The index of the assistant message content part.
TYPE:
|
type |
The type of the assistant message content part. Always
TYPE:
|
