Classifiers¶
Narrow, typed questions answered with probabilities. See the Classifiers guide for usage.
Classifier ¶
Bases: ABC
Answers typed questions about a state, every one or none (ClassifierError).
It sends the questions' wording as the caller wrote it, and bounds its wait. An implementation says how far its probabilities can be trusted.
YesNoQuestion
dataclass
¶
Whether something holds: answered with the probability of yes.
ChoiceQuestion
dataclass
¶
One option among several: answered with every option's probability.
ScoreQuestion
dataclass
¶
A degree on an ordered scale: answered with the expected level.
YesNoAnswer
dataclass
¶
ChoiceAnswer
dataclass
¶
ScoreAnswer
dataclass
¶
Answers ¶
Bases: dict[str, Answer]
The answers by question name, with typed reads.
answers.yes("addressed") is the probability of yes, answers.choice("lang")
the chosen option, answers.score("directness") the expected level.
ClassifierError ¶
Bases: Exception
A classifier could not answer: a refused request, an answer it cannot read, or the end of its bounded wait.
check_answers ¶
answers, once every question has its answer of the right type.
JevClassifier ¶
Bases: Classifier
Answers on Jev, with calibrated probabilities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
The TypeSafe key; the SDK reads |
None
|
model
|
str | None
|
A Jev model id; the SDK's default when None. |
None
|
timeout
|
float
|
Seconds the whole call may take, retries included, before
|
3.0
|
client
|
Any | None
|
An |
None
|
OpenAIClassifier ¶
Bases: Classifier
Answers on OpenAI's Decisions API, with probabilities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
The OpenAI key; the SDK reads |
None
|
model
|
str
|
A model the Decisions API takes. |
DEFAULT_MODEL
|
timeout
|
float
|
Seconds the whole call may take, retries included, before
|
3.0
|
client
|
Any | None
|
An |
None
|
LLMClassifier ¶
Bases: Classifier
Answers on provider under a JSON schema; probabilities degenerate (0 or 1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
AIProvider
|
An AI provider that supports |
required |
timeout
|
float
|
Seconds it waits for the answer before raising |
10.0
|
max_tokens
|
int
|
The answer's cap; a reasoning model needs room for its reasoning. |
1000
|
Raises:
| Type | Description |
|---|---|
ValueError
|
provider does not support a response schema. |
MockClassifier ¶
Bases: Classifier
Answers from a script, by question name: a float for a yes/no question
(the probability of yes), an option for a choice, a level for a score, or an
:data:~roomkit.classifiers.base.Answer. A question the script does not name
gets no, the first option, or the lowest level. Given a list of scripts, the
calls take them in order and the last one repeats. Records every call.