1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! A Rust client for [TypeSafe](https://docs.typesafe.ai/)'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 |
//!
//! ```no_run
//! use serde_json::json;
//! use typesafe::{Choice, Noul, Questions, Score};
//!
//! # #[cfg(feature = "blocking")]
//! # fn main() -> Result<(), typesafe::Error> {
//! 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);
//! }
//! # Ok(())
//! # }
//! # #[cfg(not(feature = "blocking"))]
//! # fn main() {}
//! ```
//!
//! # Features
//!
//! - `async` (default): [`Client`], for a tokio runtime
//! - `blocking`: [`blocking::Client`], for synchronous code
//! - `rustls` (default) or `native-tls`: the TLS backend
pub use ;
pub use Client;
pub use ;
pub use ;
pub use ;
pub use ;
pub use RetryPolicy;