pub struct Client { /* private fields */ }Expand description
Client for the TypeSafe API.
Cloning is cheap and clones share one connection pool.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
A client configured from the environment.
Reads TYPESAFE_API_KEY (required), TYPESAFE_BASE_URL and
TYPESAFE_DEFAULT_MODEL. Use Client::builder to set values in code
or to authenticate with a CredentialProvider.
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
A builder for a client. Values set in code take precedence over the environment.
Sourcepub fn default_model(&self) -> &str
pub fn default_model(&self) -> &str
Model used when a request does not set one.
Sourcepub fn retry(&self) -> &RetryPolicy
pub fn retry(&self) -> &RetryPolicy
Retry policy for calls that do not override it.
Sourcepub fn total_timeout(&self) -> Option<Duration>
pub fn total_timeout(&self) -> Option<Duration>
Upper bound for a whole call, for calls that do not override it.
Sourcepub fn max_concurrent_requests(&self) -> Option<usize>
pub fn max_concurrent_requests(&self) -> Option<usize>
The concurrency limit shared by this client and its clones, if any.
Sourcepub fn default_headers(&self) -> &HeaderMap
pub fn default_headers(&self) -> &HeaderMap
Headers sent with every request.
Sourcepub fn system_one(&self, request: SystemOneRequest) -> Call<SystemOneResult>
pub fn system_one(&self, request: SystemOneRequest) -> Call<SystemOneResult>
Answer named questions about text or structured state.
Validation errors are returned when the call is awaited, before any request is sent.
use kunobi_jev::{Client, Questions, SystemOneRequest, noul};
let client = Client::new()?;
let mut questions = Questions::new();
let billing = questions.add("billing", noul("Is this about billing?"));
let result = client
.system_one(SystemOneRequest::new("I was charged twice.", questions))
.await?;
println!("{}", result.answer(&billing)?.noul);