pydantic_ai.models.google_decisions
For details on how to set up authentication with this model, see model configuration for Google.
Bases: DecisionModelSettings
Settings used for a Gemini API decisions request.
Bases: DecisionModel[Client]
The model class for the Gemini API’s decisions endpoint, which runs a Gemini model as a decision model.
The endpoint answers typed questions about text or images, each with a probability or a distribution over the
options, rather than writing text. An agent whose job is to decide something runs on it like on any other model,
with the output_type as the questions:
from typing import Literal
from pydantic import BaseModel, Field
from pydantic_ai import Agent
class Handling(BaseModel):
verdict: Literal['run', 'reject', 'ask'] = Field(description='How to handle this command.')
irreversible: bool = Field(description='Would running this destroy data or leak secrets?')
agent = Agent('google-decisions:gemini-decision-1', output_type=Handling)
...
See Decision models for how an agent’s output type and tools become questions, and Google for setup.
Apart from __init__, all methods are private or match those of the base class.
The API refuses a question without non-empty instructions, even one whose options say what it asks.
A question’s instructions in https://aistudio.google.com/docs/decisions-api#request.
Type: bool Default: True
The API accepts at most 1000 questions per request; a 1001st returns HTTP 400.
“Questions per request” in https://aistudio.google.com/docs/decisions-api#limits.
Type: int | None Default: 1000
The API takes at most this many options in one pick-one; a 256th is a 400.
“Options per choice question” in https://aistudio.google.com/docs/decisions-api#limits.
The API takes at most this many levels in one rubric; a 256th is a 400.
“Levels per score question” in https://aistudio.google.com/docs/decisions-api#limits.
The model name.
Type: GoogleDecisionsModelName
The system / model provider: 'google-decisions', whatever the provider is called.
It makes the model ID google-decisions:<model name>, which resolves back to this class, and keeps a
GoogleModel continuing the conversation from taking a decision
response for one of its own.
Type: str
def __init__(
model_name: GoogleDecisionsModelName,
*,
provider: Literal['google', 'google-decisions'] | GoogleProvider = 'google',
profile: ModelProfileSpec | None = None,
settings: ModelSettings | None = None,
)
Initialize a Google Decisions model.
The name of the Gemini decision model to use, such as gemini-decision-1.
provider : Literal[‘google’, ‘google-decisions’] | GoogleProvider Default: 'google'
The provider to use for the API’s URL and key: a
GoogleProvider, as for
GoogleModel, or 'google' (the default) or 'google-decisions',
either of which creates one.
profile : ModelProfileSpec | None Default: None
The model profile to use. Defaults to a decision model’s profile for the model name.
settings : ModelSettings | None Default: None
Model-specific settings used as defaults for this model.
@async
def decide(
request: DecisionRequest,
model_settings: DecisionModelSettings,
) -> DecisionResponse
Send one request to the Gemini API’s decisions endpoint.
DecisionResponse
The ID of the Gemini decision model to ask, such as gemini-decision-1.
Default: str | Literal['gemini-decision-1']