Skip to main content

cerno — Python client

Three kinds of question about a piece of text, answered by a locally hosted model:

  • noul — how likely is the answer yes
  • choice — which one of up to 20 options
  • score — where on a rubric of 2–10 levels

Each question is one forward pass, so answers come back in tens of milliseconds.

uv add cerno-sdk
from cerno import Client

client = Client("http://localhost:3000")

answers = (
    client.systemone("Ticket: server room at 31C, rising, servers throttling.")
    .noul("urgent", "Is this urgent?")
    .choice("team", "Which team?", ["IT", "Facility", "HR"])
    .score("sev", "How severe?", ["harmless", "minor", "moderate", "high", "critical"])
    .send()
)

answers.noul("urgent")        # 0.991
answers.choice("team")        # "Facility"
answers.score("sev")          # 5
answers.legend("sev")         # "critical"
answers.confidence("team")    # 0.939

Questions in one call share their state, so the text is sent and prefilled once.

Async

Same surface, await on send():

from cerno import AsyncClient

async with AsyncClient("http://localhost:3000") as client:
    answers = await client.systemone(text).noul("spam", "Is this spam?").send()

Reading the answer honestly

Every answer carries the evidence it came from:

answers.truncated("team")          # some label fell outside the host's reporting window
answers.truncated_labels("team")   # ("C",) — which ones; their raw_logprobs entry is a bound
answers["team"].raw_logprobs       # {"A": -4.54, "B": -0.02, ...}
answers["team"].probabilities      # per option, in request order

truncated is worth checking when you act on a probability rather than on the winner: it means at least one option ranked below everything the host reported, so its probability is an upper bound, not an observation.

To flatten an overconfident model, scale the logits before they are normalised:

client.systemone(text).calibration(2.5).noul("urgent", "Is this urgent?").send()

Above 1 flattens, below 1 sharpens, and raw_logprobs is unaffected either way.

Errors

from cerno import ApiError

try:
    answers = client.systemone(text).choice("team", "Which?", options).send()
except ApiError as err:
    err.code         # "too_many_options" — branch on this, never on the message
    err.question_id  # "team"

UnexpectedResponse is raised instead when a body is not something cerno sends — a non-2xx that is not a cerno error, or a 2xx that is not an answer — which usually means a proxy between you and the service. TransportError means the service could not be reached or timed out; the httpx exception is its __cause__. All three derive from CernoError.

The builder refuses two easy mistakes with a TypeError before anything is sent: a string where the options belong (.choice("team", "Which team?") would otherwise ask about eleven single letters), and a string or bool as a score rubric.

Metadata

Release files for cerno-sdk 0.1.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 cerno-sdk 0.1.1
File Size Uploaded
cerno_sdk-0.1.1.tar.gz 18.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cerno-sdk 0.1.1
File Interpreter ABI Platform
cerno_sdk-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.2 kB

Release files / cerno_sdk-0.1.1.tar.gz

Download URL cerno_sdk-0.1.1.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c01f86a21c906c63c35b01233e3720198eaccbdac5f7e99c67de1f0c2df7b617
BLAKE2b-256 checksum
How to use checksums
47d26c495ea45f064d9b1e9944c75c017ffee0c09d30ca0ef9b3f35454152628
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / cerno_sdk-0.1.1-py3-none-any.whl

Download URL cerno_sdk-0.1.1-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cec216a594a9380309a37cf806041d911816d15cf9fddee57742a981274a24be
BLAKE2b-256 checksum
How to use checksums
af462c8aa9498c75f73db5ce64f7da863bd91e711b5d72793c2daf98d3b2b730
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

This release

0.1.1 This release

2 release files

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