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
Name | Type | Description |
---|---|---|
cost_metadata | CostMetadata | Get metadata required for cost calculation. |
Function construct_call_response
Constructs the call response from a consumed BedrockStream.
Parameters
Name | Type | Description |
---|---|---|
self | Any | - |
Returns
Type | Description |
---|---|
BedrockCallResponse | - |