pub struct AnthropicProvider { /* private fields */ }Expand description
Client for the Anthropic Messages API (POST {base_url}/v1/messages), or for Claude on
Google Cloud Vertex AI via vertex.
Implementations§
Source§impl AnthropicProvider
impl AnthropicProvider
pub fn new(api_key: impl Into<String>) -> Self
Sourcepub fn vertex(
project: impl Into<String>,
region: impl Into<String>,
access_token: impl Into<String>,
) -> Self
pub fn vertex( project: impl Into<String>, region: impl Into<String>, access_token: impl Into<String>, ) -> Self
Claude on Google Cloud Vertex AI. access_token is an OAuth token
(e.g. gcloud auth print-access-token); region is e.g. global or us-east5.
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 AnthropicProvider
impl Clone for AnthropicProvider
Source§impl Debug for AnthropicProvider
impl Debug for AnthropicProvider
Source§impl LlmProvider for AnthropicProvider
impl LlmProvider for AnthropicProvider
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 AnthropicProvider
impl !UnwindSafe for AnthropicProvider
impl Freeze for AnthropicProvider
impl Send for AnthropicProvider
impl Sync for AnthropicProvider
impl Unpin for AnthropicProvider
impl UnsafeUnpin for AnthropicProvider
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