pub struct Client { /* private fields */ }Expand description
An async client for the SystemOne HTTP API.
Cheap to clone; clones share one connection pool. All methods are safe to call concurrently from many tasks.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(api_key: impl Into<String>) -> Result<Self, Error>
pub fn new(api_key: impl Into<String>) -> Result<Self, Error>
Client::builder().api_key(key).build()? with all other defaults.
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Start building a customized client.
Sourcepub fn default_model(&self) -> &str
pub fn default_model(&self) -> &str
The resolved default model alias.
Sourcepub async fn evaluate(
&self,
request: SystemRequest,
) -> Result<SystemResponse, Error>
pub async fn evaluate( &self, request: SystemRequest, ) -> Result<SystemResponse, Error>
Evaluate a SystemRequest, POSTing it to /v1/systemone.
Retries and rate-limit backoff follow the client’s RetryPolicy;
see evaluate_with for per-call overrides.
Sourcepub async fn evaluate_with(
&self,
request: SystemRequest,
opts: &RequestOptions,
) -> Result<SystemResponse, Error>
pub async fn evaluate_with( &self, request: SystemRequest, opts: &RequestOptions, ) -> Result<SystemResponse, Error>
evaluate with per-call RequestOptions.
Sourcepub async fn system_one<S, I, K>(
&self,
state: S,
questions: I,
) -> Result<SystemResponse, Error>
pub async fn system_one<S, I, K>( &self, state: S, questions: I, ) -> Result<SystemResponse, Error>
Evaluate ad-hoc questions against a state, mirroring the Python SDK’s
client.system_one(...). The client’s default model is used.
§Examples
use openkind_client::{question, Client};
let response = client
.system_one(
"I was charged twice. Please help.",
[
("billing", question::noul("Is this about billing?")),
("tone", question::choice("What is the tone?", [("calm", None), ("angry", None)])),
],
)
.await?;
assert!(response.answers.contains_key("billing"));Sourcepub async fn system_one_with<S, I, K>(
&self,
state: S,
questions: I,
opts: &RequestOptions,
) -> Result<SystemResponse, Error>
pub async fn system_one_with<S, I, K>( &self, state: S, questions: I, opts: &RequestOptions, ) -> Result<SystemResponse, Error>
system_one with per-call RequestOptions.
Sourcepub async fn list_models(&self) -> Result<ModelsResponse, Error>
pub async fn list_models(&self) -> Result<ModelsResponse, Error>
GET /v1/models — list model aliases registered on the server.
Sourcepub async fn list_models_with(
&self,
opts: &RequestOptions,
) -> Result<ModelsResponse, Error>
pub async fn list_models_with( &self, opts: &RequestOptions, ) -> Result<ModelsResponse, Error>
list_models with per-call RequestOptions.
Sourcepub async fn health(&self) -> Result<Health, Error>
pub async fn health(&self) -> Result<Health, Error>
GET /health — liveness probe. Unauthenticated, so it works even
with a wrong API key.
Sourcepub async fn health_with(&self, opts: &RequestOptions) -> Result<Health, Error>
pub async fn health_with(&self, opts: &RequestOptions) -> Result<Health, Error>
health with per-call RequestOptions.