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
//! # jev-sdk
//!
//! A Rust client for the [TypeSafe AI](https://typesafe.ai) System One API.
//!
//! [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) is a
//! System One model: instead of generating text, it evaluates typed
//! *questions* against a *state* and returns structured decisions with
//! calibrated probabilities and confidence — fast enough to sit inside
//! ordinary code paths.
//!
//! ## Quick start
//!
//! ```no_run
//! use jev_sdk::{Choice, Noul, Question, Score, TypeSafeClient};
//!
//! # async fn example() -> Result<(), jev_sdk::Error> {
//! // Reads TYPESAFE_API_KEY from the environment.
//! let client = TypeSafeClient::from_env()?;
//!
//! let ticket = "Hi, I've been trying to connect my Stripe account for 3 days \
//! and it keeps failing. I'm losing sales. Please help ASAP.";
//!
//! let response = client
//! .system_one(
//! ticket,
//! [
//! (
//! "department",
//! Question::from(Choice::new(
//! "Which team should handle this",
//! [
//! ("billing", Some("Payment or subscription issues")),
//! ("technical", Some("Bugs or integration problems")),
//! ("sales", Some("Pricing or account questions")),
//! ],
//! )),
//! ),
//! (
//! "frustration",
//! Question::from(Score::new(
//! "How frustrated the customer appears",
//! ["Calm, just stating facts", "Frustrated but civil", "Very angry"],
//! )),
//! ),
//! (
//! "is_urgent",
//! Question::from(Noul::new("The message conveys urgency or time-sensitivity")),
//! ),
//! ],
//! )
//! .await?;
//!
//! let department = response.choice("department").unwrap();
//! println!("route to {} (confidence {:.2})", department.choice, department.confidence);
//! println!("frustration: {:.2}", response.score("frustration").unwrap().score);
//! println!("urgent: {:.3}", response.noul("is_urgent").unwrap().noul);
//! # Ok(())
//! # }
//! ```
//!
//! ## Configuration
//!
//! | Setting | Environment variable | Default |
//! |---------|----------------------|---------|
//! | API key | `TYPESAFE_API_KEY` | — (required) |
//! | Model | `TYPESAFE_DEFAULT_MODEL` | `jev-latest` |
//! | Base URL | `TYPESAFE_BASE_URL` | `https://api.typesafe.ai` |
//!
//! Use [`TypeSafeClient::builder`] for timeouts, retry policy, extra headers,
//! or a custom `reqwest` client. See [`RetryPolicy`] for retry behavior
//! (transient `429`/`529` responses are retried with exponential backoff by
//! default).
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use RetryPolicy;