GoogleGenAIClassifier()| Name | Type | Description |
|---|---|---|
model* | unknown | Decisions model used to answer questions. |
api_key* | unknown | Google API key. If omitted, reads |
base_url* | unknown | Base URL for API requests. If omitted, the |
timeout* | unknown | Request timeout in seconds. |
max_retries* | unknown | Maximum number of request attempts. Uses the |
client* | unknown | Optional |
Base URL for API requests. Uses the google-genai SDK default when None.
Ask typed questions about text, JSON, or media with the Gemini Decisions API.
A single request can combine Noul probabilities, Choice selections, and
Score ratings over shared state. The response preserves probabilities,
confidence, and token usage so application code can decide whether to act,
route, or request human review.
ChoiceAnswer.confidence and ScoreAnswer.confidence are the probability of the
selected label or level. The API's NoulAnswer confidence, max(noul, 1 - noul),
is not kept because it can be computed from noul. NoulAnswer.noul is always
between 0.01 and 0.99, so a threshold above 0.99 never matches.
Requests always use the Gemini Developer API.
Strings are sent as-is. Any other state, such as JSON objects, arrays, or LangChain
messages, is sent as JSON text, with messages converted to role/content objects.
LangChain standard media blocks (type of image, audio, video, or file,
with base64 or url data) are sent as native media at the position where they
appear in the JSON text.
from langchain_core.decisions import Choice, Noul, Score
from langchain_google_genai import GoogleGenAIClassifier
classifier = GoogleGenAIClassifier(model="gemini-decision-1")
response = classifier.invoke(
{
"state": "Stripe has failed to connect for three days. Help ASAP.",
"questions": {
"department": Choice(
instructions="Which team should handle this request?",
criteria={
"billing": "Payment or subscription issues.",
"technical": "Product bugs or integration failures.",
},
),
"urgent": Noul(instructions="Is this request urgent?"),
"frustration": Score(
instructions="How frustrated does the customer appear?",
criteria=["Calm.", "Concerned but civil.", "Very angry."],
),
},
}
)
print(response.choices["department"].choice)
print(response.nouls["urgent"].noul)
print(response.scores["frustration"].score)Standard LangChain media blocks are sent as media wherever they appear in the state.
from langchain_core.messages import HumanMessage
response = classifier.invoke(
{
"state": [
HumanMessage(
content_blocks=[
{"type": "text", "text": "Photo of the delivered item."},
{
"type": "image",
"base64": image_data,
"mime_type": "image/jpeg",
},
]
)
],
"questions": {
"damaged": Noul(instructions="Did the item arrive damaged?"),
},
}
)