mirascope.core.vertex.call_response_chunk¶
This module contains the VertexCallResponseChunk
class.
Usage Documentation
VertexCallResponseChunk
¶
Bases: BaseCallResponseChunk[GenerationResponse, FinishReason]
A convenience wrapper around the Vertex AI streamed response chunks.
When calling the Vertex AI API using a function decorated with vertex_call
and
stream
set to True
, the stream will contain VertexCallResponseChunk
instances
with properties that allow for more convenient access to commonly used attributes.
Example:
from mirascope.core import prompt_template
from mirascope.core.vertex import vertex_call
@vertex_call("gemini-1.5-flash", stream=True)
def recommend_book(genre: str) -> str:
return f"Recommend a {genre} book"
stream = recommend_book("fantasy") # response is an `VertexStream`
for chunk, _ in stream:
print(chunk.content, end="", flush=True)