umpirix/examples/README.md
caelum0x 03c7e2c397 fix(license): consistent Apache-2.0/MIT split + migrate 3 examples from private audit
- Root LICENSE: replace the short-form notice with the full canonical
  Apache-2.0 text (fixes GitHub's "Other" license detection); update the
  OpenJev -> Umpirix copyright line in LICENSE/NOTICE, otsone/NOTICE and
  sdk/python/LICENSE+NOTICE (missed by the rebrand pass).
- sdk/ai-sdk: was MIT with no LICENSE/NOTICE and no upstream fork trail
  (unlike sdk/js, sdk/python, adapters/python, skills, which are real
  TypeSafe AI SDK forks and correctly keep MIT per their NOTICE). It is
  original Umpirix code, so switch it to Apache-2.0 with its own
  LICENSE/NOTICE, matching the root.
- README Licensing section: list sdk/ai-sdk under Apache-2.0 and
  sdk/scribase-decisions under MIT, and spell out why the TypeSafe-forked
  directories stay MIT (their MIT terms require preserving the notice).
- Audited caelum0x/openjev-private (read-only clone): it's an older,
  mostly-superseded snapshot of this repo. Migrated the 3 self-contained,
  secret-free example scripts it had that this repo didn't (raw-HTTP, no
  SDK dependency): content-moderation, lead-scoring, support-ticket-routing
  (Python + Node.js, each with a sample JSONL), plus
  scripts/reproduce-leaderboard.mjs (wired to a new `npm run
  bench:reproduce`) for leaderboard reproducibility. Left behind in
  private: src/lib/seo/retired.ts (a reversed decision - this repo now has
  live /compare pages) and the hosted-SaaS pieces already superseded by
  this repo's own, newer versions of the same files.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-11 19:08:57 +03:00

52 lines
3.7 KiB
Markdown

# Examples
Runnable scripts against a running OpenJev server (`npm run dev` or
`docker compose up`). Each batches a typed question set (Choice + Score + Noul) per item
in one request, then applies a ranking/routing policy in plain code over the returned
probabilities — the model only judges the candidates you hand it, the decision logic stays
in your code and is free to change without another inference call.
| Example | Language | Shows |
|---|---|---|
| [`rank-ads.mjs`](./rank-ads.mjs) | Node.js (built-in `fetch`, no dependency) | Ranking ad-copy hooks by a composite score built from `score` + two `noul` flags |
| [`triage-tickets.py`](./triage-tickets.py) | Python (`openjev` SDK) | Routing support tickets by department (`choice`) and a priority built from `score` + `noul` |
| [`official-sdk.py`](./official-sdk.py) | Python (official `typesafe-sdk` from PyPI) | The unmodified TypeSafe SDK against OpenJev: choice, score, noul, several questions at once, `models.list()`, a rejected request |
| [`official-sdk.mjs`](./official-sdk.mjs) | Node.js (official `@typesafe-ai/sdk` from npm) | The same, plus a zstd-compressed request body |
| [`content-moderation/triage.py`](./content-moderation/triage.py) / [`.ts`](./content-moderation/triage.ts) | Python + Node.js (raw HTTP, no SDK) | Sorting comments into publish / hold / human-review from a `choice` category plus confidence, over [`posts.jsonl`](./content-moderation/posts.jsonl) |
| [`lead-scoring/score.py`](./lead-scoring/score.py) / [`.ts`](./lead-scoring/score.ts) | Python + Node.js (raw HTTP, no SDK) | Three typed questions per lead (stage `score`, segment `choice`, inquiry-vs-pitch `choice`) combined into a points formula in code, over [`leads.jsonl`](./lead-scoring/leads.jsonl) |
| [`support-ticket-routing/route.py`](./support-ticket-routing/route.py) / [`.ts`](./support-ticket-routing/route.ts) | Python + Node.js (raw HTTP, no SDK) | Team `choice` + urgency `score` + a refund `noul` flag per ticket, auto-routed vs sent to a human queue, over [`tickets.jsonl`](./support-ticket-routing/tickets.jsonl) |
The three above use only `urllib`/`fetch` against the plain HTTP API — no SDK install —
for anyone self-hosting without either language's client. `triage-tickets.py` shows the
same idea through the `openjev` SDK client instead.
Run either with the server already up:
```bash
npm run dev # http://localhost:8080
OPENJEV_BASE_URL=http://localhost:8080 node examples/rank-ads.mjs
pip install ./sdk/python && python examples/triage-tickets.py
```
The two official-SDK examples need their package installed first and read the SDK's own
variables:
```bash
pip install typesafe-sdk && TYPESAFE_BASE_URL=http://localhost:8080 python examples/official-sdk.py
npm install @typesafe-ai/sdk && TYPESAFE_BASE_URL=http://localhost:8080 node examples/official-sdk.mjs
```
The first two read `OPENJEV_BASE_URL` (default `http://localhost:3000` for the Node example,
`http://localhost:8080` for the Python one — match whichever you started). No API key is
needed: the SDK sends no `Authorization` header unless `OPENJEV_API_KEY` is set, which you
only do when your server issues keys.
[`feedback.txt`](./feedback.txt) is sample input for the no-server command line classifier:
`node scripts/cli.mjs classify bug,feature,praise < examples/feedback.txt` (see the main README).
[`classify-eval.jsonl`](./classify-eval.jsonl) is a synthetic, hand-labeled gold set (65
rows, built for this repo, not scraped) for measuring `openjev classify`'s lexical-engine
accuracy, including rows that deliberately reuse a *different* label's vocabulary
(`shared_vocab: true`). Run `npm run classify-eval` — see the "Lexical-engine accuracy"
section in the main README for the measured before/after numbers.