pub struct ApiClient { /* private fields */ }Expand description
A client for the Silicon Flow API.
Implementationsยง
Sourceยงimpl ApiClient
impl ApiClient
Sourcepub fn new(key: &str, model: Model) -> Result<Self, SenseError>
pub fn new(key: &str, model: Model) -> Result<Self, SenseError>
Create a new API client.
ยงErrors
Returns an error if the API key is malformed or the HTTP client cannot be created.
Sourcepub async fn embed(&self, text: &str) -> Result<EmbeddingBytes, SenseError>
pub async fn embed(&self, text: &str) -> Result<EmbeddingBytes, SenseError>
Embed a text.
ยงErrors
Returns:
SenseError::RequestFailedif the request failsSenseError::Base64DecodingFailedif base64 decoding failsSenseError::DimensionMismatchif the embedding is not 1024-dimensional.
Trait Implementationsยง
Auto Trait Implementationsยง
impl Freeze for ApiClient
impl !RefUnwindSafe for ApiClient
impl Send for ApiClient
impl Sync for ApiClient
impl Unpin for ApiClient
impl !UnwindSafe for ApiClient
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