pub struct SystemOneRequest<'a> { /* private fields */ }Expand description
A POST /v1/systemone call under construction. Created by Client::system_one.
Set the state once with state (any Serialize, typically your own
struct) or build it field by field with field, add questions, then
send. Errors in the inputs (unserializable value, fields added to a
non-object state, no state, no questions) surface from send, so the chain stays clean.
Implementations§
Source§impl<'a> SystemOneRequest<'a>
impl<'a> SystemOneRequest<'a>
Sourcepub fn model(self, model: impl Into<String>) -> Self
pub fn model(self, model: impl Into<String>) -> Self
Model for this call only. Defaults to the client’s model.
Sourcepub fn state(self, state: impl Serialize) -> Self
pub fn state(self, state: impl Serialize) -> Self
The whole state: a string, or any Serialize value (your own struct, a Vec, a
serde_json::Value). Replaces anything set before.
Sourcepub fn field(self, name: impl Into<String>, value: impl Serialize) -> Self
pub fn field(self, name: impl Into<String>, value: impl Serialize) -> Self
One named field of an object state. Call it once per field; a later
state replaces them all. Fails at send if the state was already
set to something that is not an object.
Sourcepub fn question(self, id: impl Into<String>, question: Question) -> Self
pub fn question(self, id: impl Into<String>, question: Question) -> Self
Any question under id. Answers come back under the same id.
Sourcepub fn noul(self, id: impl Into<String>, instructions: impl Into<Value>) -> Self
pub fn noul(self, id: impl Into<String>, instructions: impl Into<Value>) -> Self
Yes/no question.
Sourcepub fn noul_with_criteria(
self,
id: impl Into<String>,
instructions: impl Into<Value>,
yes: impl Into<String>,
no: impl Into<String>,
) -> Self
pub fn noul_with_criteria( self, id: impl Into<String>, instructions: impl Into<Value>, yes: impl Into<String>, no: impl Into<String>, ) -> Self
Yes/no question with descriptions of what yes and no mean.
Sourcepub fn choice(
self,
id: impl Into<String>,
instructions: impl Into<Value>,
options: impl FnOnce(ChoiceBuilder) -> ChoiceBuilder,
) -> Self
pub fn choice( self, id: impl Into<String>, instructions: impl Into<Value>, options: impl FnOnce(ChoiceBuilder) -> ChoiceBuilder, ) -> Self
Pick one option; build the option set in the closure. Repeating an option name is an
error at send, as is an empty set or more than MAX_CHOICE_OPTIONS options.
Sourcepub fn score<L: Into<String>>(
self,
id: impl Into<String>,
instructions: impl Into<Value>,
levels: impl IntoIterator<Item = L>,
) -> Self
pub fn score<L: Into<String>>( self, id: impl Into<String>, instructions: impl Into<Value>, levels: impl IntoIterator<Item = L>, ) -> Self
Rate along levels, lowest first. Fewer than two levels is an error at send.
Sourcepub async fn send(self) -> Result<SystemOneResponse>
pub async fn send(self) -> Result<SystemOneResponse>
Send the request.
§Errors
Error::InvalidRequest for a request that is not sendable as built: no state, no
questions, a Choice without options or with more than MAX_CHOICE_OPTIONS, a
repeated option name, a Score with fewer than two levels, a duplicate question id,
or a field added to a non-object state. Error::RequestSerialization
if a state/field value failed to serialise. Otherwise as Client::evaluate.