Expand description
The questions a call asks, and the shapes the API accepts them in.
A question is a noul (how true is this?), a choice (which of these?) or a score (how much, on this scale?); a raw question carries a shape this version of the SDK does not model, so a new question type on the server does not need a new release here.
A question set is validated and serialized once, and the bytes are reused for every call that asks it. That is what keeps the per-call cost to splicing one prepared fragment into the body instead of walking a structure that has not changed since the last call.
use typesafe_sdk::question::{Choice, Noul, Questions, Score};
let prepared = Questions::new()
.noul("billing", Noul::new().instructions("Is this about billing?"))
.choice(
"tone",
Choice::new(["calm", "angry"])
.option("calm", "neutral or polite")
.instructions("What is the tone?"),
)
.score("urgency", Score::new(["can wait", "this week", "today"]))
.prepare()?;
assert_eq!(prepared.len(), 3);
assert_eq!(prepared.names().collect::<Vec<_>>(), ["billing", "tone", "urgency"]);Structs§
- Choice
- A question that picks one of a set of named options.
- Noul
- A yes/no question: how true is a statement about the state?
- Prepared
Questions - A validated question set, serialized once.
- Questions
- The questions of one call, keyed by the names their answers come back under.
- RawQuestion
- A question of a type, or with fields, that this version of the SDK does not model.
- Score
- A question that rates the state on an ordered scale.
Enums§
- Question
- Any one question, for code that builds a question set from data.
Traits§
- Question
Set - A question set declared as a type: it knows the questions it asks, and its answers decode into it.