mirascope.core.mistral.stream | Mirascope
MirascopeLilypad

mirascope.core.mistral.stream

The MistralStream class for convenience around streaming LLM calls.

Usage

Class MistralStream

A class for convenience around streaming Mistral LLM calls.

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")  # returns `MistralStream` instance
for chunk, _ in stream:
    print(chunk.content, end="", flush=True)

Bases:

BaseStream[MistralCallResponse, MistralCallResponseChunk, UserMessage, AssistantMessage, ToolMessage, AssistantMessage | SystemMessage | ToolMessage | UserMessage, MistralTool, dict[str, Any], MistralDynamicConfig, MistralCallParams, FinishReason]

Attributes

NameTypeDescription
cost_metadataCostMetadata-

Function construct_call_response

Constructs the call response from a consumed MistralStream.

Parameters

NameTypeDescription
selfAny-

Returns

TypeDescription
MistralCallResponse-