pub struct TypeSafeClient { /* private fields */ }Expand description
An asynchronous client for the TypeSafe AI System One API.
use jev_sdk::{Noul, TypeSafeClient};
let client = TypeSafeClient::new("apikey_...")?;
let response = client
.system_one(
"I was charged twice. Please help.",
[("billing", Noul::new("Is this about billing?"))],
)
.await?;
println!("{:?}", response.noul("billing").unwrap().noul);Implementations§
Source§impl TypeSafeClient
impl TypeSafeClient
Sourcepub fn new(api_key: impl Into<String>) -> Result<Self, Error>
pub fn new(api_key: impl Into<String>) -> Result<Self, Error>
Create a client with the given API key and default settings.
Sourcepub fn from_env() -> Result<Self, Error>
pub fn from_env() -> Result<Self, Error>
Create a client from environment variables.
ENV_API_KEY(TYPESAFE_API_KEY) — required.ENV_DEFAULT_MODEL(TYPESAFE_DEFAULT_MODEL) — optional.ENV_BASE_URL(TYPESAFE_BASE_URL) — optional.
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Start building a client with custom settings.
Sourcepub async fn system_one<S, I, K, Q>(
&self,
state: S,
questions: I,
) -> Result<SystemOneResponse, Error>
pub async fn system_one<S, I, K, Q>( &self, state: S, questions: I, ) -> Result<SystemOneResponse, Error>
Answer named questions about text or structured state.
questions maps question ids (you choose them; answers come back under
the same keys) to Questions. Noul, Choice, and Score all
convert into Question, and the different types can be mixed freely in
one call — every question is evaluated in parallel against the same
state.
Sourcepub async fn system_one_with_model<S, I, K, Q>(
&self,
model: &str,
state: S,
questions: I,
) -> Result<SystemOneResponse, Error>
pub async fn system_one_with_model<S, I, K, Q>( &self, model: &str, state: S, questions: I, ) -> Result<SystemOneResponse, Error>
Like TypeSafeClient::system_one, with a per-call model override.
Sourcepub async fn list_models(&self) -> Result<ListModelsResponse, Error>
pub async fn list_models(&self) -> Result<ListModelsResponse, Error>
List the models available to the account.
Trait Implementations§
Source§impl Clone for TypeSafeClient
impl Clone for TypeSafeClient
Source§fn clone(&self) -> TypeSafeClient
fn clone(&self) -> TypeSafeClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !Freeze for TypeSafeClient
impl !RefUnwindSafe for TypeSafeClient
impl !UnwindSafe for TypeSafeClient
impl Send for TypeSafeClient
impl Sync for TypeSafeClient
impl Unpin for TypeSafeClient
impl UnsafeUnpin for TypeSafeClient
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