mirascope.core.google.call_response¶
This module contains the GoogleCallResponse
class.
Usage Documentation
GoogleCallResponse
¶
Bases: BaseCallResponse[GenerateContentResponse, GoogleTool, Tool, GoogleDynamicConfig, ContentListUnion | ContentListUnionDict, GoogleCallParams, ContentDict]
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)
model
property
¶
model: str
Returns the model name.
google.generativeai does not return model, so we return the model provided by the user.
id
property
¶
id: str | None
Returns the id of the response.
google.generativeai does not return an id
usage
property
¶
Returns the usage of the chat completion.
google.generativeai does not have Usage, so we return None
message_param
cached
property
¶
Returns the models's response as a message parameter.
tools
cached
property
¶
tools: list[GoogleTool] | None
Returns the list of tools for the 0th candidate's 0th content part.
tool
cached
property
¶
tool: GoogleTool | None
Returns the 0th tool for the 0th candidate's 0th content part.
Raises:
Type | Description |
---|---|
ValidationError
|
if the tool call doesn't match the tool's schema. |
tool_message_params
classmethod
¶
tool_message_params(
tools_and_outputs: list[tuple[GoogleTool, str]]
) -> list[ContentDict]
Returns the tool message parameters for tool call results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tools_and_outputs |
list[tuple[GoogleTool, str]]
|
The list of tools and their outputs from which the tool message parameters should be constructed. |
required |
Returns:
Type | Description |
---|---|
list[ContentDict]
|
The list of constructed |