pub struct Client { /* private fields */ }Expand description
TypeSafe API client. Cheap to clone; clones share the connection pool.
use typesafe::{Client, Choice, Noul, Questions, Score};
let client = Client::from_env()?;
let res = client
.system_one(
"I've been trying to connect Stripe for 3 days. Please help ASAP.",
Questions::new()
.with("department", Choice::new("Which team should handle this")
.option("billing", "Payment or subscription issues")
.option("technical", "Bugs or integration problems"))
.with("frustration", Score::new("How frustrated", ["Calm", "Frustrated", "Very angry"]))
.with("is_urgent", Noul::new("The message conveys urgency")),
)
.await?;
println!("{}", res.choice("department").unwrap().choice);Implementations§
Source§impl Client
impl Client
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Start configuring a client.
Sourcepub fn default_model(&self) -> &str
pub fn default_model(&self) -> &str
The default model.
Sourcepub fn system_one<S: Serialize>(
&self,
state: S,
questions: impl Into<Questions>,
) -> SystemOneRequest
pub fn system_one<S: Serialize>( &self, state: S, questions: impl Into<Questions>, ) -> SystemOneRequest
Ask typed questions about state (a string, or anything Serialize that becomes a JSON
object/array). Returns a request builder: .await it directly or set per-call options first.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
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