pub struct Choice { /* private fields */ }Expand description
A question that selects one option from a defined set. The answer is a
ChoiceAnswer.
Options are sent in the order they were added, because the order is part of what the model reads. Include a no-match option when nothing may fit: the model always picks one of the options given.
use typesafe::Choice;
let team = Choice::new("Which team should own this ticket?")
.option("billing", "Charges, invoices, refunds")
.option("technical", "Bugs, outages, integrations")
.option("unclear", "The ticket does not say enough to tell");
let tone = Choice::new("What is the customer's tone?").options(["calm", "frustrated", "angry"]);Implementations§
Source§impl Choice
impl Choice
Sourcepub fn new(instructions: impl Into<Value>) -> Self
pub fn new(instructions: impl Into<Value>) -> Self
instructions is a string, or a JSON object or array when structure
makes the question clearer.
Sourcepub fn option(
self,
name: impl Into<String>,
description: impl Into<Value>,
) -> Self
pub fn option( self, name: impl Into<String>, description: impl Into<Value>, ) -> Self
Adds an option with a description of when it applies.
Sourcepub fn option_names(&self) -> impl Iterator<Item = &str>
pub fn option_names(&self) -> impl Iterator<Item = &str>
The option names, in the order they are sent.
Trait Implementations§
impl StructuralPartialEq for Choice
Auto Trait Implementations§
impl Freeze for Choice
impl RefUnwindSafe for Choice
impl Send for Choice
impl Sync for Choice
impl Unpin for Choice
impl UnsafeUnpin for Choice
impl UnwindSafe for Choice
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