Skip to content

mirascope.core.base.call_response

This module contains the base call response class.

BaseCallResponse

Bases: BaseModel, Generic[_ResponseT, _BaseToolT, _ToolSchemaT, _BaseDynamicConfigT, _MessageParamT, _CallParamsT, _UserMessageParamT], ABC

A base abstract interface for LLM call responses.

Attributes:

Name Type Description
metadata Metadata

The metadata pulled from the call that was made.

response _ResponseT

The original response from whichever model response this wraps.

tool_types list[type[_BaseToolT]] | None

The list of tool types used, if any.

prompt_template str | None

The unformatted prompt template from the call that was made.

fn_args dict[str, Any]

The input arguments used when making the call.

dynamic_config _BaseDynamicConfigT

Dynamic configuration options, if any.

messages SkipValidation[list[_MessageParamT]]

The list of provider-specific messages used to make the API call.

call_params SkipValidation[_CallParamsT]

The original call params set in the call decorator.

call_kwargs BaseCallKwargs[_ToolSchemaT]

The keyword arguments used to make the API call.

user_message_param _UserMessageParamT | None

The most recent provider-specific message if it was a user message. Otherwise None.

start_time float

The start time of the completion in ms.

end_time float

The end time of the completion in ms.

content abstractmethod property

content: str

Should return the string content of the response.

If there are multiple choices in a response, 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[str] | 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.

cost abstractmethod property

cost: float | None

Should return the cost of the response in dollars.

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

message_param abstractmethod property

message_param: Any

Returns the assistant's response as a message parameter.

tools abstractmethod property

tools: list[_BaseToolT] | None

Returns the tools for the 0th choice message.

tool abstractmethod property

tool: _BaseToolT | None

Returns the 0th tool for the 0th choice message.

tool_message_params abstractmethod classmethod

tool_message_params(
    tools_and_outputs: list[tuple[_BaseToolT, Any]]
) -> list[Any]

Returns the tool message parameters for tool call results.

Parameters:

Name Type Description Default
tools_and_outputs list[tuple[_BaseToolT, Any]]

The list of tools and their outputs from which the tool message parameters should be constructed.

required
Source code in mirascope/core/base/call_response.py
@classmethod
@abstractmethod
def tool_message_params(
    cls, tools_and_outputs: list[tuple[_BaseToolT, Any]]
) -> list[Any]:
    """Returns the tool message parameters for tool call results.

    Args:
        tools_and_outputs: The list of tools and their outputs from which the tool
            message parameters should be constructed.
    """
    ...