pub struct Choice {
pub instructions: Value,
pub criteria: IndexMap<String, Option<String>>,
}Expand description
Pick one option from a defined set.
Fields§
§instructions: ValueWhat the model should decide. A string or arbitrary JSON structure.
criteria: IndexMap<String, Option<String>>Map of option name to an optional rubric description for that option. Insertion order is preserved.
Implementations§
Source§impl Choice
impl Choice
Sourcepub fn new<K, D, I>(instructions: impl IntoContent, criteria: I) -> Self
pub fn new<K, D, I>(instructions: impl IntoContent, criteria: I) -> Self
Create a choice question from option/description pairs.
use jev_sdk::Choice;
let q = Choice::new(
"What is the tone?",
[("calm", None), ("angry", Some("Strong language"))],
);
assert_eq!(q.criteria.len(), 2);Sourcepub fn options<I, S>(instructions: impl IntoContent, options: I) -> Self
pub fn options<I, S>(instructions: impl IntoContent, options: I) -> Self
Create a choice question from bare option names, with no per-option descriptions.
use jev_sdk::Choice;
let q = Choice::options("What is the tone?", ["calm", "angry"]);
assert_eq!(q.criteria.len(), 2);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Choice
impl<'de> Deserialize<'de> for Choice
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 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