Expand description
Async Rust client for the TypeSafe System One API.
System One models (Jev) evaluate a state against typed questions and return
calibrated probabilities instead of generated text. Three primitives exist:
Question::noul— a yes/no judgment, answered with the probability of “yes”.Question::choice— pick one option from a set, answered with a full distribution.Question::score— a position on an ordered rubric, answered with a weighted score.
use typesafe_systemone::Client;
let client = Client::from_env()?; // reads TYPESAFE_API_KEY
let response = client
.system_one()
.field("message", "Help! My payouts have been failing for 3 days.")
.noul("is_urgent", "Does `message` convey urgency?")
.choice("department", "Which team should handle `message`?", |c| {
c.option("billing", "Payments, invoicing, refunds")
.option("technical", "Bugs, outages, integrations")
.none_of_the_above("No listed team fits")
})
.score("frustration", "How frustrated is the customer?", ["Calm", "Frustrated", "Very angry"])
.send()
.await?;
let urgent = response.noul("is_urgent")?;
let team = response.choice("department")?;
println!("urgent={urgent:.2} team={} confidence={:.2}", team.choice, team.confidence);state is whatever your questions refer to: pass your own Serialize struct with
SystemOneRequest::state, or assemble an object with SystemOneRequest::field.
Callers that already hold a question map use Client::evaluate directly.
This is an unofficial client. The API contract it follows is documented at https://docs.typesafe.ai/api.
Structs§
- Choice
Answer - Answer to a
Question::Choice. - Choice
Builder - Option set of a Choice, built inside
SystemOneRequest::choice. - Client
- Client for the TypeSafe System One API. Cheap to clone; shares one HTTP pool.
- Client
Builder - Builder for
Client. Explicit values win over environment variables. - Model
Info - One entry from
GET /v1/models. - Noul
Answer - Answer to a
Question::Noul. - Noul
Criteria - Optional descriptions of what a “yes” and a “no” mean for a
Question::Noul. - Retry
Policy - Retry behaviour for transient failures.
- Score
Answer - Answer to a
Question::Score. - System
OneRequest - A
POST /v1/systemonecall under construction. Created byClient::system_one. - System
OneResponse - Response from
POST /v1/systemone. - Usage
- Token usage for one request. Output tokens are not billed.
Enums§
- Answer
- One answer, tagged with the type of the question that produced it.
- Error
- Errors returned by
Client. - Question
- A typed question evaluated against the request
state.
Constants§
- DEFAULT_
BASE_ URL - Production API root.
- DEFAULT_
MODEL - Model used when none is configured: the latest stable Jev release.
- NONE_
OF_ THE_ ABOVE - Conventional name of the abstain option in a Choice. The model always picks some option, so give it one that means “nothing here fits”.
Type Aliases§
- Result
- Result alias for this crate.