#[non_exhaustive]pub struct Choice {
pub instructions: Option<Content>,
pub criteria: IndexMap<String, Content>,
pub extra: IndexMap<String, Value>,
}Expand description
Picks one option from a set the caller defines.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.instructions: Option<Content>What the model should decide.
Marked required by the API reference, although the server accepts a Choice without it.
criteria: IndexMap<String, Content>Each option mapped to its description, or to null when the name says enough.
Options keep the order they were written in. The API allows up to 255 of them. A repeated option is a parse error when reading JSON or YAML text directly.
extra: IndexMap<String, Value>Fields this version of the crate does not know, sent to the API unchanged.
Implementations§
Source§impl Choice
impl Choice
Sourcepub fn new(instructions: impl Into<Content>) -> Self
pub fn new(instructions: impl Into<Content>) -> Self
A Choice with the given instructions and no options yet.
Sourcepub fn option(
self,
name: impl Into<String>,
description: impl Into<Content>,
) -> Self
pub fn option( self, name: impl Into<String>, description: impl Into<Content>, ) -> Self
Adds an option with a description, replacing any option already using that name.
Sourcepub fn bare_option(self, name: impl Into<String>) -> Self
pub fn bare_option(self, name: impl Into<String>) -> Self
Adds an option whose name needs no description (sent as null).
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
Source§impl JsonSchema for Choice
impl JsonSchema for Choice
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreimpl StructuralPartialEq for Choice
Auto Trait Implementations§
impl Forget for Choice
impl Freeze for Choice
impl Move 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