Expand description
A Rust client for TypeSafe’s System One API, the API behind Jev. It is unofficial. Its behaviour follows the official Python SDK: the same environment variables and defaults, the same retry policy, and the same error kinds.
System One models don’t generate text. You send some state and a set of typed questions, and get back one typed answer per question, with probabilities your code acts on:
| Question | Asks | Answer |
|---|---|---|
Noul | whether a condition holds | NoulAnswer: the probability of yes |
Choice | which one of a defined set | ChoiceAnswer: option, probabilities, confidence |
Score | how far along ordered levels | ScoreAnswer: weighted level, probabilities, confidence |
use serde_json::json;
use typesafe::{Choice, Noul, Questions, Score};
let client = typesafe::blocking::Client::new(); // reads TYPESAFE_API_KEY
let questions = Questions::new()
.ask("billing", Noul::new("Is this ticket about billing?"))
.ask("tone", Choice::new("What is the customer's tone?").options(["calm", "frustrated", "angry"]))
.ask("urgency", Score::new("How urgent is this ticket?", ["Can wait", "This week", "Today"]));
let response = client.system_one(
&json!({"ticket": "I was charged twice. Please fix this ASAP."}),
&questions,
)?;
let tone = response.choice("tone").unwrap();
if response.noul("billing").unwrap().yes() && tone.confidence > 0.5 {
println!("billing, {} ({:.2})", tone.choice, tone.confidence);
}§Features
async(default):Client, for a tokio runtimeblocking:blocking::Client, for synchronous coderustls(default) ornative-tls: the TLS backend
Modules§
- blocking
- A blocking client, for synchronous code such as a game loop or a CLI.
Structs§
- Call
Options - Overrides for a single call.
- Choice
- A question that selects one option from a defined set. The answer is a
ChoiceAnswer. - Choice
Answer - The answer to a
Choice. - Client
- An async client for the System One API. It needs a tokio runtime with the
time driver enabled, which
#[tokio::main]provides. - Config
- Connection settings for a client.
- Error
- Why a call failed.
- Model
- A model name the account can send, from
models(). - Noul
- A yes/no question. The answer, a
NoulAnswer, is the probability that the answer is yes. - Noul
Answer - The answer to a
Noul:noulis the probability of yes, from 0 to 1. - Questions
- The questions for one call, each under an id. Answers come back under the same ids.
- Response
- The result of a System One call.
- Retry
Policy - When and how long to wait before retrying. The defaults match TypeSafe’s official SDKs:
- Score
- A question that rates the state against ordered levels, worst or least
first. The answer is a
ScoreAnswer. - Score
Answer - The answer to a
Score. - Usage
- Tokens used by a call. Only input tokens are billed.
Enums§
- Answer
- Any one answer. Its variant matches the question that asked it.
- Error
Kind - What kind of failure an
Erroris. - Question
- Any one question.