Skip to content

mirascope.core.base.call_response_chunk

This module contains the BaseCallResponseChunk class.

Usage Documentation

Streams

BaseCallResponseChunk

Bases: BaseModel, Generic[_ChunkT, _FinishReasonT], ABC

A base abstract interface for LLM streaming response chunks.

Attributes:

Name Type Description
chunk _ChunkT

The original response chunk from whichever model response this wraps.

content abstractmethod property

content: str

Should return the string content of the response chunk.

If there are multiple choices in a chunk, this method should select the 0th choice and return it's string content.

If there is no string content (e.g. when using tools), this method must return the empty string.

finish_reasons abstractmethod property

finish_reasons: list[_FinishReasonT] | None

Should return the finish reasons of the response.

If there is no finish reason, this method must return None.

model abstractmethod property

model: str | None

Should return the name of the response model.

id abstractmethod property

id: str | None

Should return the id of the response.

usage abstractmethod property

usage: Any

Should return the usage of the response.

If there is no usage, this method must return None.

input_tokens abstractmethod property

input_tokens: int | float | None

Should return the number of input tokens.

If there is no input_tokens, this method must return None.

output_tokens abstractmethod property

output_tokens: int | float | None

Should return the number of output tokens.

If there is no output_tokens, this method must return None.