mistral_common.protocol.instruct.converters
convert_openai_messages(messages)
Convert OpenAI messages to Mistral messages.
Dispatches each message to the from_openai constructor of the matching
role class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages
|
list[dict[str, str | list[dict[str, str | dict[str, Any]]]]]
|
Message dicts matching OpenAI's chat schema. Each must have a "role" key of "user", "assistant", "tool", or "system". |
required |
Returns:
| Type | Description |
|---|---|
list[ChatMessage]
|
The Mistral message instances, one per input dict. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a message has an unknown role. |
Source code in src/mistral_common/protocol/instruct/converters.py
convert_openai_tools(tools)
Convert OpenAI tools to Mistral tools.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tools
|
list[dict[str, Any]]
|
Tool dicts matching OpenAI's tool schema, each with "type" and "function" keys. |
required |
Returns:
| Type | Description |
|---|---|
list[Tool]
|
The Mistral Tool instances, one per input dict. |