pub struct ApiClient { /* private fields */ }Expand description
A client for the Silicon Flow API.
Implementations§
Source§impl ApiClient
impl ApiClient
Sourcepub fn new(api_key: &str) -> Result<Self, InvalidHeaderValue>
pub fn new(api_key: &str) -> Result<Self, InvalidHeaderValue>
Create a new API client.
§Errors
Returns a InvalidHeaderValue if the API key does not make a valid header value.
Sourcepub async fn embed_text(
&self,
input: &[&str],
) -> Result<Vec<Embedding>, EmbedError>
pub async fn embed_text( &self, input: &[&str], ) -> Result<Vec<Embedding>, EmbedError>
Embed text using the Silicon Flow API.
§Errors
Returns an EmbedError if the request fails or the response cannot be parsed.
§Panics
This function should not panic under normal circumstances. If it does, then chunks_exact does not properly return a chunk of 4 bytes.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more