Noullama Python client
Ask a model loaded in Noullama questions from your own Python code.
Install
Python 3.10 or newer. It has no dependencies.
python -m pip install noullama
Using python -m pip makes sure the package goes into the same Python that runs your script.
Quick start
Open Noullama and load a model first.
from noullama import Choice, Client, Noul, Score
nl = Client()
decision = nl.decide(
model="d1-2B-Q8_0",
state="I was charged twice. Please refund the duplicate payment.",
questions={
"route": Choice(
instructions="Which team should handle this?",
billing="Charges and refunds",
technical="App errors",
),
"urgency": Score(
instructions="How urgent is this?",
levels=["Can wait", "This week", "Today", "Immediately"],
),
"refund": Noul(instructions="Is the customer asking for a refund?"),
},
)
answer = decision["route"]
print(answer.value) # billing
print(answer.probabilities) # {'billing': 0.98, 'technical': 0.02}
print(answer.confidence) # 0.98
print(decision.nl_time) # 0.025 (seconds the whole decision took)
model: the model's name or alias as shown in the app's Local API tab. Useany-availablefor any free model.state: the text (or dict or list) you're asking about.questions: each question gets a name you choose ("route"above). You use that name to read its answer.decision,answerandnlare ordinary variable names. Call them whatever you like.
Questions
There are three types. Every question needs instructions, which can't be empty. Descriptions are optional: use None for no description. An empty one like technical="" is an error, so a forgotten description doesn't slip through.
Choice: pick one option. Each option is a name, plus an optional description that helps the model understand it. You get back the name.
Choice(instructions="Which team?", billing="Charges and refunds", technical="App errors")
Choice(instructions="Which team?", billing=None, technical=None) # no descriptions
Score: pick a level on a scale. List the levels lowest first, 2 to 10 of them. You get back the level's number, counting from 0.
Score(instructions="How urgent?", levels=["Can wait", "This week", "Today", "Immediately"])
Noul: yes or no. You get back the chance that the answer is yes, from 0 to 1.
Noul(instructions="Is this a refund request?")
Noul(instructions="Is this a refund request?", true="asks for money back") # optional descriptions
Answers
Every answer has the same three fields:
| Field | Choice | Score | Noul |
|---|---|---|---|
.value |
the picked option, e.g. "billing" |
the picked level, e.g. 2.0 |
chance of yes, e.g. 0.93 |
.probabilities |
chance per option | chance per level ("0", "1", …) |
{"false": 0.07, "true": 0.93} |
.confidence |
how sure the model is, 0 to 1 | same | same |
Native models only send the yes chance for Noul, so the client works out .probabilities and .confidence from it.
Native and Winnow models count Score and confidence differently. Native models give the most likely level and its chance. Winnow models give a weighted average level and an entropy-based confidence. The client shows what the model sends.
The decision as a whole has these:
decision.nl_time: seconds from sending the request to getting the full reply. All questions share one request, so there's one time per decision.decision.modelanddecision.usage: the model name and token counts.decision.rawandanswer.raw: the untouched reply, for anything else, such as a Score'slegend.
Settings and the API key
Client() finds the app's address and your API key, then waits. It sends nothing until you call it. It checks these places in order and uses the first value it finds:
- Arguments:
Client(base_url="http://127.0.0.1:11440", api_key="da-noul-...") - Environment variables
NOULLAMA_URLandNOULLAMA_API_KEY - A
.envfile in the folder you run from, with the same names - Defaults:
http://127.0.0.1:11435and no key
You only need a key when Require API key is on in the app. Keep it out of your code with a .env file:
NOULLAMA_API_KEY=da-noul-...
The address can be pasted from the Local API tab as is, /v1 included. The key never appears in printouts or error messages.
Make one client and reuse it, for example in a loop:
nl = Client()
for email in inbox:
decision = nl.decide(model="d1-2B-Q8_0", state=email, questions=questions)
More
nl.models(): the model names you can use right now.nl.health(): whether the app is up and a model is ready.nl.wait_until_ready(model="d1-2B-Q8_0", timeout=60): waits until that model is ready. Leave outmodelto wait for any model.- Images: pass
images=["receipt.png"]todecide(). This only works with models that have a vision projector. Winnow models are text only.
Errors
Each problem has its own exception, so you can catch the ones you care about:
from noullama import Client, ModelUnavailable, NotRunning, Noul
try:
decision = Client().decide(
model="d1-2B-Q8_0",
state="Please refund my duplicate payment.",
questions={"refund": Noul(instructions="Is this a refund request?")},
)
except NotRunning:
print("Open Noullama first")
except ModelUnavailable:
print("That model isn't loaded yet")
| Exception | Meaning |
|---|---|
NotRunning |
The app isn't open, or isn't at that address |
ModelUnavailable |
The model isn't loaded, is still loading, or every model is busy |
UnknownModel |
No model has that name (names are case-sensitive) |
AmbiguousModel |
The name matches more than one model |
BadRequest |
Something in the request is wrong. The message says what |
AuthError |
The API key is missing, wrong or expired |
Forbidden |
The API key isn't allowed to use this model |
InferenceFailed |
The model failed while answering |
NoullamaError |
The base class of all of the above; catches everything |
Every exception has .message (the app's own wording) and .status (the HTTP status code).
Tested with
Noullama 0.5.4.
License
The Python client is MIT-licensed. The rest of Noullama is AGPL-3.0.
Metadata
Release files for noullama 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| noullama-0.2.0.tar.gz | 19.1 kB | Without provenance | Details for noullama-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| noullama-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for noullama-0.2.0-py3-none-any.whl |
Total release size: 31.0 kB
Release files / noullama-0.2.0.tar.gz
| Download URL | noullama-0.2.0.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed44171133ba5155023fa9730b4ff71711060599c0d6500652561b2442ab7b38
|
|
BLAKE2b-256 checksum How to use checksums |
50220b0232a6c6801d7941850dfe465d4a3420945d43817109138b057962a698
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.2
|
Release files / noullama-0.2.0-py3-none-any.whl
| Download URL | noullama-0.2.0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64d9a73576c40d1e5195289cdd86bfd0ee8cdebeb794ade58851a2acdda323c9
|
|
BLAKE2b-256 checksum How to use checksums |
5fbd5649fef11c044aca35bd62612ea73f7aafdfa1c60e45e1e7ff863f6c4dd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.2
|
Security for noullama 0.2.0
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.