Skip to main content

choiceone

A type-safe decision layer between your Python code and an AI model.

Instead of generating prose and parsing it back, choiceone sends an unstructured state plus a closed set of typed questions and returns typed, probabilistic decisions your code can branch on directly. Answers cannot have a type error: they are always a distribution over the options you supplied.

Implements the "ChoiceOne" protocol: state in, typed probabilistic decisions out.

Install

pip install choiceone            # core, no model dependencies
pip install 'choiceone[local]'   # + local Hugging Face backend (torch, transformers)
pip install 'choiceone[server]'  # + HTTP server (fastapi, uvicorn)

Quick start

from choiceone import ChoiceOne, Choice

so = ChoiceOne()  # default local model
response = so(
    state="My running shoes arrived in the wrong size.",
    questions={
        "department": Choice(
            instructions="Which team should handle this?",
            criteria={
                "returns": "Exchanges, wrong or damaged items",
                "shipping": "Delivery status, delays, lost packages",
                "billing": "Charges, invoices, payment problems",
            },
        ),
    },
)

answer = response.answers["department"]
print(answer.choice, answer.probabilities, answer.confidence)

Primitives

Question Returns
Choice choice, probabilities, confidence
Score score, legend, probabilities, confidence
Noul noul (probability the statement is true, 0-1)

Every Choice/Score answer includes a confidence derived from how peaked the distribution is, so your code can act automatically, ask, or escalate.

Backends

The model side is a pluggable Backend. choiceone ships with two:

  • LocalBackend — a local Hugging Face causal LM (default Qwen/Qwen3-0.6B). Text-generation-free: reads the next-token distribution.
  • OpenAIBackend — any OpenAI-compatible logprobs endpoint (DeepSeek, OpenAI, vLLM, ...). Stdlib only.

Embed your own AI by subclassing Backend and implementing three methods:

from choiceone import Backend

class MyBackend(Backend):
    def build_prompt(self, user_content): ...
    def count_tokens(self, texts): ...
    def probs_over_labels(self, prompts, labels_per_prompt): ...

HTTP server

choiceone-serve --model Qwen/Qwen3-0.6B --port 8000
# POST /v1/choiceone  {"state": ..., "questions": {...}}

License

MIT

Metadata

Release files for choiceone 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for choiceone 1.0.1
File Size Uploaded Provenance
choiceone-1.0.1.tar.gz 18.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for choiceone 1.0.1
File Interpreter ABI Platform
choiceone-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 34.9 kB

Release files / choiceone-1.0.1.tar.gz

Download URL choiceone-1.0.1.tar.gz
Size 18.3 kB
Tags Source
SHA-256 checksum
How to use checksums
42cd3ce5b0dca2f6e6fbda040880b4fac748a2e73251ccb834b78b55008eaf1d
BLAKE2b-256 checksum
How to use checksums
b9aaa6a3a18af1bb5622bde099664e245520206fbeae642a83a1835b6d56542d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / choiceone-1.0.1-py3-none-any.whl

Download URL choiceone-1.0.1-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e83a21b2c3203c4d8a7007bc3a6f049e764cb33e28a6a4be021854e7230dffe
BLAKE2b-256 checksum
How to use checksums
5aaae46e2f5b770c3925d0b6718754cef500474d2f32c1d286a171d85a4f74aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for choiceone 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page