pub struct SystemOneResponse {
pub model: String,
pub answers: IndexMap<String, Answer>,
pub usage: Option<Usage>,
pub meta: ResponseMeta,
}Expand description
Parsed POST /v1/systemone response.
Look up typed answers with noul, choice,
and score. Unknown type values are Answer::Unknown.
Fields§
§model: StringModel that produced the answers.
answers: IndexMap<String, Answer>Answers keyed as in the request.
usage: Option<Usage>Token usage, when present.
meta: ResponseMetaHTTP metadata filled in by the client after deserialize.
Implementations§
Source§impl SystemOneResponse
impl SystemOneResponse
Sourcepub fn choices(&self) -> impl Iterator<Item = (&str, ChoiceView<'_>)> + '_
pub fn choices(&self) -> impl Iterator<Item = (&str, ChoiceView<'_>)> + '_
Iterate Choice answers.
Sourcepub fn scores(&self) -> impl Iterator<Item = (&str, ScoreView<'_>)> + '_
pub fn scores(&self) -> impl Iterator<Item = (&str, ScoreView<'_>)> + '_
Iterate Score answers.
Sourcepub fn noul(&self, key: &str) -> Option<f64>
pub fn noul(&self, key: &str) -> Option<f64>
Noul probability for key, if that answer is a Noul.
Examples found in repository?
examples/blocking.rs (line 29)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12 let rt = tokio::runtime::Builder::new_multi_thread()
13 .enable_all()
14 .build()?;
15 let mock = rt.block_on(MockServer::start());
16 mock.on_system_one().respond(json!({
17 "urgent": noul(0.91),
18 }));
19
20 let client = ClientConfig::new()
21 .api_key("test")
22 .base_url(mock.url())
23 .build_blocking()?;
24
25 let response = client.system_one(
26 "Help! My payouts have been failing for 3 days.",
27 questions! { "urgent" => Question::noul("Does this convey urgency?") },
28 )?;
29 println!("urgent noul = {:?}", response.noul("urgent"));
30
31 drop(client);
32 drop(mock);
33 drop(rt);
34 Ok(())
35}More examples
examples/quickstart.rs (line 38)
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}examples/triage.rs (line 44)
12async fn main() -> Result<(), Box<dyn std::error::Error>> {
13 let mock = MockServer::start().await;
14 mock.on_system_one().respond(json!({
15 "urgent": noul(0.97),
16 "team": choice("technical", 0.82),
17 "frustration": score(1.6, 0.78),
18 }));
19
20 let client = ClientConfig::new()
21 .api_key("test")
22 .base_url(mock.url())
23 .build()?;
24
25 let response = client
26 .system_one(
27 "Help! My payouts have been failing for 3 days.",
28 questions! {
29 "urgent" => Question::noul("Does this convey urgency?")
30 .when_true("Explicitly time-sensitive")
31 .when_false("No time pressure"),
32 "team" => Question::choice("Which team should handle this?")
33 .option("billing", "Payments, invoicing, refunds")
34 .option("technical", "Bugs, outages, integrations")
35 .option("sales", "Pricing, upgrades, new accounts"),
36 "frustration" => Question::score("How frustrated is the customer?")
37 .level("Calm")
38 .level("Frustrated")
39 .level("Very angry"),
40 },
41 )
42 .await?;
43
44 println!("urgent = {:?}", response.noul("urgent"));
45 println!(
46 "team = {:?}",
47 response.choice("team").map(|c| c.choice)
48 );
49 println!(
50 "frustration = {:?}",
51 response.score("frustration").map(|s| s.score)
52 );
53 Ok(())
54}Sourcepub fn choice(&self, key: &str) -> Option<ChoiceView<'_>>
pub fn choice(&self, key: &str) -> Option<ChoiceView<'_>>
Choice view for key, if that answer is a Choice.
Examples found in repository?
examples/triage.rs (line 47)
12async fn main() -> Result<(), Box<dyn std::error::Error>> {
13 let mock = MockServer::start().await;
14 mock.on_system_one().respond(json!({
15 "urgent": noul(0.97),
16 "team": choice("technical", 0.82),
17 "frustration": score(1.6, 0.78),
18 }));
19
20 let client = ClientConfig::new()
21 .api_key("test")
22 .base_url(mock.url())
23 .build()?;
24
25 let response = client
26 .system_one(
27 "Help! My payouts have been failing for 3 days.",
28 questions! {
29 "urgent" => Question::noul("Does this convey urgency?")
30 .when_true("Explicitly time-sensitive")
31 .when_false("No time pressure"),
32 "team" => Question::choice("Which team should handle this?")
33 .option("billing", "Payments, invoicing, refunds")
34 .option("technical", "Bugs, outages, integrations")
35 .option("sales", "Pricing, upgrades, new accounts"),
36 "frustration" => Question::score("How frustrated is the customer?")
37 .level("Calm")
38 .level("Frustrated")
39 .level("Very angry"),
40 },
41 )
42 .await?;
43
44 println!("urgent = {:?}", response.noul("urgent"));
45 println!(
46 "team = {:?}",
47 response.choice("team").map(|c| c.choice)
48 );
49 println!(
50 "frustration = {:?}",
51 response.score("frustration").map(|s| s.score)
52 );
53 Ok(())
54}Sourcepub fn score(&self, key: &str) -> Option<ScoreView<'_>>
pub fn score(&self, key: &str) -> Option<ScoreView<'_>>
Score view for key, if that answer is a Score.
Examples found in repository?
examples/triage.rs (line 51)
12async fn main() -> Result<(), Box<dyn std::error::Error>> {
13 let mock = MockServer::start().await;
14 mock.on_system_one().respond(json!({
15 "urgent": noul(0.97),
16 "team": choice("technical", 0.82),
17 "frustration": score(1.6, 0.78),
18 }));
19
20 let client = ClientConfig::new()
21 .api_key("test")
22 .base_url(mock.url())
23 .build()?;
24
25 let response = client
26 .system_one(
27 "Help! My payouts have been failing for 3 days.",
28 questions! {
29 "urgent" => Question::noul("Does this convey urgency?")
30 .when_true("Explicitly time-sensitive")
31 .when_false("No time pressure"),
32 "team" => Question::choice("Which team should handle this?")
33 .option("billing", "Payments, invoicing, refunds")
34 .option("technical", "Bugs, outages, integrations")
35 .option("sales", "Pricing, upgrades, new accounts"),
36 "frustration" => Question::score("How frustrated is the customer?")
37 .level("Calm")
38 .level("Frustrated")
39 .level("Very angry"),
40 },
41 )
42 .await?;
43
44 println!("urgent = {:?}", response.noul("urgent"));
45 println!(
46 "team = {:?}",
47 response.choice("team").map(|c| c.choice)
48 );
49 println!(
50 "frustration = {:?}",
51 response.score("frustration").map(|s| s.score)
52 );
53 Ok(())
54}Trait Implementations§
Source§impl Clone for SystemOneResponse
impl Clone for SystemOneResponse
Source§fn clone(&self) -> SystemOneResponse
fn clone(&self) -> SystemOneResponse
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SystemOneResponse
impl Debug for SystemOneResponse
Source§impl<'de> Deserialize<'de> for SystemOneResponse
impl<'de> Deserialize<'de> for SystemOneResponse
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SystemOneResponse
impl RefUnwindSafe for SystemOneResponse
impl Send for SystemOneResponse
impl Sync for SystemOneResponse
impl Unpin for SystemOneResponse
impl UnsafeUnpin for SystemOneResponse
impl UnwindSafe for SystemOneResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more