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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! Rust client for the [TypeSafe AI](https://typesafe.ai) System One API.
//!
//! Send a `state` and a map of typed questions — [`Noul`] (yes/no probability), [`Choice`]
//! (one of N labels) and [`Score`] (ordered levels) — and get typed answers back.
//!
//! Behaviour follows the official Python SDK (`typesafe-sdk`): the same environment variables,
//! defaults, retry semantics, error classification and forward-compatible decoding.
//!
//! Enable the `blocking` feature for a synchronous client in [`blocking`], `reqwest-client`
//! to supply your own `reqwest::Client`, and `derive` for `#[derive(Rubric)]`: a struct that
//! describes the questions and receives the answers (see [`rubric`]).
//!
//! # Example
//!
//! With the `derive` feature, a struct is the rubric: each field is a question, and the answers
//! come back into it, typed.
//!
//! ```no_run
//! # #[cfg(feature = "derive")] {
//! use typesafe::{ChoiceOf, Client, NoulAnswer, Rubric, RubricChoice, ScoreAnswer};
//!
//! #[derive(Rubric)]
//! struct Triage {
//! #[noul("The message conveys urgency")]
//! is_urgent: NoulAnswer,
//! #[choice("Which team should handle this")]
//! department: ChoiceOf<Department>,
//! #[score("How frustrated", levels = ["Calm", "Frustrated but civil", "Very angry"])]
//! frustration: ScoreAnswer,
//! }
//!
//! #[derive(Debug, RubricChoice)]
//! enum Department {
//! /// Payment or subscription issues
//! Billing,
//! /// Bugs or integration problems
//! Technical,
//! }
//!
//! # async fn run() -> typesafe::Result<()> {
//! let client = Client::from_env()?; // TYPESAFE_API_KEY
//! let triage = client
//! .ask::<Triage>("I've been trying to connect Stripe for 3 days. Please help ASAP.")
//! .await?;
//! println!("route to {:?}", *triage.department);
//! println!("urgent: {}", triage.is_urgent.is_yes(0.8));
//! println!("frustration: {:.2}", triage.frustration.score);
//! # Ok(()) }
//! # }
//! ```
//!
//! Without the derive, [`Client::system_one`] takes a [`Questions`] map built at runtime and
//! returns a [`SystemOneResponse`] to look answers up in by name.
pub use ;
pub use ;
/// The HTTP status type of [`Error::status`], [`ApiError::status`], [`ResponseMeta::status`] and
/// [`RetryPolicy::statuses`], with constants such as `StatusCode::TOO_MANY_REQUESTS`.
pub use StatusCode;
pub use ;
pub use ;
pub use RetryPolicy;
pub use ;
/// `#[derive(Rubric)]` and `#[derive(RubricChoice)]` (feature `derive`); see [`rubric`].
pub use ;
/// Re-exported so callers can build headers without adding a dependency.
pub use http;
/// Re-exported so callers can build structured instructions/state without adding a dependency.
pub use ;
/// Compiles the README's code samples as doctests (they are not part of the rendered docs). The
/// quick start uses `#[derive(Rubric)]`, so they are checked with the `derive` feature on.
;