mirascope.core.vertex.call_response¶
This module contains the VertexCallResponse
class.
Usage Documentation
VertexCallResponse
¶
Bases: BaseCallResponse[GenerationResponse, VertexTool, Tool, VertexDynamicConfig, Content, VertexCallParams, Content]
A convenience wrapper around the Vertex AI GenerateContentResponse
.
When calling the Vertex AI API using a function decorated with vertex_call
, the
response will be a VertexCallResponse
instance with properties that allow for
more convenient access to commonly used attributes.
Example:
from mirascope.core import prompt_template
from mirascope.core.vertex import vertex_call
@vertex_call("gemini-1.5-flash")
def recommend_book(genre: str) -> str:
return f"Recommend a {genre} book"
response = recommend_book("fantasy") # response is an `VertexCallResponse` instance
print(response.content)
model
property
¶
model: str
Returns the model name.
vertex does not return model, so we return the model provided by the user.
message_param
property
¶
Returns the models's response as a message parameter.
tools
property
¶
tools: list[VertexTool] | None
Returns the list of tools for the 0th candidate's 0th content part.
tool
property
¶
tool: VertexTool | 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[VertexTool, object]]
) -> list[Content]
Returns the tool message parameters for tool call results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tools_and_outputs |
list[tuple[VertexTool, object]]
|
The list of tools and their outputs from which the tool message parameters should be constructed. |
required |
Returns:
Type | Description |
---|---|
list[Content]
|
The list of constructed |