> ## Documentation Index
> Fetch the complete documentation index at: https://ladygraph.io.vn/llms.txt
> Use this file to discover all available pages before exploring further.

# decision

> Choose between options, or score texts.

Decision layer: one interface (`Decider`), with adapters for DecisionLite, an LLM judge, or any endpoint.

## `decision.base`

The interface the index depends on to make small decisions, and the types around it.

#### `Decider`

Small decisions over English text.

Construct with `Decider(*args, **kwargs)`.

| Method | What it does |
| - | - |
| `apick(self, text: str, options: Sequence[Option], *, allow_other: bool = True, instructions: str = '') -> Pick` | — |
| `pick(self, text: str, options: Sequence[Option], *, allow_other: bool = True, instructions: str = '') -> Pick` | — |
| `ascore(self, query: str, texts: Sequence[str]) -> list[float]` | — |
| `score(self, query: str, texts: Sequence[str]) -> list[float]` | One number in \[0, 1] per text, higher meaning a better answer to `query`. |

#### `DecisionError`

The call failed (model error, timeout, bad answer) after the adapter's own retries.

#### `Option`

| Field | Type | Default |
| - | - | - |
| `key` | `str` | required |
| `description` | `str` | required |
| `label` | `str \| None` | `None` |

#### `Pick`

The outcome of `pick`.

| Field | Type | Default |
| - | - | - |
| `key` | `str \| None` | required |
| `probabilities` | `dict[str, float]` | required |
| `confidence` | `float` | `0.0` |

| Method | What it does |
| - | - |
| `(property)` | — |
| `ranked(self, n: int \| None = None) -> list[str]` | Option keys, best first, without `OTHER`. |

#### `PickSpec`

A `pick` question without its text: the options, whether 'none' is allowed, and the instructions.

| Field | Type | Default |
| - | - | - |
| `options` | `tuple[Option, ...]` | required |
| `allow_other` | `bool` | `True` |
| `instructions` | `str` | `''` |

#### `Preparable`

Optional: a decider that is cheaper when it learns its option sets before the first `pick`.

Construct with `Preparable(*args, **kwargs)`.

| Method | What it does |
| - | - |
| `prepare(self, specs: Sequence[PickSpec]) -> None` | — |

#### `check_options`

```python theme={null}
check_options(options: Sequence[Option], allow_other: bool = True) -> None
```

Reject a bad option set.

## `decision.composite`

Use one decider for `pick` and another for `score`.

#### `CompositeDecider`

Construct with `CompositeDecider(picker: Decider, scorer: Decider)`.

| Method | What it does |
| - | - |
| `prepare(self, specs: Sequence[PickSpec]) -> None` | — |
| `apick(self, text: str, options: Sequence[Option], *, allow_other: bool = True, instructions: str = '') -> Pick` | — |
| `pick(self, text: str, options: Sequence[Option], *, allow_other: bool = True, instructions: str = '') -> Pick` | — |
| `ascore(self, query: str, texts: Sequence[str]) -> list[float]` | — |
| `score(self, query: str, texts: Sequence[str]) -> list[float]` | — |

## `decision.decision_lite`

A decider backed by the DecisionLite SDK (EmbeddingGemma through the MediaPipe Decision Maker).

#### `DecisionLiteDecider`

`Decider` over a DecisionLite SDK instance.

Construct with `DecisionLiteDecider(decision_model: str \| pathlib.Path, *, backend: str = 'cpu', workers: int = 1, auto_prepare: bool = True)`.

| Method | What it does |
| - | - |
| `prepare(self, specs: Sequence[PickSpec], *, replace: bool = False) -> None` | Register option sets with one reload. |
| `close(self) -> None` | — |
| `pick(self, text: str, options: Sequence[Option], *, allow_other: bool = True, instructions: str = '') -> Pick` | — |
| `apick(self, text: str, options: Sequence[Option], *, allow_other: bool = True, instructions: str = '') -> Pick` | — |
| `score(self, query: str, texts: Sequence[str]) -> list[float]` | — |
| `ascore(self, query: str, texts: Sequence[str]) -> list[float]` | — |

#### `build_config_text`

```python theme={null}
build_config_text(model_path: str, specs: Sequence[PickSpec], *, backend: str = 'cpu', workers: int = 1) -> str
```

A DecisionLite config, as YAML text, with one choice decision per spec and no translator.

#### `spec_name`

```python theme={null}
spec_name(spec: PickSpec) -> str
```

The decision name for a spec.

## `decision.fake`

A scripted decider for tests: no model, no network.

#### `FakeDecider`

Returns canned replies in order and records every request.

