From af6f5ecc86409636fd2901a024330c0e1218b572 Mon Sep 17 00:00:00 2001 From: Dan Goodman Date: Tue, 10 Dec 2024 09:13:44 -0800 Subject: [PATCH] customize Anthropic client via kwargs, also bumps default model version (#813) * customize Anthropic client via kwargs * bump default model --- src/pipecat/services/anthropic.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pipecat/services/anthropic.py b/src/pipecat/services/anthropic.py index d3445dbe0..48102eda7 100644 --- a/src/pipecat/services/anthropic.py +++ b/src/pipecat/services/anthropic.py @@ -75,7 +75,12 @@ def assistant(self) -> "AnthropicAssistantContextAggregator": class AnthropicLLMService(LLMService): - """This class implements inference with Anthropic's AI models""" + """ + This class implements inference with Anthropic's AI models. + + Can provide a custom client via the `client` kwarg, allowing you to + use `AsyncAnthropicBedrock` and `AsyncAnthropicVertex` clients + """ class InputParams(BaseModel): enable_prompt_caching_beta: Optional[bool] = False @@ -89,12 +94,15 @@ def __init__( self, *, api_key: str, - model: str = "claude-3-5-sonnet-20240620", + model: str = "claude-3-5-sonnet-20241022", params: InputParams = InputParams(), + client=None, **kwargs, ): super().__init__(**kwargs) - self._client = AsyncAnthropic(api_key=api_key) + self._client = client or AsyncAnthropic( + api_key=api_key + ) # if the client is provided, use it and remove it, otherwise create a new one self.set_model_name(model) self._settings = { "max_tokens": params.max_tokens,