mistral_common.protocol.instruct.messages
AssistantMessage(**data)
Bases: BaseMessage
Assistant message.
Attributes:
Name | Type | Description |
---|---|---|
role |
Literal[assistant]
|
The role of the message. |
content |
Optional[Union[str, List[Union[TextChunk, ThinkChunk]]]]
|
The content of the message. |
tool_calls |
Optional[List[ToolCall]]
|
The tool calls of the message. |
prefix |
bool
|
Whether the message is a prefix. |
Examples:
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
from_openai(openai_message)
classmethod
Converts the OpenAI message to the Mistral format.
Source code in src/mistral_common/protocol/instruct/messages.py
to_openai()
Converts the message to the OpenAI format.
Source code in src/mistral_common/protocol/instruct/messages.py
BaseMessage(**data)
Bases: MistralBase
Base class for all messages.
Attributes:
Name | Type | Description |
---|---|---|
role |
Literal[system, user, assistant, tool]
|
The role of the message. |
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
from_openai(openai_message)
classmethod
Converts the OpenAI message to the Mistral format.
Should be implemented by subclasses.
Source code in src/mistral_common/protocol/instruct/messages.py
to_openai()
Converts the message to the OpenAI format.
Should be implemented by subclasses.
Source code in src/mistral_common/protocol/instruct/messages.py
FinetuningAssistantMessage(**data)
Bases: AssistantMessage
Assistant message for finetuning.
Attributes:
Name | Type | Description |
---|---|---|
weight |
Optional[float]
|
The weight of the message to train on. |
Examples:
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
Roles
SystemMessage(**data)
Bases: BaseMessage
System message.
Attributes:
Name | Type | Description |
---|---|---|
content |
Union[str, List[Union[TextChunk, ThinkChunk]]]
|
The content of the message. |
Examples:
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
from_openai(openai_message)
classmethod
Converts the OpenAI message to the Mistral format.
Source code in src/mistral_common/protocol/instruct/messages.py
ToolMessage(**data)
Bases: BaseMessage
Tool message.
Attributes:
Name | Type | Description |
---|---|---|
content |
str
|
The content of the message. |
tool_call_id |
Optional[str]
|
The tool call id of the message. |
name |
Optional[str]
|
The name of the tool. (Deprecated in V3 tokenization) |
Examples:
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
from_openai(messages)
classmethod
Converts the OpenAI message to the Mistral format.
Source code in src/mistral_common/protocol/instruct/messages.py
to_openai()
Converts the message to the OpenAI format.
Source code in src/mistral_common/protocol/instruct/messages.py
UserMessage(**data)
Bases: BaseMessage
User message.
Attributes:
Name | Type | Description |
---|---|---|
content |
Union[str, List[UserContentChunk]]
|
The content of the message. |
Examples:
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
from_openai(openai_message)
classmethod
Converts the OpenAI message to the Mistral format.
Source code in src/mistral_common/protocol/instruct/messages.py
to_openai()
Converts the message to the OpenAI format.