camel-ai 0.2.74a5__py3-none-any.whl → 0.2.75a2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of camel-ai might be problematic. Click here for more details.
- camel/__init__.py +1 -1
- camel/agents/chat_agent.py +2 -2
- camel/interpreters/e2b_interpreter.py +34 -1
- camel/models/aiml_model.py +1 -16
- camel/models/anthropic_model.py +6 -22
- camel/models/aws_bedrock_model.py +1 -16
- camel/models/azure_openai_model.py +1 -16
- camel/models/base_model.py +0 -12
- camel/models/cohere_model.py +1 -16
- camel/models/crynux_model.py +1 -16
- camel/models/deepseek_model.py +1 -16
- camel/models/gemini_model.py +1 -16
- camel/models/groq_model.py +1 -17
- camel/models/internlm_model.py +1 -16
- camel/models/litellm_model.py +1 -16
- camel/models/lmstudio_model.py +1 -17
- camel/models/mistral_model.py +1 -16
- camel/models/modelscope_model.py +1 -16
- camel/models/moonshot_model.py +6 -22
- camel/models/nemotron_model.py +0 -5
- camel/models/netmind_model.py +1 -16
- camel/models/novita_model.py +1 -16
- camel/models/nvidia_model.py +1 -16
- camel/models/ollama_model.py +1 -16
- camel/models/openai_compatible_model.py +0 -3
- camel/models/openai_model.py +1 -16
- camel/models/openrouter_model.py +1 -17
- camel/models/ppio_model.py +1 -16
- camel/models/qianfan_model.py +1 -16
- camel/models/qwen_model.py +1 -16
- camel/models/reka_model.py +1 -16
- camel/models/samba_model.py +0 -32
- camel/models/sglang_model.py +1 -16
- camel/models/siliconflow_model.py +1 -16
- camel/models/stub_model.py +0 -4
- camel/models/togetherai_model.py +1 -16
- camel/models/vllm_model.py +1 -16
- camel/models/volcano_model.py +0 -17
- camel/models/watsonx_model.py +1 -16
- camel/models/yi_model.py +1 -16
- camel/models/zhipuai_model.py +1 -16
- camel/societies/workforce/prompts.py +1 -8
- camel/toolkits/__init__.py +0 -2
- camel/toolkits/hybrid_browser_toolkit/config_loader.py +3 -0
- camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit_ts.py +225 -0
- camel/toolkits/hybrid_browser_toolkit/ts/src/browser-session.ts +164 -8
- camel/toolkits/hybrid_browser_toolkit/ts/src/config-loader.ts +2 -0
- camel/toolkits/hybrid_browser_toolkit/ts/src/hybrid-browser-toolkit.ts +106 -1
- camel/toolkits/hybrid_browser_toolkit/ts/src/types.ts +19 -1
- camel/toolkits/hybrid_browser_toolkit/ts/websocket-server.js +20 -0
- camel/toolkits/hybrid_browser_toolkit/ws_wrapper.py +41 -0
- camel/toolkits/hybrid_browser_toolkit_py/actions.py +158 -0
- camel/toolkits/hybrid_browser_toolkit_py/browser_session.py +55 -8
- camel/toolkits/hybrid_browser_toolkit_py/config_loader.py +43 -0
- camel/toolkits/hybrid_browser_toolkit_py/hybrid_browser_toolkit.py +312 -3
- camel/toolkits/hybrid_browser_toolkit_py/snapshot.py +10 -4
- camel/toolkits/hybrid_browser_toolkit_py/unified_analyzer.js +45 -4
- camel/toolkits/search_toolkit.py +140 -27
- camel/types/__init__.py +2 -2
- camel/types/enums.py +20 -1
- camel/types/openai_types.py +2 -2
- camel/utils/mcp.py +2 -2
- camel/utils/token_counting.py +18 -3
- {camel_ai-0.2.74a5.dist-info → camel_ai-0.2.75a2.dist-info}/METADATA +6 -6
- {camel_ai-0.2.74a5.dist-info → camel_ai-0.2.75a2.dist-info}/RECORD +67 -68
- camel/toolkits/openai_agent_toolkit.py +0 -135
- {camel_ai-0.2.74a5.dist-info → camel_ai-0.2.75a2.dist-info}/WHEEL +0 -0
- {camel_ai-0.2.74a5.dist-info → camel_ai-0.2.75a2.dist-info}/licenses/LICENSE +0 -0
camel/toolkits/search_toolkit.py
CHANGED
|
@@ -458,17 +458,21 @@ class SearchToolkit(BaseToolkit):
|
|
|
458
458
|
|
|
459
459
|
Args:
|
|
460
460
|
query (str): The query to be searched.
|
|
461
|
-
search_type (str): The type of search to perform.
|
|
462
|
-
web pages or "image" for image search.
|
|
461
|
+
search_type (str): The type of search to perform. Must be either
|
|
462
|
+
"web" for web pages or "image" for image search. Any other
|
|
463
|
+
value will raise a ValueError. (default: "web")
|
|
463
464
|
number_of_result_pages (int): The number of result pages to
|
|
464
|
-
retrieve.
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
(
|
|
465
|
+
retrieve. Must be a positive integer between 1 and 10.
|
|
466
|
+
Google Custom Search API limits results to 10 per request.
|
|
467
|
+
If a value greater than 10 is provided, it will be capped
|
|
468
|
+
at 10 with a warning. Adjust this based on your task - use
|
|
469
|
+
fewer results for focused searches and more for comprehensive
|
|
470
|
+
searches. (default: :obj:`10`)
|
|
471
|
+
start_page (int): The result page to start from. Must be a
|
|
472
|
+
positive integer (>= 1). Use this for pagination - e.g.,
|
|
473
|
+
start_page=1 for results 1-10, start_page=11 for results
|
|
474
|
+
11-20, etc. This allows agents to check initial results
|
|
475
|
+
and continue searching if needed. (default: :obj:`1`)
|
|
472
476
|
|
|
473
477
|
Returns:
|
|
474
478
|
List[Dict[str, Any]]: A list of dictionaries where each dictionary
|
|
@@ -514,8 +518,33 @@ class SearchToolkit(BaseToolkit):
|
|
|
514
518
|
'height': 600
|
|
515
519
|
}
|
|
516
520
|
"""
|
|
521
|
+
from urllib.parse import quote
|
|
522
|
+
|
|
517
523
|
import requests
|
|
518
524
|
|
|
525
|
+
# Validate input parameters
|
|
526
|
+
if not isinstance(start_page, int) or start_page < 1:
|
|
527
|
+
raise ValueError("start_page must be a positive integer")
|
|
528
|
+
|
|
529
|
+
if (
|
|
530
|
+
not isinstance(number_of_result_pages, int)
|
|
531
|
+
or number_of_result_pages < 1
|
|
532
|
+
):
|
|
533
|
+
raise ValueError(
|
|
534
|
+
"number_of_result_pages must be a positive integer"
|
|
535
|
+
)
|
|
536
|
+
|
|
537
|
+
# Google Custom Search API has a limit of 10 results per request
|
|
538
|
+
if number_of_result_pages > 10:
|
|
539
|
+
logger.warning(
|
|
540
|
+
f"Google API limits results to 10 per request. "
|
|
541
|
+
f"Requested {number_of_result_pages}, using 10 instead."
|
|
542
|
+
)
|
|
543
|
+
number_of_result_pages = 10
|
|
544
|
+
|
|
545
|
+
if search_type not in ["web", "image"]:
|
|
546
|
+
raise ValueError("search_type must be either 'web' or 'image'")
|
|
547
|
+
|
|
519
548
|
# https://developers.google.com/custom-search/v1/overview
|
|
520
549
|
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
|
|
521
550
|
# https://cse.google.com/cse/all
|
|
@@ -535,11 +564,13 @@ class SearchToolkit(BaseToolkit):
|
|
|
535
564
|
modified_query = f"{query} {exclusion_terms}"
|
|
536
565
|
logger.debug(f"Excluded domains, modified query: {modified_query}")
|
|
537
566
|
|
|
567
|
+
encoded_query = quote(modified_query)
|
|
568
|
+
|
|
538
569
|
# Constructing the URL
|
|
539
570
|
# Doc: https://developers.google.com/custom-search/v1/using_rest
|
|
540
571
|
base_url = (
|
|
541
572
|
f"https://www.googleapis.com/customsearch/v1?"
|
|
542
|
-
f"key={GOOGLE_API_KEY}&cx={SEARCH_ENGINE_ID}&q={
|
|
573
|
+
f"key={GOOGLE_API_KEY}&cx={SEARCH_ENGINE_ID}&q={encoded_query}&start="
|
|
543
574
|
f"{start_page_idx}&lr={search_language}&num={number_of_result_pages}"
|
|
544
575
|
)
|
|
545
576
|
|
|
@@ -584,7 +615,6 @@ class SearchToolkit(BaseToolkit):
|
|
|
584
615
|
"context_url": context_url,
|
|
585
616
|
}
|
|
586
617
|
|
|
587
|
-
# Add dimensions if available
|
|
588
618
|
if width:
|
|
589
619
|
response["width"] = int(width)
|
|
590
620
|
if height:
|
|
@@ -592,8 +622,6 @@ class SearchToolkit(BaseToolkit):
|
|
|
592
622
|
|
|
593
623
|
responses.append(response)
|
|
594
624
|
else:
|
|
595
|
-
# Process web search results (existing logic)
|
|
596
|
-
# Check metatags are present
|
|
597
625
|
if "pagemap" not in search_item:
|
|
598
626
|
continue
|
|
599
627
|
if "metatags" not in search_item["pagemap"]:
|
|
@@ -607,12 +635,9 @@ class SearchToolkit(BaseToolkit):
|
|
|
607
635
|
][0]["og:description"]
|
|
608
636
|
else:
|
|
609
637
|
long_description = "N/A"
|
|
610
|
-
# Get the page title
|
|
611
638
|
title = search_item.get("title")
|
|
612
|
-
# Page snippet
|
|
613
639
|
snippet = search_item.get("snippet")
|
|
614
640
|
|
|
615
|
-
# Extract the page url
|
|
616
641
|
link = search_item.get("link")
|
|
617
642
|
response = {
|
|
618
643
|
"result_id": i,
|
|
@@ -623,16 +648,36 @@ class SearchToolkit(BaseToolkit):
|
|
|
623
648
|
}
|
|
624
649
|
responses.append(response)
|
|
625
650
|
else:
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
651
|
+
if "error" in data:
|
|
652
|
+
error_info = data.get("error", {})
|
|
653
|
+
logger.error(
|
|
654
|
+
f"Google search failed - API response: {error_info}"
|
|
655
|
+
)
|
|
656
|
+
responses.append(
|
|
657
|
+
{
|
|
658
|
+
"error": f"Google search failed - "
|
|
659
|
+
f"API response: {error_info}"
|
|
660
|
+
}
|
|
661
|
+
)
|
|
662
|
+
elif "searchInformation" in data:
|
|
663
|
+
search_info = data.get("searchInformation", {})
|
|
664
|
+
total_results = search_info.get("totalResults", "0")
|
|
665
|
+
if total_results == "0":
|
|
666
|
+
logger.info(f"No results found for query: {query}")
|
|
667
|
+
# Return empty list to indicate no results (not an error)
|
|
668
|
+
responses = []
|
|
669
|
+
else:
|
|
670
|
+
logger.warning(
|
|
671
|
+
f"Google search returned no items but claims {total_results} results"
|
|
672
|
+
)
|
|
673
|
+
responses = []
|
|
674
|
+
else:
|
|
675
|
+
logger.error(
|
|
676
|
+
f"Unexpected Google API response format: {data}"
|
|
677
|
+
)
|
|
678
|
+
responses.append(
|
|
679
|
+
{"error": "Unexpected response format from Google API"}
|
|
680
|
+
)
|
|
636
681
|
|
|
637
682
|
except Exception as e:
|
|
638
683
|
responses.append({"error": f"google search failed: {e!s}"})
|
|
@@ -1233,6 +1278,73 @@ class SearchToolkit(BaseToolkit):
|
|
|
1233
1278
|
f"search: {e!s}"
|
|
1234
1279
|
}
|
|
1235
1280
|
|
|
1281
|
+
@api_keys_required([(None, 'METASO_API_KEY')])
|
|
1282
|
+
def search_metaso(
|
|
1283
|
+
self,
|
|
1284
|
+
query: str,
|
|
1285
|
+
page: int = 1,
|
|
1286
|
+
include_summary: bool = False,
|
|
1287
|
+
include_raw_content: bool = False,
|
|
1288
|
+
concise_snippet: bool = False,
|
|
1289
|
+
scope: Literal[
|
|
1290
|
+
"webpage", "document", "scholar", "image", "video", "podcast"
|
|
1291
|
+
] = "webpage",
|
|
1292
|
+
) -> Dict[str, Any]:
|
|
1293
|
+
r"""Perform a web search using the metaso.cn API.
|
|
1294
|
+
|
|
1295
|
+
Args:
|
|
1296
|
+
query (str): The search query string.
|
|
1297
|
+
page (int): Page number. (default: :obj:`1`)
|
|
1298
|
+
include_summary (bool): Whether to include summary in the result.
|
|
1299
|
+
(default: :obj:`False`)
|
|
1300
|
+
include_raw_content (bool): Whether to include raw content in the
|
|
1301
|
+
result. (default: :obj:`False`)
|
|
1302
|
+
concise_snippet (bool): Whether to return concise snippet.
|
|
1303
|
+
(default: :obj:`False`)
|
|
1304
|
+
scope (Literal["webpage", "document", "scholar", "image", "video",
|
|
1305
|
+
"podcast"]): Search scope. (default: :obj:`"webpage"`)
|
|
1306
|
+
|
|
1307
|
+
Returns:
|
|
1308
|
+
Dict[str, Any]: Search results or error information.
|
|
1309
|
+
"""
|
|
1310
|
+
import http.client
|
|
1311
|
+
import json
|
|
1312
|
+
|
|
1313
|
+
# It is recommended to put the token in environment variable for
|
|
1314
|
+
# security
|
|
1315
|
+
|
|
1316
|
+
METASO_API_KEY = os.getenv("METASO_API_KEY")
|
|
1317
|
+
|
|
1318
|
+
conn = http.client.HTTPSConnection("metaso.cn")
|
|
1319
|
+
payload = json.dumps(
|
|
1320
|
+
{
|
|
1321
|
+
"q": query,
|
|
1322
|
+
"scope": scope,
|
|
1323
|
+
"includeSummary": include_summary,
|
|
1324
|
+
"page": str(page),
|
|
1325
|
+
"includeRawContent": include_raw_content,
|
|
1326
|
+
"conciseSnippet": concise_snippet,
|
|
1327
|
+
}
|
|
1328
|
+
)
|
|
1329
|
+
headers = {
|
|
1330
|
+
'Authorization': f'Bearer {METASO_API_KEY}',
|
|
1331
|
+
'Accept': 'application/json',
|
|
1332
|
+
'Content-Type': 'application/json',
|
|
1333
|
+
}
|
|
1334
|
+
try:
|
|
1335
|
+
conn.request("POST", "/api/v1/search", payload, headers)
|
|
1336
|
+
res = conn.getresponse()
|
|
1337
|
+
data = res.read()
|
|
1338
|
+
result = data.decode("utf-8")
|
|
1339
|
+
try:
|
|
1340
|
+
return json.loads(result)
|
|
1341
|
+
except Exception:
|
|
1342
|
+
return {
|
|
1343
|
+
"error": f"Metaso returned content could not be parsed: {result}"
|
|
1344
|
+
}
|
|
1345
|
+
except Exception as e:
|
|
1346
|
+
return {"error": f"Metaso search failed: {e}"}
|
|
1347
|
+
|
|
1236
1348
|
def get_tools(self) -> List[FunctionTool]:
|
|
1237
1349
|
r"""Returns a list of FunctionTool objects representing the
|
|
1238
1350
|
functions in the toolkit.
|
|
@@ -1253,4 +1365,5 @@ class SearchToolkit(BaseToolkit):
|
|
|
1253
1365
|
FunctionTool(self.search_bing),
|
|
1254
1366
|
FunctionTool(self.search_exa),
|
|
1255
1367
|
FunctionTool(self.search_alibaba_tongxiao),
|
|
1368
|
+
FunctionTool(self.search_metaso),
|
|
1256
1369
|
]
|
camel/types/__init__.py
CHANGED
|
@@ -41,8 +41,8 @@ from .openai_types import (
|
|
|
41
41
|
ChatCompletionAssistantMessageParam,
|
|
42
42
|
ChatCompletionChunk,
|
|
43
43
|
ChatCompletionMessage,
|
|
44
|
+
ChatCompletionMessageFunctionToolCall,
|
|
44
45
|
ChatCompletionMessageParam,
|
|
45
|
-
ChatCompletionMessageToolCall,
|
|
46
46
|
ChatCompletionSystemMessageParam,
|
|
47
47
|
ChatCompletionToolMessageParam,
|
|
48
48
|
ChatCompletionUserMessageParam,
|
|
@@ -71,7 +71,7 @@ __all__ = [
|
|
|
71
71
|
'ChatCompletionUserMessageParam',
|
|
72
72
|
'ChatCompletionAssistantMessageParam',
|
|
73
73
|
'ChatCompletionToolMessageParam',
|
|
74
|
-
'
|
|
74
|
+
'ChatCompletionMessageFunctionToolCall',
|
|
75
75
|
'CompletionUsage',
|
|
76
76
|
'OpenAIImageType',
|
|
77
77
|
'OpenAIVisionDetailType',
|
camel/types/enums.py
CHANGED
|
@@ -30,7 +30,7 @@ class RoleType(Enum):
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
class ModelType(UnifiedModelType, Enum):
|
|
33
|
-
DEFAULT = os.getenv("DEFAULT_MODEL_TYPE", "gpt-
|
|
33
|
+
DEFAULT = os.getenv("DEFAULT_MODEL_TYPE", "gpt-5-mini")
|
|
34
34
|
|
|
35
35
|
GPT_3_5_TURBO = "gpt-3.5-turbo"
|
|
36
36
|
GPT_4 = "gpt-4"
|
|
@@ -48,6 +48,9 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
48
48
|
O4_MINI = "o4-mini"
|
|
49
49
|
O3 = "o3"
|
|
50
50
|
O3_PRO = "o3-pro"
|
|
51
|
+
GPT_5 = "gpt-5"
|
|
52
|
+
GPT_5_MINI = "gpt-5-mini"
|
|
53
|
+
GPT_5_NANO = "gpt-5-nano"
|
|
51
54
|
|
|
52
55
|
AWS_CLAUDE_3_7_SONNET = "anthropic.claude-3-7-sonnet-20250219-v1:0"
|
|
53
56
|
AWS_CLAUDE_3_5_SONNET = "anthropic.claude-3-5-sonnet-20241022-v2:0"
|
|
@@ -59,6 +62,7 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
59
62
|
AWS_LLAMA_3_2_11B_INSTRUCT = "us.meta.llama3-2-11b-instruct-v1:0"
|
|
60
63
|
AWS_CLAUDE_SONNET_4 = "anthropic.claude-sonnet-4-20250514-v1:0"
|
|
61
64
|
AWS_CLAUDE_OPUS_4 = "anthropic.claude-opus-4-20250514-v1:0"
|
|
65
|
+
AWS_CLAUDE_OPUS_4_1 = "anthropic.claude-opus-4-1-20250805-v1:0"
|
|
62
66
|
|
|
63
67
|
GLM_4 = "glm-4"
|
|
64
68
|
GLM_4V = "glm-4v"
|
|
@@ -91,6 +95,7 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
91
95
|
OPENROUTER_LLAMA_4_SCOUT = "meta-llama/llama-4-scout"
|
|
92
96
|
OPENROUTER_LLAMA_4_SCOUT_FREE = "meta-llama/llama-4-scout:free"
|
|
93
97
|
OPENROUTER_OLYMPICODER_7B = "open-r1/olympiccoder-7b:free"
|
|
98
|
+
OPENROUTER_HORIZON_ALPHA = "openrouter/horizon-alpha"
|
|
94
99
|
|
|
95
100
|
# LMStudio models
|
|
96
101
|
LMSTUDIO_GEMMA_3_1B = "gemma-3-1b"
|
|
@@ -157,6 +162,7 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
157
162
|
CLAUDE_3_7_SONNET = "claude-3-7-sonnet-latest"
|
|
158
163
|
CLAUDE_SONNET_4 = "claude-sonnet-4-20250514"
|
|
159
164
|
CLAUDE_OPUS_4 = "claude-opus-4-20250514"
|
|
165
|
+
CLAUDE_OPUS_4_1 = "claude-opus-4-1-20250805"
|
|
160
166
|
|
|
161
167
|
# Netmind models
|
|
162
168
|
NETMIND_LLAMA_4_MAVERICK_17B_128E_INSTRUCT = (
|
|
@@ -495,6 +501,9 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
495
501
|
ModelType.GPT_4_1,
|
|
496
502
|
ModelType.GPT_4_1_MINI,
|
|
497
503
|
ModelType.GPT_4_1_NANO,
|
|
504
|
+
ModelType.GPT_5,
|
|
505
|
+
ModelType.GPT_5_MINI,
|
|
506
|
+
ModelType.GPT_5_NANO,
|
|
498
507
|
ModelType.O4_MINI,
|
|
499
508
|
ModelType.O3,
|
|
500
509
|
}
|
|
@@ -513,6 +522,7 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
513
522
|
ModelType.AWS_LLAMA_3_2_11B_INSTRUCT,
|
|
514
523
|
ModelType.AWS_CLAUDE_SONNET_4,
|
|
515
524
|
ModelType.AWS_CLAUDE_OPUS_4,
|
|
525
|
+
ModelType.AWS_CLAUDE_OPUS_4_1,
|
|
516
526
|
}
|
|
517
527
|
|
|
518
528
|
@property
|
|
@@ -535,6 +545,7 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
535
545
|
ModelType.GPT_4_1,
|
|
536
546
|
ModelType.GPT_4_1_MINI,
|
|
537
547
|
ModelType.GPT_4_1_NANO,
|
|
548
|
+
ModelType.GPT_5,
|
|
538
549
|
ModelType.O4_MINI,
|
|
539
550
|
ModelType.O3,
|
|
540
551
|
}
|
|
@@ -577,6 +588,7 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
577
588
|
ModelType.CLAUDE_3_7_SONNET,
|
|
578
589
|
ModelType.CLAUDE_SONNET_4,
|
|
579
590
|
ModelType.CLAUDE_OPUS_4,
|
|
591
|
+
ModelType.CLAUDE_OPUS_4_1,
|
|
580
592
|
}
|
|
581
593
|
|
|
582
594
|
@property
|
|
@@ -603,6 +615,7 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
603
615
|
ModelType.OPENROUTER_LLAMA_4_SCOUT,
|
|
604
616
|
ModelType.OPENROUTER_LLAMA_4_SCOUT_FREE,
|
|
605
617
|
ModelType.OPENROUTER_OLYMPICODER_7B,
|
|
618
|
+
ModelType.OPENROUTER_HORIZON_ALPHA,
|
|
606
619
|
}
|
|
607
620
|
|
|
608
621
|
@property
|
|
@@ -1170,6 +1183,9 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
1170
1183
|
ModelType.O1_PREVIEW,
|
|
1171
1184
|
ModelType.O1_MINI,
|
|
1172
1185
|
ModelType.GPT_4_5_PREVIEW,
|
|
1186
|
+
ModelType.GPT_5,
|
|
1187
|
+
ModelType.GPT_5_NANO,
|
|
1188
|
+
ModelType.GPT_5_MINI,
|
|
1173
1189
|
ModelType.MISTRAL_LARGE,
|
|
1174
1190
|
ModelType.MISTRAL_NEMO,
|
|
1175
1191
|
ModelType.MISTRAL_PIXTRAL_12B,
|
|
@@ -1262,6 +1278,7 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
1262
1278
|
ModelType.CLAUDE_3_7_SONNET,
|
|
1263
1279
|
ModelType.CLAUDE_SONNET_4,
|
|
1264
1280
|
ModelType.CLAUDE_OPUS_4,
|
|
1281
|
+
ModelType.CLAUDE_OPUS_4_1,
|
|
1265
1282
|
ModelType.YI_MEDIUM_200K,
|
|
1266
1283
|
ModelType.AWS_CLAUDE_3_5_SONNET,
|
|
1267
1284
|
ModelType.AWS_CLAUDE_3_HAIKU,
|
|
@@ -1269,6 +1286,7 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
1269
1286
|
ModelType.AWS_CLAUDE_3_7_SONNET,
|
|
1270
1287
|
ModelType.AWS_CLAUDE_SONNET_4,
|
|
1271
1288
|
ModelType.AWS_CLAUDE_OPUS_4,
|
|
1289
|
+
ModelType.AWS_CLAUDE_OPUS_4_1,
|
|
1272
1290
|
ModelType.O4_MINI,
|
|
1273
1291
|
ModelType.O3,
|
|
1274
1292
|
}:
|
|
@@ -1276,6 +1294,7 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
1276
1294
|
elif self in {
|
|
1277
1295
|
ModelType.MISTRAL_CODESTRAL_MAMBA,
|
|
1278
1296
|
ModelType.OPENROUTER_LLAMA_4_MAVERICK_FREE,
|
|
1297
|
+
ModelType.OPENROUTER_HORIZON_ALPHA,
|
|
1279
1298
|
}:
|
|
1280
1299
|
return 256_000
|
|
1281
1300
|
|
camel/types/openai_types.py
CHANGED
|
@@ -33,7 +33,7 @@ from openai.types.chat.chat_completion_user_message_param import (
|
|
|
33
33
|
from openai.types.completion_usage import CompletionUsage
|
|
34
34
|
from openai.types.chat import ParsedChatCompletion
|
|
35
35
|
from openai._types import NOT_GIVEN, NotGiven
|
|
36
|
-
from openai.types.chat import
|
|
36
|
+
from openai.types.chat import ChatCompletionMessageFunctionToolCall
|
|
37
37
|
|
|
38
38
|
__all__ = [
|
|
39
39
|
"Choice",
|
|
@@ -45,7 +45,7 @@ __all__ = [
|
|
|
45
45
|
"ChatCompletionUserMessageParam",
|
|
46
46
|
"ChatCompletionAssistantMessageParam",
|
|
47
47
|
"ChatCompletionToolMessageParam",
|
|
48
|
-
"
|
|
48
|
+
"ChatCompletionMessageFunctionToolCall",
|
|
49
49
|
"CompletionUsage",
|
|
50
50
|
"ParsedChatCompletion",
|
|
51
51
|
"NOT_GIVEN",
|
camel/utils/mcp.py
CHANGED
|
@@ -106,11 +106,11 @@ class MCPServer:
|
|
|
106
106
|
"""
|
|
107
107
|
from mcp.server.fastmcp import FastMCP
|
|
108
108
|
|
|
109
|
-
from camel.toolkits.base import BaseToolkit
|
|
110
|
-
|
|
111
109
|
original_init = cls.__init__
|
|
112
110
|
|
|
113
111
|
def new_init(instance, *args, **kwargs):
|
|
112
|
+
from camel.toolkits.base import BaseToolkit
|
|
113
|
+
|
|
114
114
|
original_init(instance, *args, **kwargs)
|
|
115
115
|
self.server_name = self.server_name or cls.__name__
|
|
116
116
|
instance.mcp = FastMCP(self.server_name)
|
camel/utils/token_counting.py
CHANGED
|
@@ -133,7 +133,11 @@ class OpenAITokenCounter(BaseTokenCounter):
|
|
|
133
133
|
self.tokens_per_message = 4
|
|
134
134
|
# If there's a name, the role is omitted
|
|
135
135
|
self.tokens_per_name = -1
|
|
136
|
-
elif (
|
|
136
|
+
elif (
|
|
137
|
+
("gpt-3.5-turbo" in self.model)
|
|
138
|
+
or ("gpt-4" in self.model)
|
|
139
|
+
or ("gpt-5" in self.model)
|
|
140
|
+
):
|
|
137
141
|
self.tokens_per_message = 3
|
|
138
142
|
self.tokens_per_name = 1
|
|
139
143
|
elif (
|
|
@@ -280,15 +284,26 @@ class OpenAITokenCounter(BaseTokenCounter):
|
|
|
280
284
|
|
|
281
285
|
class AnthropicTokenCounter(BaseTokenCounter):
|
|
282
286
|
@dependencies_required('anthropic')
|
|
283
|
-
def __init__(
|
|
287
|
+
def __init__(
|
|
288
|
+
self,
|
|
289
|
+
model: str,
|
|
290
|
+
api_key: Optional[str] = None,
|
|
291
|
+
base_url: Optional[str] = None,
|
|
292
|
+
):
|
|
284
293
|
r"""Constructor for the token counter for Anthropic models.
|
|
285
294
|
|
|
286
295
|
Args:
|
|
287
296
|
model (str): The name of the Anthropic model being used.
|
|
297
|
+
api_key (Optional[str], optional): The API key for authenticating
|
|
298
|
+
with the Anthropic service. If not provided, it will use the
|
|
299
|
+
ANTHROPIC_API_KEY environment variable. (default: :obj:`None`)
|
|
300
|
+
base_url (Optional[str], optional): The URL of the Anthropic
|
|
301
|
+
service. If not provided, it will use the default Anthropic
|
|
302
|
+
URL. (default: :obj:`None`)
|
|
288
303
|
"""
|
|
289
304
|
from anthropic import Anthropic
|
|
290
305
|
|
|
291
|
-
self.client = Anthropic()
|
|
306
|
+
self.client = Anthropic(api_key=api_key, base_url=base_url)
|
|
292
307
|
self.model = model
|
|
293
308
|
|
|
294
309
|
@dependencies_required('anthropic')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: camel-ai
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.75a2
|
|
4
4
|
Summary: Communicative Agents for AI Society Study
|
|
5
5
|
Project-URL: Homepage, https://www.camel-ai.org/
|
|
6
6
|
Project-URL: Repository, https://github.com/camel-ai/camel
|
|
@@ -32,7 +32,7 @@ Requires-Dist: azure-storage-blob<13,>=12.21.0; extra == 'all'
|
|
|
32
32
|
Requires-Dist: beautifulsoup4<5,>=4; extra == 'all'
|
|
33
33
|
Requires-Dist: botocore<2,>=1.35.3; extra == 'all'
|
|
34
34
|
Requires-Dist: chromadb<1.0.0,>=0.6.0; extra == 'all'
|
|
35
|
-
Requires-Dist: chunkr-ai
|
|
35
|
+
Requires-Dist: chunkr-ai<0.1.0,>=0.0.50; extra == 'all'
|
|
36
36
|
Requires-Dist: cohere<6,>=5.11.0; extra == 'all'
|
|
37
37
|
Requires-Dist: crawl4ai>=0.4.0; extra == 'all'
|
|
38
38
|
Requires-Dist: dappier<0.4,>=0.3.3; extra == 'all'
|
|
@@ -206,7 +206,7 @@ Requires-Dist: sphinx<8,>=7; extra == 'docs'
|
|
|
206
206
|
Requires-Dist: sphinxext-rediraffe<0.3,>=0.2.7; extra == 'docs'
|
|
207
207
|
Provides-Extra: document-tools
|
|
208
208
|
Requires-Dist: beautifulsoup4<5,>=4; extra == 'document-tools'
|
|
209
|
-
Requires-Dist: chunkr-ai
|
|
209
|
+
Requires-Dist: chunkr-ai<0.1.0,>=0.0.50; extra == 'document-tools'
|
|
210
210
|
Requires-Dist: crawl4ai>=0.3.745; extra == 'document-tools'
|
|
211
211
|
Requires-Dist: docx2txt<0.9,>=0.8; extra == 'document-tools'
|
|
212
212
|
Requires-Dist: docx>=0.2.4; extra == 'document-tools'
|
|
@@ -227,8 +227,8 @@ Requires-Dist: xls2xlsx>=0.2.0; extra == 'document-tools'
|
|
|
227
227
|
Provides-Extra: eigent
|
|
228
228
|
Requires-Dist: aci-sdk>=1.0.0b1; extra == 'eigent'
|
|
229
229
|
Requires-Dist: anthropic<0.50.0,>=0.47.0; extra == 'eigent'
|
|
230
|
+
Requires-Dist: chunkr-ai<0.1.0,>=0.0.50; extra == 'eigent'
|
|
230
231
|
Requires-Dist: chunkr-ai>=0.0.41; extra == 'eigent'
|
|
231
|
-
Requires-Dist: chunkr-ai>=0.0.50; extra == 'eigent'
|
|
232
232
|
Requires-Dist: crawl4ai>=0.3.745; extra == 'eigent'
|
|
233
233
|
Requires-Dist: datasets<4,>=3; extra == 'eigent'
|
|
234
234
|
Requires-Dist: docx>=0.2.4; extra == 'eigent'
|
|
@@ -286,8 +286,8 @@ Provides-Extra: owl
|
|
|
286
286
|
Requires-Dist: aci-sdk>=1.0.0b1; extra == 'owl'
|
|
287
287
|
Requires-Dist: anthropic<0.50.0,>=0.47.0; extra == 'owl'
|
|
288
288
|
Requires-Dist: beautifulsoup4<5,>=4; extra == 'owl'
|
|
289
|
+
Requires-Dist: chunkr-ai<0.1.0,>=0.0.50; extra == 'owl'
|
|
289
290
|
Requires-Dist: chunkr-ai>=0.0.41; extra == 'owl'
|
|
290
|
-
Requires-Dist: chunkr-ai>=0.0.50; extra == 'owl'
|
|
291
291
|
Requires-Dist: crawl4ai>=0.3.745; extra == 'owl'
|
|
292
292
|
Requires-Dist: datasets<4,>=3; extra == 'owl'
|
|
293
293
|
Requires-Dist: docx2txt<0.9,>=0.8; extra == 'owl'
|
|
@@ -335,7 +335,7 @@ Requires-Dist: xls2xlsx>=0.2.0; extra == 'owl'
|
|
|
335
335
|
Requires-Dist: yt-dlp<2025,>=2024.11.4; extra == 'owl'
|
|
336
336
|
Provides-Extra: rag
|
|
337
337
|
Requires-Dist: chromadb<1.0.0,>=0.6.0; extra == 'rag'
|
|
338
|
-
Requires-Dist: chunkr-ai
|
|
338
|
+
Requires-Dist: chunkr-ai<0.1.0,>=0.0.50; extra == 'rag'
|
|
339
339
|
Requires-Dist: cohere<6,>=5.11.0; extra == 'rag'
|
|
340
340
|
Requires-Dist: crawl4ai>=0.3.745; extra == 'rag'
|
|
341
341
|
Requires-Dist: faiss-cpu<2,>=1.7.2; extra == 'rag'
|