mirascope.core.cohere.stream | Mirascope
MirascopeLilypad

mirascope.core.cohere.stream

The CohereStream class for convenience around streaming LLM calls.

Usage

Class CohereStream

A class for convenience around streaming Cohere LLM calls.

Example:

from mirascope.core import prompt_template
from mirascope.core.cohere import cohere_call


@cohere_call("command-r-plus", stream=True)
def recommend_book(genre: str) -> str:
    return f"Recommend a {genre} book"


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

Bases:

BaseStream[CohereCallResponse, CohereCallResponseChunk, ChatMessage, ChatMessage, ChatMessage, ChatMessage, CohereTool, Tool, AsyncCohereDynamicConfig | CohereDynamicConfig, CohereCallParams, ChatStreamEndEventFinishReason]

Attributes

NameTypeDescription
cost_metadataCostMetadata-

Function construct_call_response

Constructs the call response from a consumed CohereStream.

Parameters

NameTypeDescription
selfAny-

Returns

TypeDescription
CohereCallResponse-