Expand description
Decision models: typed questions about shared state, answered with calibrated probabilities instead of text.
A decision model (a “System One” model, such as TypeSafe AI’s Jev on
Vercel AI Gateway) takes a state (a string, an object or an array) and a
map of named questions. Each answer comes back typed:
| Question | Answer |
|---|---|
Question::Boolean | probability that the statement is true |
Question::Choice | the chosen option and each option’s probability |
Question::Score | a probability-weighted position on an ordered scale |
A decision model writes no text, so it cannot fill an open slot such as a
name or a date. It can pick among options the session already holds (the
time slots a tool offered) and decide categorical things (a confirmation,
an intent, which stage comes next), usually far faster than a language
model. Decisions holds the questions a session asks and asks them
against the rolling conversation; guards name them with the decided atom
(see crate::flow::decided). GatewayDecisionModel (feature
ai-gateway) calls Vercel AI Gateway.
use gemini_adk_rs::decision::{Answer, DecisionRequest, MockDecisionModel, Question, DecisionModel};
use serde_json::json;
let model = MockDecisionModel::new(|_| {
Ok([("confirmed".to_string(), Answer::boolean(0.97))].into())
});
let response = model
.decide(DecisionRequest::new(
json!("Caller: yes, book it."),
[("confirmed", Question::boolean("Did the caller agree to book?"))],
))
.await
.unwrap();
assert_eq!(response.answers["confirmed"].probability(), Some(0.97));Structs§
- Boolean
Criteria - What the true and false cases of a boolean question mean.
- Conversation
- The conversation a decision model reads: caller and agent lines and tool results in order, the facts the active stages ground the model in, and which stages are active.
- Decision
- One question in the bank.
- Decision
Request - A decision request: one state and its questions.
- Decision
Response - A decision model’s answers and what it cost.
- Decision
Usage - Token usage of one decision.
- Decisions
- A bank of questions asked of a decision model against the rolling conversation.
- Gateway
Decision Model - A decision model served by Vercel AI Gateway, such as TypeSafe AI’s Jev.
- Mock
Decision Model - A
DecisionModelwhose answers come from a closure, for offline tests. It records every request it receives. - Round
- What one ask did.
Enums§
- Answer
- One answer, typed like its question.
- Fallback
When - When AI Gateway should rerun a decision with another model.
- Question
- One typed question, as the decision API takes it.
Constants§
- DEFAULT_
BOOLEAN_ THRESHOLD - The
P(true)a boolean answer needs to count as yes (and1 -this to count as no), unless the question sets its own. - DEFAULT_
CERTAINTY_ THRESHOLD - The certainty a choice or score answer needs, unless the question sets its own.
- DEFAULT_
DECISION_ TIMEOUT - How long a round waits for the decision model.
- DEFAULT_
HISTORY_ TURNS - How many turns of the conversation the decision model reads.
- MAX_
CHOICE_ OPTIONS - The most options a choice question may have.
- NONE_
OPTION - The option a choice gets from
Decision::or_none. - SCORE_
LEVELS - The fewest and most levels a score question may have.
Traits§
- Decision
Model - A model that answers typed questions about a state.