Expand description
Blocking and asynchronous clients for TypeSafe’s System One API.
Requests contain shared Request::state and one or more typed Questions. The
service evaluates those questions independently and returns an Answer under each
caller-selected question ID.
The default reqwest feature provides the asynchronous ReqwestClient. Enable the
ureq feature for the blocking UreqClient. The rustls-tls feature enables rustls
on each selected backend. With no backend feature, the data types and client traits
remain available without an HTTP implementation.
§Request example
The same request can be passed to either backend:
use std::collections::BTreeMap;
use serde_json::json;
use typesafe_ai::{Question, Request};
let request = Request::new("Help! My payouts have been failing for three days.")
.with_question(
"is_urgent",
Question::noul("Does the customer convey urgency?"),
)
.with_question(
"department",
Question::choice(
"Which team should handle this?",
BTreeMap::from([
("billing".into(), json!("Payments and invoices")),
("technical".into(), json!("Bugs and outages")),
]),
),
)
.with_question(
"frustration",
Question::score(
"How frustrated is the customer?",
vec![json!("Calm"), json!("Frustrated"), json!("Very angry")],
),
);
assert_eq!(request.model, "jev-latest");
assert_eq!(request.questions.len(), 3);Structs§
- Client
Config - Configuration shared by the blocking and asynchronous HTTP clients.
- Evaluation
Failure - A failed attempt and its scheduled retry, if any.
- Noul
Criteria - Criteria defining the positive and negative sides of a Noul question.
- Request
- State and typed questions sent to the System One evaluation endpoint.
- Reqwest
Client - Asynchronous TypeSafe client backed by reqwest.
- Response
- A successful System One response.
- Ureq
Client - Blocking TypeSafe client backed by ureq.
- Usage
- Token counts reported for a request.
Enums§
- Answer
- A typed answer returned by System One.
- Error
- Errors returned while configuring or using a client.
- Evaluation
Event - An observable outcome while evaluating a request.
- Question
- A typed judgment for System One to make against request state.
Traits§
- Async
Client - A backend-neutral asynchronous TypeSafe client.
- Stream
- A stream of values produced asynchronously.
- Sync
Client - A backend-neutral blocking TypeSafe client.
Type Aliases§
- Reqwest
Error - Errors returned by
ReqwestClient. - Ureq
Error - Errors returned by
UreqClient.