mirascope.core.mistral.call_response¶
This module contains the MistralCallResponse
class.
Usage Documentation
MistralCallResponse
¶
Bases: BaseCallResponse[ChatCompletionResponse, MistralTool, dict[str, Any], MistralDynamicConfig, AssistantMessage | SystemMessage | ToolMessage | UserMessage, MistralCallParams, UserMessage]
A convenience wrapper around the Mistral ChatCompletion
response.
When calling the Mistral API using a function decorated with mistral_call
, the
response will be an MistralCallResponse
instance with properties that allow for
more convenience access to commonly used attributes.
Example:
from mirascope.core import prompt_template
from mirascope.core.mistral import mistral_call
@mistral_call("mistral-largel-latest")
def recommend_book(genre: str) -> str:
return f"Recommend a {genre} book"
response = recommend_book("fantasy") # response is an `MistralCallResponse` instance
print(response.content)
message_param
cached
property
¶
Returns the assistants's response as a message parameter.
tools
cached
property
¶
tools: list[MistralTool] | None
Returns the tools for the 0th choice message.
Raises:
Type | Description |
---|---|
ValidationError
|
if the tool call doesn't match the tool's schema. |
tool
cached
property
¶
tool: MistralTool | None
Returns the 0th tool for the 0th choice message.
Raises:
Type | Description |
---|---|
ValidationError
|
if the tool call doesn't match the tool's schema. |
tool_message_params
classmethod
¶
tool_message_params(
tools_and_outputs: list[tuple[MistralTool, str]]
) -> list[ToolMessage]
Returns the tool message parameters for tool call results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tools_and_outputs |
list[tuple[MistralTool, str]]
|
The list of tools and their outputs from which the tool message parameters should be constructed. |
required |
Returns:
Type | Description |
---|---|
list[ToolMessage]
|
The list of constructed |