Question and response types for the OpenAI Decisions API.
A discriminated union of question types accepted by OpenAIDecisions.
A discriminated union of answers returned by OpenAIDecisions.
One level of a Score rubric.
Complete input for one OpenAIDecisions invocation.
Keeping the input and questions together in the Runnable input ensures both participate in composition, batching, and tracing.
Probability that a Predicate condition is true.
Selected Choice value with its probability distribution and confidence.
Expected Score value with its levels, distribution, and confidence.
The model declined to answer a question.
Token usage reported for a Decisions request.
Typed answers and metadata returned from one Decisions request.
Access every answer through answers, or use predicates, choices, scores,
and refusals for views filtered by answer type. Each mapping is keyed by the
question names supplied in DecisionRequest.questions.
Input accepted by OpenAIDecisions.
The Decisions API natively accepts a string or user messages containing text and
base64 images. Strings and HumanMessage objects (alone or in a sequence) are sent
natively. Any other state, such as conversations with system or AI messages, or JSON
objects, is sent as JSON text in a single user message, with base64 images kept in
place as image parts.
Estimate the probability that a condition is true.
from langchain_openai.decisions import OpenAIDecisions, Predicate
decisions = OpenAIDecisions(model="gpt-6-luna")
response = decisions.invoke(
{
"input": "Production is down. Please help immediately.",
"questions": {
"urgent": Predicate(instructions="Is this request urgent?"),
},
}
)
if response.predicates["urgent"].probability >= 0.8:
page_on_call_engineer()Select one value from a fixed, unordered set of options.
from langchain_openai.decisions import Choice, OpenAIDecisions
decisions = OpenAIDecisions(model="gpt-6-luna")
response = decisions.invoke(
{
"input": "I was charged twice for my order.",
"questions": {
"department": Choice(
instructions="Which department should handle this?",
choices={
"billing": "Payments, invoices, and refunds.",
"technical": "Problems using the product.",
"other": "Requests outside these categories.",
},
),
},
}
)
department = response.choices["department"]
if department.confidence >= 0.7:
route_to(department.choice)Rate the input against ordered levels.
Levels are indexed from 0 in the order supplied. The returned score is the
probability-weighted average of those indices, so it may fall between levels.
from langchain_openai.decisions import Level, OpenAIDecisions, Score
decisions = OpenAIDecisions(model="gpt-6-luna")
response = decisions.invoke(
{
"input": "Export fails in Safari but works in Chrome.",
"questions": {
"severity": Score(
instructions="How severe is this issue?",
levels=[
Level(label="Cosmetic", description="No lost function."),
Level(label="Workaround", description="Another way works."),
Level(label="Blocked", description="No workaround."),
],
),
},
}
)
print(response.scores["severity"].score) # May be fractional, e.g. 1.1