pub struct Client { /* private fields */ }Expand description
A client bound to a localbrain endpoint.
Implementations§
Source§impl Client
impl Client
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Start configuring a client.
Sourcepub async fn chat_with(
&self,
prompt: &str,
opts: &ChatOptions,
) -> Result<String>
pub async fn chat_with( &self, prompt: &str, opts: &ChatOptions, ) -> Result<String>
Chat completion with options.
Sourcepub async fn classify(&self, text: &str, labels: &[&str]) -> Result<String>
pub async fn classify(&self, text: &str, labels: &[&str]) -> Result<String>
Classify text into exactly one of labels (grammar-constrained).
Sourcepub async fn extract<T: DeserializeOwned>(
&self,
text: &str,
schema: Value,
) -> Result<T>
pub async fn extract<T: DeserializeOwned>( &self, text: &str, schema: Value, ) -> Result<T>
Extract structured data as T, constrained to schema (a JSON Schema).
#[derive(Deserialize)]
struct Invoice { vendor: String, total: f64 }
let schema = json!({
"type": "object",
"properties": { "vendor": {"type":"string"}, "total": {"type":"number"} },
"required": ["vendor", "total"]
});
let invoice: Invoice = ai.extract("Invoice from Acme for $42", schema).await?;Sourcepub async fn summarize_with(
&self,
text: &str,
opts: &ChatOptions,
) -> Result<String>
pub async fn summarize_with( &self, text: &str, opts: &ChatOptions, ) -> Result<String>
Summarize with options.
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