diff --git a/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/anthropic.py b/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/anthropic.py index e36563f69..8cfee8243 100644 --- a/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/anthropic.py +++ b/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/anthropic.py @@ -1,39 +1,8 @@ -from langchain_anthropic import AnthropicLLM, ChatAnthropic +from langchain_anthropic import ChatAnthropic from ..providers import BaseProvider, EnvAuthStrategy -class AnthropicProvider(BaseProvider, AnthropicLLM): - id = "anthropic" - name = "Anthropic" - models = [ - "claude-v1", - "claude-v1.0", - "claude-v1.2", - "claude-instant-v1", - "claude-instant-v1.0", - "claude-instant-v1.2", - ] - model_id_key = "model" - pypi_package_deps = ["anthropic"] - auth_strategy = EnvAuthStrategy(name="ANTHROPIC_API_KEY") - - @property - def allows_concurrency(self): - return False - - @classmethod - def is_api_key_exc(cls, e: Exception): - """ - Determine if the exception is an Anthropic API key error. - """ - import anthropic - - if isinstance(e, anthropic.AuthenticationError): - return e.status_code == 401 and "Invalid API Key" in str(e) - return False - - class ChatAnthropicProvider( BaseProvider, ChatAnthropic ): # https://docs.anthropic.com/en/docs/about-claude/models @@ -45,6 +14,7 @@ class ChatAnthropicProvider( "claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-3-haiku-20240307", + "claude-3-5-haiku-20241022", "claude-3-5-sonnet-20240620", "claude-3-5-sonnet-20241022", ] @@ -55,3 +25,14 @@ class ChatAnthropicProvider( @property def allows_concurrency(self): return False + + @classmethod + def is_api_key_exc(cls, e: Exception): + """ + Determine if the exception is an Anthropic API key error. + """ + import anthropic + + if isinstance(e, anthropic.AuthenticationError): + return e.status_code == 401 and "Invalid API Key" in str(e) + return False diff --git a/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/aws.py b/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/aws.py index e669c9d8e..4baff07a6 100644 --- a/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/aws.py +++ b/packages/jupyter-ai-magics/jupyter_ai_magics/partner_providers/aws.py @@ -68,6 +68,7 @@ class BedrockChatProvider(BaseProvider, ChatBedrock): "anthropic.claude-3-sonnet-20240229-v1:0", "anthropic.claude-3-haiku-20240307-v1:0", "anthropic.claude-3-opus-20240229-v1:0", + "anthropic.claude-3-5-haiku-20241022-v1:0", "anthropic.claude-3-5-sonnet-20240620-v1:0", "anthropic.claude-3-5-sonnet-20241022-v2:0", "meta.llama2-13b-chat-v1", diff --git a/packages/jupyter-ai-magics/pyproject.toml b/packages/jupyter-ai-magics/pyproject.toml index 91ef5699f..40c7b234d 100644 --- a/packages/jupyter-ai-magics/pyproject.toml +++ b/packages/jupyter-ai-magics/pyproject.toml @@ -57,7 +57,6 @@ all = [ [project.entry-points."jupyter_ai.model_providers"] ai21 = "jupyter_ai_magics:AI21Provider" -anthropic = "jupyter_ai_magics.partner_providers.anthropic:AnthropicProvider" anthropic-chat = "jupyter_ai_magics.partner_providers.anthropic:ChatAnthropicProvider" cohere = "jupyter_ai_magics.partner_providers.cohere:CohereProvider" gpt4all = "jupyter_ai_magics:GPT4AllProvider"