🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
chore: move anthropic as optional (#1069)
Wendong-Fan2466015576cb
diff --git a/camel/configs/anthropic_config.py b/camel/configs/anthropic_config.pyindex 4bc4063ff..c9470e14c 100644--- a/camel/configs/anthropic_config.py+++ b/camel/configs/anthropic_config.py@@ -15,7 +15,7 @@ from __future__ import annotationsfrom typing import List, Union-from anthropic import NOT_GIVEN, NotGiven+from openai._types import NOT_GIVEN, NotGivenfrom camel.configs.base_config import BaseConfigdiff --git a/camel/models/anthropic_model.py b/camel/models/anthropic_model.pyindex e5056ae10..8f2a51571 100644--- a/camel/models/anthropic_model.py+++ b/camel/models/anthropic_model.py@@ -14,7 +14,7 @@import osfrom typing import Any, Dict, List, Optional, Union-from anthropic import NOT_GIVEN, Anthropic+from openai import NOT_GIVENfrom camel.configs import ANTHROPIC_API_PARAMS, AnthropicConfigfrom camel.messages import OpenAIMessage@@ -54,6 +54,8 @@ class AnthropicModel(BaseModelBackend):url: Optional[str] = None,token_counter: Optional[BaseTokenCounter] = None,) -> None:+ from anthropic import Anthropic+if model_config_dict is None:model_config_dict = AnthropicConfig().as_dict()api_key = api_key or os.environ.get("ANTHROPIC_API_KEY")diff --git a/camel/utils/token_counting.py b/camel/utils/token_counting.pyindex 13db4a052..dfcf0e6d1 100644--- a/camel/utils/token_counting.py+++ b/camel/utils/token_counting.py@@ -20,7 +20,6 @@ from io import BytesIOfrom math import ceilfrom typing import TYPE_CHECKING, List, Optional-from anthropic import Anthropicfrom PIL import Imagefrom camel.types import (@@ -220,6 +219,7 @@ class OpenAITokenCounter(BaseTokenCounter):class AnthropicTokenCounter(BaseTokenCounter):def __init__(self):r"""Constructor for the token counter for Anthropic models."""+ from anthropic import Anthropicself.client = Anthropic()self.tokenizer = self.client.get_tokenizer()