Skip to main content

Crate jev

Crate jev 

Source
Expand description

A client for TypeSafe’s Jev, a System One model, on OpenRouter’s decisions endpoint. Jev reads a state (a string, a JSON object or an array) and answers typed questions about it: a Choice between options, a Score along levels, or a Noul, the probability that something is true.

use jev::{Client, Question};

let client = Client::new(&std::env::var("OPENROUTER_API_KEY").unwrap_or_default());
let reply = client
    .decide(
        "Help! My payouts have been failing for 3 days.",
        [
            ("is_urgent", Question::noul("Does this message convey urgency?")),
            ("department", Question::choice("Which team should handle this?", [("billing", "Payments"), ("technical", "Bugs")])),
            ("frustration", Question::score("How frustrated is the customer?", ["Calm", "Frustrated", "Very angry"])),
        ],
    )
    .await?;
if reply.noul("is_urgent")? > 0.8 && reply.choice("department")?.confidence > 0.6 {
    println!("page {}", reply.choice("department")?.choice);
}

Works natively and on wasm32, where requests go through the host’s fetch.

Modules§

print
A reply in the format asked for: text or a table for a person, with the questions in the order they were asked and then what the call used, or JSON for scripts.
rules
Fuzzy rules over a reply: what -r rules.toml reads. Jev’s answers are degrees from 0 to 1 — a Noul’s probability of yes, each Score level’s and each Choice option’s probability — and the rules combine them with AND, OR, NOT and hedges into a score per outcome, which counts as a yes at or over a threshold.
skill
The Agent Skills this crate ships, compiled in: what jev add skill writes into a project, and what dx writes into one when it turns jev on.
spec
Questions written on the command line: ID=INSTRUCTIONS, then |-separated criteria.

Structs§

ChoiceAnswer
Client
Sends decision requests. Debug isn’t derived, to keep the key out of logs.
DecisionRequest
One request: a state, and questions about it under ids of the caller’s choosing. Every question sees the same state and is answered independently of the others.
DecisionResponse
The reply: one answer per question, under the ids from the request.
NoulAnswer
NoulCriteria
What a Noul’s yes and no mean.
Options
A Choice’s options, sent as a JSON object in the order they were given.
ScoreAnswer
Usage

Enums§

Answer
One question’s answer.
Error
Errors are kept as owned data so they stay Send + Sync on wasm32, where the underlying fetch errors are not.
Question
A question. The id it is sent under is never shown to the model, so instructions should say everything. It reads from JSON too, in the endpoint’s own shape.

Constants§

DECISIONS_URL
OpenRouter’s decisions endpoint.
DEFAULT_MODEL
The model requests go to unless the client says otherwise.

Type Aliases§

Result