Metadata-Version: 2.3
Name: decision-ui
Version: 0.2.1
Summary: Add your description here
Author: panuthept
Author-email: panuthept <falcon_270394@hotmail.co.th>
Requires-Dist: fastapi>=0.143.0
Requires-Dist: openai>=3.29.0
Requires-Dist: pydantic>=2.14.1
Requires-Dist: transformers>=5.19.0
Requires-Dist: typer>=0.27.3
Requires-Dist: typesafe-sdk>=0.7.4
Requires-Dist: uvicorn>=0.54.0
Requires-Python: >=3.14
Description-Content-Type: text/markdown

# DecisionUI

**Turn LLM API into Decision Model API.**

DecisionUI is a lightweight Python server that sits in front of a Chat Completions endpoint (vLLM, SGLang, Ollama, a hosted API, etc.) and exposes it through two decision APIs:

- **SystemOne API**
- **OpenAI Decisions API**

Instead of parsing free-form text, you ask structured questions and get back the chosen option along with its probabilities.

## Installation

```bash
pip install decision-ui
```

## Quick Start

**1. Serve a model** with any OpenAI-compatible inference engine, for example vLLM:

```bash
vllm serve google/gemma-4-31B-it --host localhost --port 8000
```

**2. Launch DecisionUI** and point it at the model server:

```bash
decision-ui serve http://localhost:8000 --host localhost --port 9000
```

**3. Use a LLM as a Decision Model**

```python
from typesafe_sdk import Choice, TypeSafeClient

with TypeSafeClient(base_url="http://localhost:9000", api_key="EMPTY") as client:
    decision = client.system_one(
        model="google/gemma-4-31B-it",
        state={"document": "I was charged twice. Please fix this ASAP."},
        questions={
            "category": Choice(
                instructions="What is this ticket about?",
                criteria={"billing": None, "technical": None, "other": None},
            ),
        },
    )

print(decision.choices["category"].probabilities)
```

Example output:

```python
{"billing": 0.94, "technical": 0.03, "other": 0.03}
```

### How it works

```
Your app ──► DecisionUI (:9000) ──► Chat Completions server (:8000) ──► LLM
          SystemOne / Decisions API        e.g. vLLM
```

## CLI Reference

```bash
decision-ui serve <backend_url> [--host HOST] [--port PORT]
```

| Option        | Description                                      | Default     |
|---------------|--------------------------------------------------|-------------|
| `backend_url` | Base URL of the OpenAI-compatible model server.  | required    |
| `--host`      | Interface DecisionUI binds to.                   | `localhost` |
| `--port`      | Port DecisionUI listens on.                      | `9000`      |
