pub struct Client { /* private fields */ }Expand description
Client for the TypeSafe System One API. Cheap to clone; shares one HTTP pool.
Implementations§
Source§impl Client
impl Client
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Start configuring a client.
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Client configured entirely from TYPESAFE_API_KEY, TYPESAFE_DEFAULT_MODEL and
TYPESAFE_BASE_URL.
§Errors
Same as ClientBuilder::build; in practice a missing TYPESAFE_API_KEY.
Sourcepub fn default_model(&self) -> &str
pub fn default_model(&self) -> &str
The model used when Client::system_one is called.
Sourcepub fn system_one(&self) -> SystemOneRequest<'_>
pub fn system_one(&self) -> SystemOneRequest<'_>
Start building a POST /v1/systemone call: state, questions, then .send().
Sourcepub async fn evaluate<K>(
&self,
state: impl Serialize,
questions: impl IntoIterator<Item = (K, Question)>,
) -> Result<SystemOneResponse>
pub async fn evaluate<K>( &self, state: impl Serialize, questions: impl IntoIterator<Item = (K, Question)>, ) -> Result<SystemOneResponse>
Evaluate state against an existing map of questions with the client’s default
model. The builder form is Client::system_one.
Questions are keyed by the ids you choose; answers come back under the same ids. All questions see the same state and are evaluated independently.
§Errors
Error::RequestSerialization if state cannot be serialised; an HTTP-status
variant (Error::Authentication, Error::UnprocessableEntity, Error::RateLimit,
…) for a non-2xx answer after retries; Error::Connection / Error::Timeout for
transport failures; Error::ResponseValidation if the body is not the documented
shape.
Sourcepub async fn evaluate_with_model<K>(
&self,
model: &str,
state: impl Serialize,
questions: impl IntoIterator<Item = (K, Question)>,
) -> Result<SystemOneResponse>
pub async fn evaluate_with_model<K>( &self, model: &str, state: impl Serialize, questions: impl IntoIterator<Item = (K, Question)>, ) -> Result<SystemOneResponse>
Sourcepub async fn models(&self) -> Result<Vec<ModelInfo>>
pub async fn models(&self) -> Result<Vec<ModelInfo>>
List the model names and aliases this account may send in the model field.
§Errors
An HTTP-status variant for a non-2xx answer after retries, Error::Connection /
Error::Timeout for transport failures, Error::ResponseValidation for an
unexpected body.