Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

chore: move anthropic as optional (#1069)

Wendong-Fan2466015576cb
diff --git a/camel/configs/anthropic_config.py b/camel/configs/anthropic_config.py
index 4bc4063ff..c9470e14c 100644
--- a/camel/configs/anthropic_config.py
+++ b/camel/configs/anthropic_config.py
@@ -15,7 +15,7 @@ from __future__ import annotations
from typing import List, Union
-from anthropic import NOT_GIVEN, NotGiven
+from openai._types import NOT_GIVEN, NotGiven
from camel.configs.base_config import BaseConfig
diff --git a/camel/models/anthropic_model.py b/camel/models/anthropic_model.py
index e5056ae10..8f2a51571 100644
--- a/camel/models/anthropic_model.py
+++ b/camel/models/anthropic_model.py
@@ -14,7 +14,7 @@
import os
from typing import Any, Dict, List, Optional, Union
-from anthropic import NOT_GIVEN, Anthropic
+from openai import NOT_GIVEN
from camel.configs import ANTHROPIC_API_PARAMS, AnthropicConfig
from 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.py
index 13db4a052..dfcf0e6d1 100644
--- a/camel/utils/token_counting.py
+++ b/camel/utils/token_counting.py
@@ -20,7 +20,6 @@ from io import BytesIO
from math import ceil
from typing import TYPE_CHECKING, List, Optional
-from anthropic import Anthropic
from PIL import Image
from 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 Anthropic
self.client = Anthropic()
self.tokenizer = self.client.get_tokenizer()