🐫 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: Update some versions (#1311)
CaelumFd40f5a04bca4
diff --git a/camel/models/anthropic_model.py b/camel/models/anthropic_model.pyindex 8fd7e565e..42ad19d53 100644--- a/camel/models/anthropic_model.py+++ b/camel/models/anthropic_model.py@@ -12,7 +12,9 @@# limitations under the License.# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========import os-from typing import Any, Dict, List, Optional, Union+from typing import Any, Dict, List, Literal, Optional, Union++from anthropic.types.beta import BetaMessageParamfrom camel.configs import ANTHROPIC_API_PARAMS, AnthropicConfigfrom camel.messages import OpenAIMessage@@ -94,19 +96,26 @@ class AnthropicModel(BaseModelBackend):tokenization style."""if not self._token_counter:- self._token_counter = AnthropicTokenCounter()+ self._token_counter = AnthropicTokenCounter(self.model_type)return self._token_counter- def count_tokens_from_prompt(self, prompt: str) -> int:+ def count_tokens_from_prompt(+ self, prompt: str, role: Literal["user", "assistant"]+ ) -> int:r"""Count the number of tokens from a prompt.Args:prompt (str): The prompt string.+ role (Literal["user", "assistant"]): The role of the message+ sender, either "user" or "assistant".Returns:int: The number of tokens in the prompt."""- return self.client.count_tokens(prompt)+ return self.client.beta.messages.count_tokens(+ messages=[BetaMessageParam(content=prompt, role=role)],+ model=self.model_type,+ ).input_tokens@api_keys_required("ANTHROPIC_API_KEY")def run(diff --git a/camel/models/vllm_model.py b/camel/models/vllm_model.pyindex f4abc60a7..b25dc8766 100644--- a/camel/models/vllm_model.py+++ b/camel/models/vllm_model.py@@ -74,7 +74,7 @@ class VLLMModel(BaseModelBackend):self._client = OpenAI(timeout=60,max_retries=3,- api_key="Set-but-ignored", # required but ignored+ api_key="EMPTY", # required but ignoredbase_url=self._url,)diff --git a/camel/types/enums.py b/camel/types/enums.pyindex 353bc7aac..1bfc534c1 100644--- a/camel/types/enums.py+++ b/camel/types/enums.py@@ -62,10 +62,11 @@ class ModelType(UnifiedModelType, Enum):CLAUDE_INSTANT_1_2 = "claude-instant-1.2"# Claude3 models- CLAUDE_3_OPUS = "claude-3-opus-20240229"+ CLAUDE_3_OPUS = "claude-3-opus-latest"CLAUDE_3_SONNET = "claude-3-sonnet-20240229"CLAUDE_3_HAIKU = "claude-3-haiku-20240307"- CLAUDE_3_5_SONNET = "claude-3-5-sonnet-20240620"+ CLAUDE_3_5_SONNET = "claude-3-5-sonnet-latest"+ CLAUDE_3_5_HAIKU = "claude-3-5-haiku-latest"# Nvidia modelsNVIDIA_NEMOTRON_340B_INSTRUCT = "nvidia/nemotron-4-340b-instruct"@@ -206,6 +207,7 @@ class ModelType(UnifiedModelType, Enum):ModelType.CLAUDE_3_SONNET,ModelType.CLAUDE_3_HAIKU,ModelType.CLAUDE_3_5_SONNET,+ ModelType.CLAUDE_3_5_HAIKU,}@property@@ -455,6 +457,7 @@ class ModelType(UnifiedModelType, Enum):ModelType.CLAUDE_3_SONNET,ModelType.CLAUDE_3_HAIKU,ModelType.CLAUDE_3_5_SONNET,+ ModelType.CLAUDE_3_5_HAIKU,ModelType.YI_MEDIUM_200K,}:return 200_000diff --git a/camel/utils/token_counting.py b/camel/utils/token_counting.pyindex 8cdfae062..85513d4d4 100644--- a/camel/utils/token_counting.py+++ b/camel/utils/token_counting.py@@ -20,6 +20,7 @@ from io import BytesIOfrom math import ceilfrom typing import TYPE_CHECKING, List, Optional+from anthropic.types.beta import BetaMessageParamfrom PIL import Imagefrom camel.logger import get_logger@@ -222,12 +223,16 @@ class OpenAITokenCounter(BaseTokenCounter):class AnthropicTokenCounter(BaseTokenCounter):@dependencies_required('anthropic')- def __init__(self):- r"""Constructor for the token counter for Anthropic models."""+ def __init__(self, model: str):+ r"""Constructor for the token counter for Anthropic models.++ Args:+ model (str): The name of the Anthropic model being used.+ """from anthropic import Anthropicself.client = Anthropic()- self.tokenizer = self.client.get_tokenizer()+ self.model = modeldef count_tokens_from_messages(self, messages: List[OpenAIMessage]) -> int:r"""Count number of tokens in the provided message list using@@ -240,11 +245,16 @@ class AnthropicTokenCounter(BaseTokenCounter):Returns:int: Number of tokens in the messages."""- num_tokens = 0- for message in messages:- content = str(message["content"])- num_tokens += self.client.count_tokens(content)- return num_tokens+ return self.client.beta.messages.count_tokens(+ messages=[+ BetaMessageParam(+ content=str(msg["content"]),+ role="user" if msg["role"] == "user" else "assistant",+ )+ for msg in messages+ ],+ model=self.model,+ ).input_tokensclass GeminiTokenCounter(BaseTokenCounter):@@ -360,7 +370,7 @@ class MistralTokenCounter(BaseTokenCounter):ModelType.MISTRAL_CODESTRAL,ModelType.MISTRAL_CODESTRAL_MAMBA,}- else self.model_type.value+ else self.model_type)self.tokenizer = MistralTokenizer.from_model(model_name)@@ -403,7 +413,7 @@ class MistralTokenCounter(BaseTokenCounter):)mistral_request = ChatCompletionRequest( # type: ignore[type-var]- model=self.model_type.value,+ model=self.model_type,messages=[openai_msg],)diff --git a/docs/key_modules/models.md b/docs/key_modules/models.mdindex 210ae6c8c..dd4a82455 100644--- a/docs/key_modules/models.md+++ b/docs/key_modules/models.md@@ -34,10 +34,11 @@ The following table lists currently supported model platforms by CAMEL.| Mistral AI | open-mixtral-8x7b | N || Mistral AI | open-mixtral-8x22b | N || Mistral AI | open-codestral-mamba | N |-| Anthropic | claude-3-5-sonnet-20240620 | Y |+| Anthropic | claude-3-5-sonnet-latest | Y |+| Anthropic | claude-3-5-haiku-latest | N || Anthropic | claude-3-haiku-20240307 | Y || Anthropic | claude-3-sonnet-20240229 | Y |-| Anthropic | claude-3-opus-20240229 | Y |+| Anthropic | claude-3-opus-latest | Y || Anthropic | claude-2.0 | N || Gemini | gemini-1.5-pro | Y || Gemini | gemini-1.5-flash | Y |diff --git a/examples/models/vllm_model_example.py b/examples/models/vllm_model_example.pyindex 92c9d140b..f5eb795bd 100644--- a/examples/models/vllm_model_example.py+++ b/examples/models/vllm_model_example.py@@ -20,7 +20,6 @@ vllm_model = ModelFactory.create(model_platform=ModelPlatformType.VLLM,model_type="microsoft/Phi-3-mini-4k-instruct",model_config_dict={"temperature": 0.0},- api_key="vllm",)assistant_sys_msg = "You are a helpful assistant."diff --git a/poetry.lock b/poetry.lockindex b9f1fe7fa..1c0c647e9 100644--- a/poetry.lock+++ b/poetry.lock@@ -253,13 +253,13 @@ files = [[[package]]name = "anthropic"-version = "0.29.2"+version = "0.40.0"description = "The official Python library for the anthropic API"optional = true-python-versions = ">=3.7"+python-versions = ">=3.8"files = [- {file = "anthropic-0.29.2-py3-none-any.whl", hash = "sha256:b49804cfe614859a38fe947797cdc59e1ebdf25cc7dfe6c5d9ae0301b9637217"},- {file = "anthropic-0.29.2.tar.gz", hash = "sha256:466494014471b13ab4004152145ac5b796519b02771a1881ddb6a842f1917110"},+ {file = "anthropic-0.40.0-py3-none-any.whl", hash = "sha256:442028ae8790ff9e3b6f8912043918755af1230d193904ae2ef78cc22995280c"},+ {file = "anthropic-0.40.0.tar.gz", hash = "sha256:3efeca6d9e97813f93ed34322c6c7ea2279bf0824cd0aa71b59ce222665e2b87"},][package.dependencies]@@ -269,7 +269,6 @@ httpx = ">=0.23.0,<1"jiter = ">=0.4.0,<1"pydantic = ">=1.9.0,<3"sniffio = "*"-tokenizers = ">=0.13.0"typing-extensions = ">=4.7,<5"[package.extras]@@ -2266,13 +2265,13 @@ tracing = ["opentelemetry-api (>=1.1.0)"][[package]]name = "google-cloud-vision"-version = "3.8.1"+version = "3.9.0"description = "Google Cloud Vision API client library"optional = truepython-versions = ">=3.7"files = [- {file = "google_cloud_vision-3.8.1-py2.py3-none-any.whl", hash = "sha256:e8c0c39747ead61b745bee949c4ba924865e8fac31c5d60c31cbbf2632ceda7e"},- {file = "google_cloud_vision-3.8.1.tar.gz", hash = "sha256:75c7f9c22199ba663cea7d6c1193d5a72ac1e5e2215346a852af133ce69c4f5f"},+ {file = "google_cloud_vision-3.9.0-py2.py3-none-any.whl", hash = "sha256:9acec27ee05bd197f0d89c97e9719712ef245e0c37fd428e6af09a15a082fbef"},+ {file = "google_cloud_vision-3.9.0.tar.gz", hash = "sha256:21226aac9cb4ba45bf89cc2e107aea19e4f78f9736eb1de56837e0c2989fecff"},][package.dependencies]@@ -9987,4 +9986,4 @@ vector-databases = ["pymilvus", "qdrant-client"][metadata]lock-version = "2.0"python-versions = ">=3.10,<3.13"-content-hash = "00f9266244b3166cee0bbf28c5da7ba2c64055819ed2ee2c45a63eeecf6eec37"+content-hash = "2cf66e6e1ed00de5c67edda2170205071f7828e8145c3e25389d99057fa1a94e"diff --git a/pyproject.toml b/pyproject.tomlindex b84a17595..78b68704a 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -27,6 +27,7 @@ repository = "https://github.com/camel-ai/camel"documentation = "https://docs.camel-ai.org"[tool.poetry.dependencies]+httpx = ">=0.23.0,<0.27.3"python = ">=3.10,<3.13"numpy = "^1"openai = "^1.45.0"@@ -47,7 +48,7 @@ litellm = { version = "^1.38.1", optional = true }google-generativeai = { version = "^0.6.0", optional = true }mistralai = { version = "^1.1.0", optional = true }reka-api = { version = "^3.0.8", optional = true }-anthropic = { version = "^0.29.0", optional = true }+anthropic = { version = "^0.40.0", optional = true }cohere = { version = "^5.11.0", optional = true }sglang = { version = "^0.4.0", optional = true }@@ -93,7 +94,7 @@ azure-storage-blob = { version = "^12.21.0", optional = true }google-cloud-storage = { version = "^2.18.0", optional = true }botocore = { version = "^1.35.3", optional = true }nltk = { version = "3.8.1", optional = true }-asknews = { version = "^0.7.43", optional = true }+asknews = { version = "^0.7.54", optional = true }praw = { version = "^7.7.1", optional = true }textblob = { version = "^0.18.0.post0", optional = true }datacommons = { version = "^1.4.3", optional = true }diff --git a/test/models/test_anthropic_model.py b/test/models/test_anthropic_model.pyindex e0068d34a..9f5ce0a73 100644--- a/test/models/test_anthropic_model.py+++ b/test/models/test_anthropic_model.py@@ -32,6 +32,7 @@ from camel.utils import AnthropicTokenCounterModelType.CLAUDE_3_SONNET,ModelType.CLAUDE_3_HAIKU,ModelType.CLAUDE_3_5_SONNET,+ ModelType.CLAUDE_3_5_HAIKU,],)def test_anthropic_model(model_type: ModelType):