Skip to content

Commit 2466015

Browse files
authored
chore: move anthropic as optional (#1069)
1 parent 523ebae commit 2466015

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

camel/configs/anthropic_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from typing import List, Union
1717

18-
from anthropic import NOT_GIVEN, NotGiven
18+
from openai._types import NOT_GIVEN, NotGiven
1919

2020
from camel.configs.base_config import BaseConfig
2121

camel/models/anthropic_model.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import os
1515
from typing import Any, Dict, List, Optional, Union
1616

17-
from anthropic import NOT_GIVEN, Anthropic
17+
from openai import NOT_GIVEN
1818

1919
from camel.configs import ANTHROPIC_API_PARAMS, AnthropicConfig
2020
from camel.messages import OpenAIMessage
@@ -54,6 +54,8 @@ def __init__(
5454
url: Optional[str] = None,
5555
token_counter: Optional[BaseTokenCounter] = None,
5656
) -> None:
57+
from anthropic import Anthropic
58+
5759
if model_config_dict is None:
5860
model_config_dict = AnthropicConfig().as_dict()
5961
api_key = api_key or os.environ.get("ANTHROPIC_API_KEY")

camel/utils/token_counting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from math import ceil
2121
from typing import TYPE_CHECKING, List, Optional
2222

23-
from anthropic import Anthropic
2423
from PIL import Image
2524

2625
from camel.types import (
@@ -220,6 +219,7 @@ def _count_tokens_from_image(
220219
class AnthropicTokenCounter(BaseTokenCounter):
221220
def __init__(self):
222221
r"""Constructor for the token counter for Anthropic models."""
222+
from anthropic import Anthropic
223223

224224
self.client = Anthropic()
225225
self.tokenizer = self.client.get_tokenizer()

0 commit comments

Comments
 (0)