# Decision Types


Build question dictionaries with [`noul`](#noul), [`choice`](#choice), [`score`](#score), and [`box`](#box) (or pass raw Jev-compatible dicts validated by [`norm_question`](#norm_question)). [`choice`](#choice) and [`score`](#score) normalize inputs with `listify` and require at least two options or levels; [`noul`](#noul) accepts only `'true'` and `'false'` criteria keys.

[`Decision`](#decision) is a read-only `Mapping` over an `AttrDict` of typed answers ([`NoulAnswer`](#noulanswer), [`ChoiceAnswer`](#choiceanswer), [`ScoreAnswer`](#scoreanswer), [`BoxAnswer`](#boxanswer), [`RefusalAnswer`](#refusalanswer)) with attribute access (`dec.q`), bracket access (`dec['q']`, required when a question name collides with [`Decision`](#decision) or `Mapping` attributes), `custom_dir` tab-completion, and estimated USD `cost`. [`lower_state`](#lower_state) recursively converts `aidialog.msg_parts` `Msg` and `Part` objects plus nested JSON, omitting `Thinking`, `Msg.raw`, and `UNSET` while preserving JSON `None` and tool call IDs.

## noul

``` python
def noul(
    instructions=None, # Yes/no question or statement to evaluate
    *, true=None, # Optional description of what counts as yes/true
    false=None, # Optional description of what counts as no/false
    criteria:dict=None, # Optional explicit `{'true': ..., 'false': ...}` mapping
)->dict:
```

*Build a Jev [`noul`](#noul) (yes/no probability) question dictionary.*

## choice

``` python
def choice(
    criteria, # Mapping `{option: description_or_None}` or sequence of at least 2 option names
    instructions=None, # Question guiding the selection
)->dict:
```

*Build a Jev [`choice`](#choice) (single-select classification) question dictionary.*

## score

``` python
def score(
    criteria, # Ordered rubric list of level descriptions, or `{label: description}` mapping
    instructions=None, # Question describing what to rate
)->dict:
```

*Build a Jev [`score`](#score) (ordered rubric rating) question dictionary.*

## box

``` python
def box(
    instructions=None, # Description of what to locate in the image (Jev 1.14+ only)
)->dict:
```

*Build a Jev [`box`](#box) (spatial bounding box) question dictionary.*

## score_criteria_list

``` python
def score_criteria_list(
    criteria
)->list:
```

*Convert a [`score`](#score) rubric (list or `{label: description}` dict) into an ordered list.*

## norm_question

``` python
def norm_question(
    q
)->dict:
```

*Validate a question dict (or bare string shorthand for [`noul`](#noul)) and return a shallow copy.*

## NoulAnswer

``` python
def NoulAnswer(
    noul:float, # Probability of yes/true, in [0, 1]
    confidence:float=None, # Confidence in [0.5, 1]; defaults to `max(noul, 1 - noul)`
    raw:dict=None, # Original provider answer dict
):
```

*Calibrated yes/no probability answer (`type='noul'`).*

## ChoiceAnswer

``` python
def ChoiceAnswer(
    choice:str, # Selected option name
    confidence:float, # Confidence in [0, 1]
    probabilities:dict, # `{option: probability}` mapping
    raw:dict=None, # Original provider answer dict
):
```

*Single-select classification answer (`type='choice'`).*

## ScoreAnswer

``` python
def ScoreAnswer(
    score:float, # Expected score (probability-weighted average of zero-based rubric indices)
    confidence:float, # Confidence in [0, 1]
    probabilities:dict, # `{level_index_str: probability}` mapping
    legend:dict, # `{level_index_str: criterion}` rubric mapping
    raw:dict=None, # Original provider answer dict
):
```

*Ordered rubric rating answer (`type='score'`).*

## BoxCoordinates

``` python
def BoxCoordinates(
    top:float, bottom:float, left:float, right:float
):
```

*Normalized bounding-box edges as fractions of image height/width in \[0, 1\].*

## BoxAnswer

``` python
def BoxAnswer(
    box, # `BoxCoordinates` or dict with `top`, `bottom`, `left`, `right`
    confidence:float=None, # Confidence in [0, 1], or None when omitted
    raw:dict=None, # Original provider answer dict
):
```

*Spatial bounding-box answer (`type='box'`).*

## RefusalAnswer

``` python
def RefusalAnswer(
    raw:dict=None, # Original provider answer dict
):
```

*Per-question refusal answer (`type='refusal'`), returned by OpenAI when an individual question is refused.*

## norm_answer

``` python
def norm_answer(
    d:dict
):
```

*Parse a canonical Jev-shaped answer dictionary into its typed answer object.*

## check_answers

``` python
def check_answers(
    answers:dict, # Normalized `{question_name: Answer}` mapping
    questions:dict=None, # Optional requested `{question_name: question}` mapping to verify completeness
)->dict:
```

*Verify every requested question in `questions` has an answer, ordering by `questions` when given.*

## Decision

``` python
def Decision(
    model:str, # Model name returned by the provider (or requested when omitted)
    answers:dict, # `{question_name: Answer}` mapping
    usage:fastdecisions.utils.Usage=None, # Normalized token usage
    api_name:str=None, # Registered provider name, e.g. 'jev', 'gemini', 'openai'
    raw:dict=None, # Full provider response dict
):
```

*Read-only mapping of normalized decision answers alongside model, usage, and raw metadata.*

### Decision.cost

``` python
def cost()->float:
```

*Estimated USD cost using `usage`, [`get_model_info`](utils.html#get_model_info), and [`calc_cost`](utils.html#calc_cost).*

## lower_state

``` python
def lower_state(
    o, # Value, `Msg`, `Part`, or nested dict/list/tuple structure to lower to JSON-ready data
    on_media=None, # Optional callable `(p:Media) -> Any` returning a placeholder or `UNSET`; raises `ValueError` on `Media` when `None`
    *,
    drop_server_tools:bool=False, # Drop provider-executed `ToolUse(server=True)` parts and their matching `ToolResult`s?
):
```

*Recursively lower `aidialog` `Msg`/`Part` objects into JSON-ready structures, returning `UNSET` for dropped items.*
