pub struct AnthropicModel { /* private fields */ }Available on crate feature
anthropic only.Expand description
Anthropic Claude model.
Implementations§
Source§impl AnthropicModel
impl AnthropicModel
Sourcepub fn new(
model_name: impl Into<String>,
api_key: impl Into<String>,
) -> AnthropicModel
pub fn new( model_name: impl Into<String>, api_key: impl Into<String>, ) -> AnthropicModel
Create a new Anthropic model.
Sourcepub fn from_env(
model_name: impl Into<String>,
) -> Result<AnthropicModel, ModelError>
pub fn from_env( model_name: impl Into<String>, ) -> Result<AnthropicModel, ModelError>
Create from environment variable ANTHROPIC_API_KEY.
Sourcepub fn with_base_url(self, url: impl Into<String>) -> AnthropicModel
pub fn with_base_url(self, url: impl Into<String>) -> AnthropicModel
Set the base URL.
Sourcepub fn with_client(self, client: Client) -> AnthropicModel
pub fn with_client(self, client: Client) -> AnthropicModel
Set a custom HTTP client.
Sourcepub fn with_timeout(self, timeout: Duration) -> AnthropicModel
pub fn with_timeout(self, timeout: Duration) -> AnthropicModel
Set the default timeout.
Sourcepub fn with_profile(self, profile: ModelProfile) -> AnthropicModel
pub fn with_profile(self, profile: ModelProfile) -> AnthropicModel
Set a custom profile.
Sourcepub fn with_thinking(self, budget: Option<u64>) -> AnthropicModel
pub fn with_thinking(self, budget: Option<u64>) -> AnthropicModel
Enable extended thinking.
Sourcepub fn with_caching(self) -> AnthropicModel
pub fn with_caching(self) -> AnthropicModel
Enable prompt caching.
Sourcepub fn with_api_version(self, version: impl Into<String>) -> AnthropicModel
pub fn with_api_version(self, version: impl Into<String>) -> AnthropicModel
Set the API version.
Sourcepub fn add_response_to_messages(
&self,
messages: &mut Vec<AnthropicMessage>,
response: &ModelResponse,
)
pub fn add_response_to_messages( &self, messages: &mut Vec<AnthropicMessage>, response: &ModelResponse, )
Add an assistant response to messages (for multi-turn).
Trait Implementations§
Source§impl Clone for AnthropicModel
impl Clone for AnthropicModel
Source§fn clone(&self) -> AnthropicModel
fn clone(&self) -> AnthropicModel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AnthropicModel
impl Debug for AnthropicModel
Source§impl Model for AnthropicModel
impl Model for AnthropicModel
Source§fn profile(&self) -> &ModelProfile
fn profile(&self) -> &ModelProfile
Get the model profile (capabilities, schema transforms).
Source§fn request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [ModelRequest],
settings: &'life2 ModelSettings,
params: &'life3 ModelRequestParameters,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
AnthropicModel: 'async_trait,
fn request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [ModelRequest],
settings: &'life2 ModelSettings,
params: &'life3 ModelRequestParameters,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
AnthropicModel: 'async_trait,
Make a request to the model.
Source§fn request_stream<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [ModelRequest],
settings: &'life2 ModelSettings,
params: &'life3 ModelRequestParameters,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<ModelResponseStreamEvent, ModelError>> + Send>>, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
AnthropicModel: 'async_trait,
fn request_stream<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [ModelRequest],
settings: &'life2 ModelSettings,
params: &'life3 ModelRequestParameters,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<ModelResponseStreamEvent, ModelError>> + Send>>, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
AnthropicModel: 'async_trait,
Make a streaming request to the model. Read more
Source§fn identifier(&self) -> String
fn identifier(&self) -> String
Get the full model identifier.
Source§fn count_tokens<'life0, 'life1, 'async_trait>(
&'life0 self,
_messages: &'life1 [ModelRequest],
) -> Pin<Box<dyn Future<Output = Result<u64, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn count_tokens<'life0, 'life1, 'async_trait>(
&'life0 self,
_messages: &'life1 [ModelRequest],
) -> Pin<Box<dyn Future<Output = Result<u64, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Count tokens for messages (if supported). Read more
Source§fn supports(&self, capability: ModelCapability) -> bool
fn supports(&self, capability: ModelCapability) -> bool
Check if the model supports a specific capability.
Auto Trait Implementations§
impl Freeze for AnthropicModel
impl !RefUnwindSafe for AnthropicModel
impl Send for AnthropicModel
impl Sync for AnthropicModel
impl Unpin for AnthropicModel
impl !UnwindSafe for AnthropicModel
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