🐫 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
fix: anthropic token counter (#587)
Junrong Lin6df0552a85a1
diff --git a/camel/utils/token_counting.py b/camel/utils/token_counting.pyindex 35fbe7871..ed7719418 100644--- a/camel/utils/token_counting.py+++ b/camel/utils/token_counting.py@@ -296,9 +296,11 @@ class AnthropicTokenCounter(BaseTokenCounter):Returns:int: Number of tokens in the messages."""- prompt = messages_to_prompt(messages, self.model_type)-- return self.client.count_tokens(prompt)+ num_tokens = 0+ for message in messages:+ content = str(message["content"])+ num_tokens += self.client.count_tokens(content)+ return num_tokensclass LiteLLMTokenCounter: