Skip to main content

fastdecisions

fastdecisions provides a single Jev-style async interface for decision models across TypeSafe Jev (jev-1.14.0), Google Gemini (gemini-decision-1), and OpenAI (gpt-6-luna). Pass shared evidence—text, JSON, aidialog.msg_parts.Msg chat histories, or media—alongside batched noul (yes/no probability), choice (classification), score (rubric rating), or box (bounding box) questions, and swap providers with a single model= argument. Each provider adapter runs on fastspec.OpenAPIClient with offline bundled specs.

Install

Run pip install fastdecisions or clone from GitHub and install locally (pip install -e .).

Set whichever provider key(s) you plan to use: TYPESAFE_API_KEY (TypeSafe Jev), GEMINI_API_KEY (Google Gemini), or OPENAI_API_KEY (OpenAI).

Quickstart

from fastdecisions import adecide, decide, Decider, noul, choice, score, box, jev, gem_dec, luna

For a one-off yes/no check with a single provider (TYPESAFE_API_KEY), pass a bare string as questions and read r.answer.noul:

ticket = 'I was charged twice for my subscription this month and nobody has replied yet. Fix this today!'
r_one = await adecide(ticket, 'Is this message about billing?', model=jev)
f"p={r_one.answer.noul:.3f}, confidence={r_one.answer.confidence:.3f}"
'p=0.990, confidence=0.990'

Decisions across providers

Define questions once using Jev’s canonical schema—plain strings act as noul yes/no shorthand, noul(..., true=..., false=...) adds boundary criteria, choice accepts either a list of labels or a {label: description} dict, and score takes an ordered rubric—then swap model= across Jev, Gemini, and GPT-6 Luna:

qs = dict(billing='Is this message about billing?',
    prior_contact=noul('Has the customer contacted support about this before?',
        true='Mentions a prior attempt, ticket, or waiting for a reply', false='No sign of any previous contact'),
    tone=choice(['angry', 'calm', 'excited'], 'What is the tone of this message?'),
    urgency=score(['Can wait', 'Needs attention this week', 'Needs attention today'], 'How urgent is this message?'))

for m in (jev, gem_dec, luna):
    r = await adecide(ticket, qs, model=m)
    print(f"{m:18} billing={r.billing.noul:.2f}  prior={r.prior_contact.noul:.2f}  tone={r.tone.choice:7}  urgency={r.urgency.score:.2f}  cost=${r.cost:.6f}")
jev-1.14.0         billing=0.98  prior=0.73  tone=angry    urgency=2.00  cost=$0.000018
gemini-decision-1  billing=0.99  prior=0.92  tone=angry    urgency=1.88  cost=$0.000030
gpt-6-luna         billing=1.00  prior=1.00  tone=angry    urgency=2.00  cost=$0.000057

Inspect a Decision bare in a notebook to render a summary table alongside collapsible raw JSON, or access answers by attribute (r.tone.choice) or key (r['tone'].probabilities):

r
Question Type Value Confidence
billing noul 1.000 1.000
prior_contact noul 1.000 1.000
tone choice angry 1.000
urgency score 2.000 1.000
  • model: gpt-6-luna
  • tokens: 575 in / 0 out
  • cost: $0.000057
  • billing: NoulAnswer(noul=1.0, confidence=1.0, raw={'type': 'predicate', 'name': 'billing', 'probability': 1.0})
  • prior_contact: NoulAnswer(noul=1.0, confidence=1.0, raw={'type': 'predicate', 'name': 'prior_contact', 'probability': 1.0})
  • tone: ChoiceAnswer(choice='angry', confidence=1.0, probabilities={'angry': 1.0, 'calm': 0.0, 'excited': 0.0}, raw={'type': 'choice', 'name': 'tone', 'choice': 'angry', 'probabilities': [{'value': 'angry', 'probability': 1.0}, {'value': 'calm', 'probability': 0.0}, {'value': 'excited', 'probability': 0.0}], 'confidence': 1.0})
  • urgency: ScoreAnswer(score=2.0, confidence=1.0, probabilities={'0': 0.0, '1': 0.0, '2': 1.0}, legend={'0': 'Can wait', '1': 'Needs attention this week', '2': 'Needs attention today'}, raw={'type': 'score', 'name': 'urgency', 'score': 2.0, 'probabilities': [{'value': 0, 'label': 'Can wait', 'probability': 0.0}, {'value': 1, 'label': 'Needs attention this week', 'probability': 0.0}, {'value': 2, 'label': 'Needs attention today', 'probability': 1.0}], 'confidence': 1.0})

Reusable Decider and batching

Bind a question schema and model once in a Decider to evaluate many items concurrently with .batch(...) while tracking cumulative token usage and USD cost:

triage = Decider(dict(billing='Is this about billing?', tone=choice(['angry', 'calm', 'excited'], 'Tone?')), model=jev)
tickets = ['You double-charged my card and I want an immediate refund!',
    'Love the new dark mode, great work team!',
    'Could you explain how to export a CSV from my dashboard?']
