mirascope.core.google.stream | Mirascope
MirascopeLilypad

mirascope.core.google.stream

The GoogleStream class for convenience around streaming LLM calls.

Usage

Class GoogleStream

A class for convenience around streaming Google LLM calls.

Example:

from mirascope.core import prompt_template
from mirascope.core.google import google_call


@google_call("google-1.5-flash", stream=True)
def recommend_book(genre: str) -> str:
    return f"Recommend a {genre} book"

stream = recommend_book("fantasy")  # returns `GoogleStream` instance
for chunk, _ in stream:
    print(chunk.content, end="", flush=True)

Bases:

BaseStream[GoogleCallResponse, GoogleCallResponseChunk, ContentDict, ContentDict, ContentDict, ContentListUnion | ContentListUnionDict, GoogleTool, Tool, GoogleDynamicConfig, GoogleCallParams, FinishReason]

Attributes

NameTypeDescription
cost_metadataCostMetadata-

Function construct_call_response

Constructs the call response from a consumed GoogleStream.

Parameters

NameTypeDescription
selfAny-

Returns

TypeDescription
GoogleCallResponse-