1use serde_json::json;
10use typesafe_rs::{Client, ClientConfig, Question, questions};
11use typesafe_rs_mock::{MockServer, noul};
12
13#[tokio::main]
14async fn main() -> Result<(), Box<dyn std::error::Error>> {
15 let mock = MockServer::start().await;
16 mock.on_system_one().respond(json!({
17 "urgent": noul(0.97),
18 }));
19
20 let client = Client::new(ClientConfig {
21 api_key: Some("test".into()),
22 base_url: Some(mock.url()),
23 default_model: Some("jev-latest".into()),
24 ..ClientConfig::default()
25 })?;
26
27 let response = client
28 .system_one(
29 "Help! My payouts have been failing for 3 days.",
30 questions! {
31 "urgent" => Question::noul("Does this convey urgency?")
32 .when_true("Explicitly time-sensitive")
33 .when_false("No time pressure"),
34 },
35 )
36 .await?;
37
38 println!("urgent noul = {:?}", response.noul("urgent"));
39 println!("request id = {:?}", response.meta.request_id);
40 Ok(())
41}