mirascope.core.bedrock.stream | Mirascope
MirascopeLilypad

mirascope.core.bedrock.stream

The BedrockStream class for convenience around streaming LLM calls.

Usage

Class BedrockStream

A class for convenience around streaming Bedrock LLM calls.

Example:

from mirascope.core import prompt_template
from mirascope.core.bedrock import bedrock_call


@bedrock_call("gpt-4o-mini", stream=True)
@prompt_template("Recommend a {genre} book")
def recommend_book(genre: str):
    ...


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

Bases:

BaseStream[BedrockCallResponse, BedrockCallResponseChunk, UserMessageTypeDef, AssistantMessageTypeDef, ToolUseBlockMessageTypeDef, InternalBedrockMessageParam, BedrockTool, ToolTypeDef, AsyncBedrockDynamicConfig | BedrockDynamicConfig, BedrockCallParams, FinishReason]

Attributes

NameTypeDescription
cost_metadataCostMetadataGet metadata required for cost calculation.

Function construct_call_response

Constructs the call response from a consumed BedrockStream.

Parameters

NameTypeDescription
selfAny-

Returns

TypeDescription
BedrockCallResponse-