pub struct CohereProvider { /* private fields */ }Expand description
Client for the Cohere Chat API v2 (POST {base_url}/chat).
Requests use the same message, image and tool shapes as OpenAI; responses differ.
Implementations§
Source§impl CohereProvider
impl CohereProvider
pub fn new(api_key: impl Into<String>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Sourcepub fn with_client(self, client: Client) -> Self
pub fn with_client(self, client: Client) -> Self
Uses your own reqwest::Client, for example to share a connection pool or set a proxy.
Sourcepub fn with_max_retries(self, max_retries: u32) -> Self
pub fn with_max_retries(self, max_retries: u32) -> Self
How many times a failed request is retried (default DEFAULT_MAX_RETRIES; 0 disables).
Trait Implementations§
Source§impl Clone for CohereProvider
impl Clone for CohereProvider
Source§impl Debug for CohereProvider
impl Debug for CohereProvider
Source§impl EmbeddingProvider for CohereProvider
impl EmbeddingProvider for CohereProvider
fn embed<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
model: &'life1 str,
inputs: &'life2 [&'life3 str],
) -> Pin<Box<dyn Future<Output = Result<Embeddings>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§impl LlmProvider for CohereProvider
impl LlmProvider for CohereProvider
Source§fn chat<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn chat<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sends the request and waits for the whole answer.
Source§fn chat_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn chat_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Streams the answer as it is generated. The last event is
StreamEvent::Done
with the full response. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for CohereProvider
impl !UnwindSafe for CohereProvider
impl Freeze for CohereProvider
impl Send for CohereProvider
impl Sync for CohereProvider
impl Unpin for CohereProvider
impl UnsafeUnpin for CohereProvider
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