Metadata-Version: 2.4
Name: fastdar
Version: 0.2.0
Summary: FastDAR client: yes/no checks, labels and ticket sorting for lots of short texts.
License: MIT
Project-URL: Homepage, https://fastdar.com
Project-URL: Source, https://github.com/FastDAR/fastdar
Keywords: fastdar,classification,text,support-tickets,labels
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Office/Business
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# fastdar

The official Python client for [FastDAR](https://fastdar.com): yes/no checks, labels and support-ticket sorting for lots of short texts.

It uses only the standard library and needs Python 3.10+.

```sh
pip install fastdar
```

Get a free key at [fastdar.com](https://fastdar.com), then set `FASTDAR_API_KEY` or pass `api_key=`.

## Label texts

```python
from fastdar import FastDAR

fd = FastDAR()                                         # reads FASTDAR_API_KEY

r = fd.classify(["Can I pay yearly instead of monthly?"], labels=["billing", "bug", "how-to"])
print(r["results"][0]["label"], r["results"][0]["probability"])
```

Labels can be plain names or `{"label", "description", "examples"}`; a few real examples make answers sharper. Pass `min_confidence=` to get `not_sure` instead of a weak guess.

## Yes/no checks

```python
r = fd.check("Is this a complaint?", ["My order arrived broken again", "Thanks, all sorted!"])
for x in r["results"]:
    print(x["answer"], x["p_yes"])
```

## Sort support tickets

```python
topics = [{"label": "Payments", "examples": ["My card was declined"]},
          {"label": "Shipping", "examples": ["Where is my parcel?"]}]
r = fd.sort_ticket(["I was charged twice"], topics=topics)
print(r["results"][0]["route"])                        # a topic, or "person" when it isn't sure
```

## Saved labels that learn

Save labels once, use them by name, and tell FastDAR when an answer was wrong. Each correction becomes an example for the right label. Corrections are free.

```python
fd.labels.save("support", topics)
fd.sort_ticket(["Refund hasn't arrived yet"], label_set="support")
fd.labels.correct("support", "Refund hasn't arrived yet", "Payments")
fd.labels.learning("support", False)                   # freeze the set as it is
```

`fd.labels` also has `list()`, `get(name)` and `delete(name)`.

## Several questions about one text

```python
r = fd.decide("Hi, my card was charged twice, please refund one", {
    "refund": {"type": "yes_no", "question": "Is the customer asking for a refund?"},
    "topic": {"type": "choice", "options": ["billing", "shipping", "login"]},
})
print(r["answers"])
```

`fd.usage()` shows your free texts left, credit and usage. Errors are raised as `FastDARError`, which carries `.status` and `.detail`.

Answers come from small models and can be wrong. Measure them on your own texts before you rely on them.

MIT licence.