Construct with `FakeDecider(picks: list[Pick \| Exception \| Callable[[str, Sequence[Option], bool], Pick]] \| None = None, scores: list[list[float] \| Exception \| Callable[[str, Sequence[str]], list[float]]] \| None = None, model: str = 'fake/decider')`.

| Method | What it does |
| - | - |
| `choosing(cls, key: str \| None, options: Sequence[Option], *, allow_other: bool = True) -> Pick` | A confident `Pick` for `key` (None means 'other'), with the rest of the probability spread evenly. |
| `apick(self, text: str, options: Sequence[Option], *, allow_other: bool = True, instructions: str = '') -> Pick` | — |
| `pick(self, text: str, options: Sequence[Option], *, allow_other: bool = True, instructions: str = '') -> Pick` | — |
| `ascore(self, query: str, texts: Sequence[str]) -> list[float]` | — |
| `score(self, query: str, texts: Sequence[str]) -> list[float]` | — |

## `decision.lexical`

A decider that works from the words in the text, with no model and no network.

#### `LexicalDecider`

Construct with `LexicalDecider(embedder: Embedder \| None = None, *, temperature: float = 12.0, other_similarity: float = 0.3)`.

| Method | What it does |
| - | - |
| `pick(self, text: str, options: Sequence[Option], *, allow_other: bool = True, instructions: str = '') -> Pick` | — |
| `apick(self, text: str, options: Sequence[Option], *, allow_other: bool = True, instructions: str = '') -> Pick` | — |
| `score(self, query: str, texts: Sequence[str]) -> list[float]` | — |
| `ascore(self, query: str, texts: Sequence[str]) -> list[float]` | — |

## `decision.llm_judge`

A decider that asks an LLM to rate the options, through the `LlmClient` Protocol.

#### `LlmJudgeDecider`

`Decider` over any `LlmClient`.

Construct with `LlmJudgeDecider(llm: LlmClient, *, max_texts: int = 40)`.

| Method | What it does |
| - | - |
| `apick(self, text: str, options: Sequence[Option], *, allow_other: bool = True, instructions: str = '') -> Pick` | — |
| `pick(self, text: str, options: Sequence[Option], *, allow_other: bool = True, instructions: str = '') -> Pick` | — |
| `ascore(self, query: str, texts: Sequence[str]) -> list[float]` | — |
| `score(self, query: str, texts: Sequence[str]) -> list[float]` | — |

#### `pick_from_ratings`

```python theme={null}
pick_from_ratings(options: Sequence[Option], ratings: Sequence[int], allow_other: bool) -> Pick
```

The fixed rule from ratings to a `Pick`.

## `decision.system_one`

A decider for System One style decision endpoints: `POST /v1/systemone` (Cloudflare Clef, Kev, a PPLX decider, or any model that SGLang serves through that route).

#### `SystemOneDecider`

`Decider` over a System One endpoint.

Construct with `SystemOneDecider(base_url: str, *, model: str = 'Cloudflare/clef-flash', timeout_s: float = 300.0, attempts: int = 3, backoff_s: float = 1.0, max_concurrency: int = 10, api_key_env: str \| None = None, score_instructions: str = 'Does the text directly answer the question?', transport: httpx.BaseTransport \| httpx.AsyncBaseTransport \| None = None, sleep: Callable[[float], None] = <built-in function sleep>, asleep: Callable[[float], typing.Any] = <function sleep at 0x102764b80>)`.

| Method | What it does |
| - | - |
| `close(self) -> None` | — |
| `pick(self, text: str, options: Sequence[Option], *, allow_other: bool = True, instructions: str = '') -> Pick` | — |
| `apick(self, text: str, options: Sequence[Option], *, allow_other: bool = True, instructions: str = '') -> Pick` | — |
| `score(self, query: str, texts: Sequence[str]) -> list[float]` | — |
| `ascore(self, query: str, texts: Sequence[str]) -> list[float]` | — |

#### `option_names`

```python theme={null}
option_names(options: Sequence[Option], allow_other: bool) -> tuple[list[str], str | None]
```

Server-safe names for the options, and the name of the 'none of the above' option (None when not offered).

#### `parse_pick`

```python theme={null}
parse_pick(response: Any, back: dict[str, str | None]) -> Pick
```

#### `parse_score`

```python theme={null}
parse_score(response: Any) -> float
```

#### `pick_request`

```python theme={null}
pick_request(model: str, text: str, options: Sequence[Option], allow_other: bool, instructions: str) -> tuple[dict[str, typing.Any], dict[str, str | None]]
```

The request body, and the map from option name back to key (None is the 'other' answer).

#### `score_request`

```python theme={null}
score_request(model: str, query: str, text: str, instructions: str) -> dict[str, typing.Any]
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.