mirascope.core.mistral.call_response_chunk | Mirascope
MirascopeLilypad

mirascope.core.mistral.call_response_chunk

This module contains the MistralCallResponseChunk class.

Usage

Class MistralCallResponseChunk

A convenience wrapper around the Mistral ChatCompletionChunk streamed chunks.

When calling the Mistral API using a function decorated with mistral_call and stream set to True, the stream will contain MistralResponseChunk instances with properties that allow for more convenient access to commonly used attributes.

Example:

from mirascope.core import prompt_template
from mirascope.core.mistral import mistral_call


@mistral_call("mistral-large-latest", stream=True)
def recommend_book(genre: str) -> str:
    return f"Recommend a {genre} book"


stream = recommend_book("fantasy")  # response is an `MistralStream`
for chunk, _ in stream:
    print(chunk.content, end="", flush=True)

Bases:

BaseCallResponseChunk[CompletionChunk, FinishReason]

Attributes

NameTypeDescription
contentstrReturns the content of the delta.
finish_reasonslist[FinishReason]Returns the finish reasons of the response.
modelstrReturns the name of the response model.
idstrReturns the id of the response.
usageUsageInfo | NoneReturns the usage of the chat completion.
input_tokensint | NoneReturns the number of input tokens.
cached_tokensintReturns the number of cached tokens.
output_tokensint | NoneReturns the number of output tokens.
cost_metadataCostMetadataReturns the cost metadata.
common_finish_reasonslist[types.FinishReason] | None-