Decide
Answer named yes/no, choice and score questions about a state
The decide and adecide functions answer named questions about a state (text, a JSON object, or an array) with a provider that supports the decide API. See Decide for the providers.
any_llm.decide()
def decide(
model: str,
state: str | Mapping[str, Any] | Sequence[Any],
questions: Mapping[str, Noul | Choice | Score | Mapping[str, Any]],
*,
provider: str | LLMProvider | None = None,
api_key: str | None = None,
api_base: str | None = None,
client_args: dict[str, Any] | None = None,
images: list[str] | None = None,
**kwargs: Any,
) -> DecideResponseany_llm.adecide()
Async variant with the same parameters.
async def adecide(
model: str,
state: str | Mapping[str, Any] | Sequence[Any],
questions: Mapping[str, Noul | Choice | Score | Mapping[str, Any]],
*,
provider: str | LLMProvider | None = None,
api_key: str | None = None,
api_base: str | None = None,
client_args: dict[str, Any] | None = None,
images: list[str] | None = None,
**kwargs: Any,
) -> DecideResponseParameters
model
str
required
Provider-prefixed model ID (e.g., "typesafe:jev-latest").
state
str | Mapping[str, Any] | Sequence[Any]
required
Text, a JSON object, or an array the questions refer to.
questions
Mapping[str, Noul | Choice | Score | Mapping[str, Any]]
required
Names mapped to Noul, Choice or Score questions, their dict forms, or objects with the same attributes.
provider
str | LLMProvider | None
None
Provider name or enum. Inferred from model string if omitted.
api_key
str | None
None
Provider API key. Falls back to environment variable.
api_base
str | None
None
Provider API base URL. Falls back to environment variable.
client_args
dict[str, Any] | None
None
Additional arguments passed to the provider client constructor.
images
list[str] | None
None
Images the questions refer to, as data URLs (data:image/...;base64,...). Providers that do not accept images raise UnsupportedParameterError.
**kwargs
Any
required
Additional arguments for the call, such as timeout in seconds.
Return Value
Returns a DecideResponse containing:
answers-- one answer per question, keyed by question name.nouls,choices,scores-- the answers grouped by question type.model-- the model that served the request.usage-- token usage, when the provider reports it.id-- the provider's request ID, when it reports one.
Usage
Every question type
Async
Last updated