mirascope.core.google.call_response | Mirascope
MirascopeLilypad

mirascope.core.google.call_response

This module contains the GoogleCallResponse class.

Usage

Class GoogleCallResponse

A convenience wrapper around the Google API response.

When calling the Google API using a function decorated with google_call, the response will be a GoogleCallResponse instance with properties that allow for more convenient access to commonly used attributes.

Example:

from mirascope.core import prompt_template
from mirascope.core.google import google_call


@google_call("google-1.5-flash")
def recommend_book(genre: str) -> str:
    return f"Recommend a {genre} book"


response = recommend_book("fantasy")  # response is an `GoogleCallResponse` instance
print(response.content)

Bases:

BaseCallResponse[GenerateContentResponse, GoogleTool, Tool, GoogleDynamicConfig, ContentListUnion | ContentListUnionDict, GoogleCallParams, ContentDict, GoogleMessageParamConverter]

Attributes

NameTypeDescription
contentstrReturns the contained string content for the 0th choice.
finish_reasonslist[str]Returns the finish reasons of the response.
modelstrReturns the model name. google.generativeai does not return model, so we return the model provided by the user.
idstr | NoneReturns the id of the response. google.generativeai does not return an id
usageGenerateContentResponseUsageMetadata | NoneReturns the usage of the chat completion. google.generativeai does not have Usage, so we return None
input_tokensint | NoneReturns the number of input tokens.
cached_tokensint | NoneReturns the number of cached tokens.
output_tokensint | NoneReturns the number of output tokens.
message_paramContentDictReturns the models's response as a message parameter.
toolslist[GoogleTool] | NoneReturns the list of tools for the response.
toolGoogleTool | NoneReturns the 0th tool for the 0th candidate's 0th content part.
common_finish_reasonslist[FinishReason] | None-
common_message_paramBaseMessageParam-
common_user_message_paramBaseMessageParam | None-
cost_metadataCostMetadata-

Function tool_message_params

Returns the tool message parameters for tool call results.

Parameters

NameTypeDescription
clsAny-
tools_and_outputsSequence[tuple[GoogleTool, str]]The sequence of tools and their outputs from which the tool message parameters should be constructed.

Returns

TypeDescription
list[ContentDict]The list of constructed `FunctionResponse` parameters.