for t, res in zip(tickets, await triage.batch(tickets)): print(f"tone={res.tone.choice:7}  billing={res.billing.noul:.2f}  | {t}")
print(f"Total: {triage.usage.prompt_tokens} input tokens, ${triage.cost:.6f}")
tone=angry    billing=0.98  | You double-charged my card and I want an immediate refund!
tone=excited  billing=0.02  | Love the new dark mode, great work team!
tone=calm     billing=0.10  | Could you explain how to export a CSV from my dashboard?
Total: 951 input tokens, $0.000040

Chat history

Pass aidialog.msg_parts.Msg conversations directly as state. Each adapter strips internal Thinking blocks and converts the history into its provider format (JSON on Jev, structured JSON on Gemini, native Responses items on OpenAI):

from aidialog.msg_parts import Msg, Text, Thinking
history = [Msg('user', [Text('My parcel arrived smashed.')]),
    Msg('assistant', [Thinking('Check order status first'), Text('I am sorry to hear that. I have issued a full refund to your card.')]),
    Msg('user', [Text('Thanks, that solves it!')])]
for m in (jev, gem_dec, luna):
    r = await adecide(history, dict(resolved='Did the customer confirm their issue is resolved?'), model=m)
    print(f"{m:18} resolved={r.resolved.noul:.3f}")
jev-1.14.0         resolved=0.980
gemini-decision-1  resolved=0.981
gpt-6-luna         resolved=1.000

Vision and bounding boxes

Pass an InputImage directly as state across all three providers. On Jev, add a box question to locate normalized [0, 1] bounding coordinates (Gemini and OpenAI raise NotImplementedError for box):

from PIL import Image as PImg, ImageDraw
from fastcore.utils import img_bytes
from aidialog.msg_parts import InputImage, to_data_url
canvas = PImg.new('RGB', (320, 320), 'white')
ImageDraw.Draw(canvas).rectangle([80, 80, 240, 240], fill='red')
red_img = InputImage(to_data_url(img_bytes(canvas, fmt='PNG')), mime='image/png')

for m in (jev, gem_dec, luna):
    r = await adecide(red_img, dict(has_red='Does this image contain a red rectangle?',
        color=choice(['red', 'blue', 'green'], 'Main shape color?')), model=m, resolution='low')
    print(f"{m:18} has_red={r.has_red.noul:.2f}  color={r.color.choice}")

r_box = await adecide(red_img, dict(rect=box('Locate the red rectangle.')), model=jev)
r_box.rect
jev-1.14.0         has_red=0.87  color=red
gemini-decision-1  has_red=0.84  color=red
gpt-6-luna         has_red=1.00  color=red

BoxAnswer(top=0.17, left=0.23, bottom=0.90, right=0.75, confidence=0.730)

Provider capabilities

Provider-specific options pass through adecide(..., **kwargs) and are ignored by other adapters (for example long_context=True on Jev, resolution='low' on Gemini, and prompt_cache_key / prompt_cache_options on OpenAI). For synchronous code (scripts or notebooks), use the decide(...) wrapper.

Capability TypeSafe Jev (jev-1.14.0) Google Gemini (gemini-decision-1) OpenAI (gpt-6-luna)
noul, choice, score Yes Yes Yes (noul criteria folded into instructions)
box bounding boxes Yes No (NotImplementedError) No (NotImplementedError)
Msg chat history JSON in state Structured JSON + media Native message + tool items
InputImage Yes (PNG/JPEG, 280–1568 px) Yes (plus resolution) Yes (plus detail)
InputAudio / InputVideo / InputFile No Yes No
Per-question refusals Never Whole-request block (APIError) RefusalAnswer in answers

Metadata

Release files for fastdecisions 0.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 fastdecisions 0.0.1
File Size Uploaded Provenance Actions
fastdecisions-0.0.1.tar.gz 36.3 kB Without provenance Details for fastdecisions-0.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 75.1 kB

Release files / fastdecisions-0.0.1.tar.gz

Download URL fastdecisions-0.0.1.tar.gz
Size 36.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cd1bbf15b8b6893d44a1cf6973c647ec7074606c131f36729de64d2c39f8f021
BLAKE2b-256 checksum
How to use checksums
2f341aa60b497badb299f1a26e7264e6ab962158bd0c85ee9e0f2a3c66935bad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / fastdecisions-0.0.1-py3-none-any.whl

Download URL fastdecisions-0.0.1-py3-none-any.whl
Size 38.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d54574fa083fbd0301319f23b9849245cd3e2d6eebe8a9a274887adfcb92ca7
BLAKE2b-256 checksum
How to use checksums
a7eed7950db0c6ca56f8e19c1431e04aec7bf6992bb8bfa475148befacc69aa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for fastdecisions 0.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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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