pub struct Choice<'a> { /* private fields */ }Expand description
A question that picks one of a set of named options.
An option without a description is interpreted by its name alone and is
sent as null. Options are sent in the order they were first given; naming
an option again replaces its description but keeps its position, which is
what the upstream SDK’s dictionary does.
use typesafe_sdk::question::Choice;
let tone = Choice::new(["calm", "angry"])
.option("calm", "neutral or polite")
.instructions("What is the tone?");Implementations§
Source§impl<'a> Choice<'a>
impl<'a> Choice<'a>
Sourcepub fn new<I>(options: I) -> Self
pub fn new<I>(options: I) -> Self
A choice between options, none of them described yet.
No option count is enforced here: the API documents its limits as subject to change, so the server is the one to judge them.
Sourcepub fn option(
self,
name: impl Into<Cow<'a, str>>,
description: impl Into<Content<'a>>,
) -> Self
pub fn option( self, name: impl Into<Cow<'a, str>>, description: impl Into<Content<'a>>, ) -> Self
Adds the option name with a description, or describes it if it is
already there.
Sourcepub fn instructions(self, instructions: impl Into<Content<'a>>) -> Self
pub fn instructions(self, instructions: impl Into<Content<'a>>) -> Self
What the model should decide when choosing. Setting it again replaces it.
Trait Implementations§
impl<'a> Eq for Choice<'a>
impl<'a> StructuralPartialEq for Choice<'a>
Auto Trait Implementations§
impl<'a> Freeze for Choice<'a>
impl<'a> RefUnwindSafe for Choice<'a>
impl<'a> Send for Choice<'a>
impl<'a> Sync for Choice<'a>
impl<'a> Unpin for Choice<'a>
impl<'a> UnsafeUnpin for Choice<'a>
impl<'a> UnwindSafe for Choice<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.