mirascope.core.mistral.call_response | Mirascope
MirascopeLilypad

mirascope.core.mistral.call_response

This module contains the MistralCallResponse class.

Usage

Class MistralCallResponse

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)

Bases:

BaseCallResponse[ChatCompletionResponse, MistralTool, dict[str, Any], MistralDynamicConfig, AssistantMessage | SystemMessage | ToolMessage | UserMessage, MistralCallParams, UserMessage, MistralMessageParamConverter]

Attributes

NameTypeDescription
contentstrThe content of the chat completion for the 0th choice.
finish_reasonslist[str]Returns the finish reasons of the response.
modelstrReturns the name of the response model.
idstrReturns the id of the response.
usageUsageInfoReturns the usage of the chat completion.
input_tokensintReturns the number of input tokens.
cached_tokensintReturns the number of cached tokens.
output_tokensint | NoneReturns the number of output tokens.
message_paramAssistantMessageReturns the assistants's response as a message parameter.
toolslist[MistralTool] | NoneReturns the tools for the 0th choice message.
toolMistralTool | NoneReturns the 0th tool for the 0th choice message.
common_finish_reasonslist[FinishReason] | None-
common_message_paramBaseMessageParam-
common_user_message_paramBaseMessageParam | None-
cost_metadataCostMetadataGet metadata required for cost calculation.

Function tool_message_params

Returns the tool message parameters for tool call results.

Parameters

NameTypeDescription
clsAny-
tools_and_outputsSequence[tuple[MistralTool, str]]The sequence of tools and their outputs from which the tool message parameters should be constructed.

Returns

TypeDescription
list[ToolMessage]The list of constructed `ChatMessage` parameters.