Skip to content

Commit cd38ba2

Browse files
authored
fix: anthropic token counter (#2980)
1 parent 8a584cd commit cd38ba2

File tree

7 files changed

+124
-126
lines changed

7 files changed

+124
-126
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ body:
2626
attributes:
2727
label: What version of camel are you using?
2828
description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here.
29-
placeholder: E.g., 0.2.74a4
29+
placeholder: E.g., 0.2.74a5
3030
validations:
3131
required: true
3232

camel/__init__.py

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

1515
from camel.logger import disable_logging, enable_logging, set_log_level
1616

17-
__version__ = '0.2.74a4'
17+
__version__ = '0.2.74a5'
1818

1919
__all__ = [
2020
'__version__',

camel/models/anthropic_model.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ def token_counter(self) -> BaseTokenCounter:
145145
tokenization style.
146146
"""
147147
if not self._token_counter:
148-
self._token_counter = AnthropicTokenCounter(self.model_type)
148+
# Pass the API key to the token counter
149+
self._token_counter = AnthropicTokenCounter(
150+
self.model_type, api_key=self._api_key
151+
)
149152
return self._token_counter
150153

151154
def check_model_config(self):

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
project = 'CAMEL'
2828
copyright = '2024, CAMEL-AI.org'
2929
author = 'CAMEL-AI.org'
30-
release = '0.2.74a4'
30+
release = '0.2.74a5'
3131

3232
html_favicon = (
3333
'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'

examples/workforce/eigent.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ def developer_agent_factory(
169169
<operating_environment>
170170
- **System**: {platform.system()} ({platform.machine()})
171171
- **Working Directory**: `{WORKING_DIRECTORY}`. All local file operations must
172-
occur here, but you can access files from any place in the file system.
172+
occur here, but you can access files from any place in the file system. For
173+
all file system operations, you MUST use absolute paths to ensure precision
174+
and avoid ambiguity.
173175
- **Current Date**: {datetime.date.today()}.
174176
</operating_environment>
175177
@@ -380,7 +382,7 @@ def search_agent_factory(
380382
<operating_environment>
381383
- **System**: {platform.system()} ({platform.machine()})
382384
- **Working Directory**: `{WORKING_DIRECTORY}`. All local file operations must
383-
occur here.
385+
occur here, but you can access files from any place in the file system. For all file system operations, you MUST use absolute paths to ensure precision and avoid ambiguity.
384386
- **Current Date**: {datetime.date.today()}.
385387
</operating_environment>
386388
@@ -536,7 +538,7 @@ def document_agent_factory(
536538
<operating_environment>
537539
- **System**: {platform.system()} ({platform.machine()})
538540
- **Working Directory**: `{WORKING_DIRECTORY}`. All local file operations must
539-
occur here.
541+
occur here, but you can access files from any place in the file system. For all file system operations, you MUST use absolute paths to ensure precision and avoid ambiguity.
540542
- **Current Date**: {datetime.date.today()}.
541543
</operating_environment>
542544
@@ -728,7 +730,7 @@ def multi_modal_agent_factory(model: BaseModelBackend, task_id: str):
728730
<operating_environment>
729731
- **System**: {platform.system()} ({platform.machine()})
730732
- **Working Directory**: `{WORKING_DIRECTORY}`. All local file operations must
731-
occur here.
733+
occur here, but you can access files from any place in the file system. For all file system operations, you MUST use absolute paths to ensure precision and avoid ambiguity.
732734
- **Current Date**: {datetime.date.today()}.
733735
</operating_environment>
734736
@@ -940,8 +942,7 @@ async def main():
940942
f""""
941943
You are a helpful coordinator.
942944
- You are now working in system {platform.system()} with architecture
943-
{platform.machine()} at working directory `{WORKING_DIRECTORY}`. All your
944-
work related to local operations should be done in that directory.
945+
{platform.machine()} at working directory `{WORKING_DIRECTORY}`. All local file operations must occur here, but you can access files from any place in the file system. For all file system operations, you MUST use absolute paths to ensure precision and avoid ambiguity.
945946
The current date is {datetime.date.today()}. For any date-related tasks, you
946947
MUST use this as the current date.
947948
@@ -962,8 +963,7 @@ async def main():
962963
963964
You are a helpful task planner.
964965
- You are now working in system {platform.system()} with architecture
965-
{platform.machine()} at working directory `{WORKING_DIRECTORY}`. All your
966-
work related to local operations should be done in that directory.
966+
{platform.machine()} at working directory `{WORKING_DIRECTORY}`. All local file operations must occur here, but you can access files from any place in the file system. For all file system operations, you MUST use absolute paths to ensure precision and avoid ambiguity.
967967
The current date is {datetime.date.today()}. For any date-related tasks, you
968968
MUST use this as the current date.
969969
""",
@@ -981,8 +981,7 @@ async def main():
981981
f"detailed, and easy-to-read format. Avoid using markdown tables for "
982982
f"presenting data; use plain text formatting instead. You are now "
983983
f"working in "
984-
f"`{WORKING_DIRECTORY}` All your work related to local "
985-
"operations should be done in that "
984+
f"`{WORKING_DIRECTORY}` All local file operations must occur here, but you can access files from any place in the file system. For all file system operations, you MUST use absolute paths to ensure precision and avoid ambiguity."
986985
"directory. You can also communicate with other agents "
987986
"using messaging tools - use `list_available_agents` to see "
988987
"available team members and `send_message` to coordinate work "

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "camel-ai"
7-
version = "0.2.74a4"
7+
version = "0.2.74a5"
88
description = "Communicative Agents for AI Society Study"
99
authors = [{ name = "CAMEL-AI.org" }]
1010
requires-python = ">=3.10,<3.13"

0 commit comments

Comments
 (0)