camel-ai 0.2.73a4__py3-none-any.whl → 0.2.80a2__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.
- camel/__init__.py +1 -1
- camel/agents/_utils.py +38 -0
- camel/agents/chat_agent.py +2217 -519
- camel/agents/mcp_agent.py +30 -27
- camel/configs/__init__.py +15 -0
- camel/configs/aihubmix_config.py +88 -0
- camel/configs/amd_config.py +70 -0
- camel/configs/cometapi_config.py +104 -0
- camel/configs/minimax_config.py +93 -0
- camel/configs/nebius_config.py +103 -0
- camel/data_collectors/alpaca_collector.py +15 -6
- camel/datasets/base_generator.py +39 -10
- camel/environments/single_step.py +28 -3
- camel/environments/tic_tac_toe.py +1 -1
- camel/interpreters/__init__.py +2 -0
- camel/interpreters/docker/Dockerfile +3 -12
- camel/interpreters/e2b_interpreter.py +34 -1
- camel/interpreters/microsandbox_interpreter.py +395 -0
- camel/loaders/__init__.py +11 -2
- camel/loaders/chunkr_reader.py +9 -0
- camel/memories/agent_memories.py +48 -4
- camel/memories/base.py +26 -0
- camel/memories/blocks/chat_history_block.py +122 -4
- camel/memories/context_creators/score_based.py +25 -384
- camel/memories/records.py +88 -8
- camel/messages/base.py +153 -34
- camel/models/__init__.py +10 -0
- camel/models/aihubmix_model.py +83 -0
- camel/models/aiml_model.py +1 -16
- camel/models/amd_model.py +101 -0
- camel/models/anthropic_model.py +6 -19
- camel/models/aws_bedrock_model.py +2 -33
- camel/models/azure_openai_model.py +114 -89
- camel/models/base_audio_model.py +3 -1
- camel/models/base_model.py +32 -14
- camel/models/cohere_model.py +1 -16
- camel/models/cometapi_model.py +83 -0
- camel/models/crynux_model.py +1 -16
- camel/models/deepseek_model.py +1 -16
- camel/models/fish_audio_model.py +6 -0
- camel/models/gemini_model.py +36 -18
- 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/minimax_model.py +83 -0
- camel/models/mistral_model.py +1 -16
- camel/models/model_factory.py +27 -1
- camel/models/modelscope_model.py +1 -16
- camel/models/moonshot_model.py +105 -24
- camel/models/nebius_model.py +83 -0
- 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 +4 -19
- camel/models/openai_compatible_model.py +62 -41
- camel/models/openai_model.py +62 -57
- 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 +34 -47
- camel/models/sglang_model.py +64 -31
- 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 +60 -16
- camel/parsers/__init__.py +18 -0
- camel/parsers/mcp_tool_call_parser.py +176 -0
- camel/retrievers/auto_retriever.py +1 -0
- camel/runtimes/daytona_runtime.py +11 -12
- camel/societies/__init__.py +2 -0
- camel/societies/workforce/__init__.py +2 -0
- camel/societies/workforce/events.py +122 -0
- camel/societies/workforce/prompts.py +146 -66
- camel/societies/workforce/role_playing_worker.py +15 -11
- camel/societies/workforce/single_agent_worker.py +302 -65
- camel/societies/workforce/structured_output_handler.py +30 -18
- camel/societies/workforce/task_channel.py +163 -27
- camel/societies/workforce/utils.py +107 -13
- camel/societies/workforce/workflow_memory_manager.py +772 -0
- camel/societies/workforce/workforce.py +1949 -579
- camel/societies/workforce/workforce_callback.py +74 -0
- camel/societies/workforce/workforce_logger.py +168 -145
- camel/societies/workforce/workforce_metrics.py +33 -0
- camel/storages/key_value_storages/json.py +15 -2
- camel/storages/key_value_storages/mem0_cloud.py +48 -47
- camel/storages/object_storages/google_cloud.py +1 -1
- camel/storages/vectordb_storages/oceanbase.py +13 -13
- camel/storages/vectordb_storages/qdrant.py +3 -3
- camel/storages/vectordb_storages/tidb.py +8 -6
- camel/tasks/task.py +4 -3
- camel/toolkits/__init__.py +20 -7
- camel/toolkits/aci_toolkit.py +45 -0
- camel/toolkits/base.py +6 -4
- camel/toolkits/code_execution.py +28 -1
- camel/toolkits/context_summarizer_toolkit.py +684 -0
- camel/toolkits/dappier_toolkit.py +5 -1
- camel/toolkits/dingtalk.py +1135 -0
- camel/toolkits/edgeone_pages_mcp_toolkit.py +11 -31
- camel/toolkits/excel_toolkit.py +1 -1
- camel/toolkits/{file_write_toolkit.py → file_toolkit.py} +430 -36
- camel/toolkits/function_tool.py +13 -3
- camel/toolkits/github_toolkit.py +104 -17
- camel/toolkits/gmail_toolkit.py +1839 -0
- camel/toolkits/google_calendar_toolkit.py +38 -4
- camel/toolkits/google_drive_mcp_toolkit.py +12 -31
- camel/toolkits/hybrid_browser_toolkit/config_loader.py +15 -0
- camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit.py +77 -8
- camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit_ts.py +884 -88
- camel/toolkits/hybrid_browser_toolkit/installer.py +203 -0
- camel/toolkits/hybrid_browser_toolkit/ts/package-lock.json +5 -612
- camel/toolkits/hybrid_browser_toolkit/ts/package.json +0 -1
- camel/toolkits/hybrid_browser_toolkit/ts/src/browser-session.ts +959 -89
- camel/toolkits/hybrid_browser_toolkit/ts/src/config-loader.ts +9 -2
- camel/toolkits/hybrid_browser_toolkit/ts/src/hybrid-browser-toolkit.ts +281 -213
- camel/toolkits/hybrid_browser_toolkit/ts/src/parent-child-filter.ts +226 -0
- camel/toolkits/hybrid_browser_toolkit/ts/src/snapshot-parser.ts +219 -0
- camel/toolkits/hybrid_browser_toolkit/ts/src/som-screenshot-injected.ts +543 -0
- camel/toolkits/hybrid_browser_toolkit/ts/src/types.ts +23 -3
- camel/toolkits/hybrid_browser_toolkit/ts/websocket-server.js +72 -7
- camel/toolkits/hybrid_browser_toolkit/ws_wrapper.py +582 -132
- 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 +321 -8
- camel/toolkits/hybrid_browser_toolkit_py/snapshot.py +10 -4
- camel/toolkits/hybrid_browser_toolkit_py/unified_analyzer.js +45 -4
- camel/toolkits/{openai_image_toolkit.py → image_generation_toolkit.py} +151 -53
- camel/toolkits/klavis_toolkit.py +5 -1
- camel/toolkits/markitdown_toolkit.py +27 -1
- camel/toolkits/math_toolkit.py +64 -10
- camel/toolkits/mcp_toolkit.py +366 -71
- camel/toolkits/memory_toolkit.py +5 -1
- camel/toolkits/message_integration.py +18 -13
- camel/toolkits/minimax_mcp_toolkit.py +195 -0
- camel/toolkits/note_taking_toolkit.py +19 -10
- camel/toolkits/notion_mcp_toolkit.py +16 -26
- camel/toolkits/openbb_toolkit.py +5 -1
- camel/toolkits/origene_mcp_toolkit.py +8 -49
- camel/toolkits/playwright_mcp_toolkit.py +12 -31
- camel/toolkits/resend_toolkit.py +168 -0
- camel/toolkits/search_toolkit.py +264 -91
- camel/toolkits/slack_toolkit.py +64 -10
- camel/toolkits/terminal_toolkit/__init__.py +18 -0
- camel/toolkits/terminal_toolkit/terminal_toolkit.py +957 -0
- camel/toolkits/terminal_toolkit/utils.py +532 -0
- camel/toolkits/vertex_ai_veo_toolkit.py +590 -0
- camel/toolkits/video_analysis_toolkit.py +17 -11
- camel/toolkits/wechat_official_toolkit.py +483 -0
- camel/toolkits/zapier_toolkit.py +5 -1
- camel/types/__init__.py +2 -2
- camel/types/enums.py +274 -7
- camel/types/openai_types.py +2 -2
- camel/types/unified_model_type.py +15 -0
- camel/utils/commons.py +36 -5
- camel/utils/constants.py +3 -0
- camel/utils/context_utils.py +1003 -0
- camel/utils/mcp.py +138 -4
- camel/utils/token_counting.py +43 -20
- {camel_ai-0.2.73a4.dist-info → camel_ai-0.2.80a2.dist-info}/METADATA +223 -83
- {camel_ai-0.2.73a4.dist-info → camel_ai-0.2.80a2.dist-info}/RECORD +170 -141
- camel/loaders/pandas_reader.py +0 -368
- camel/toolkits/openai_agent_toolkit.py +0 -135
- camel/toolkits/terminal_toolkit.py +0 -1550
- {camel_ai-0.2.73a4.dist-info → camel_ai-0.2.80a2.dist-info}/WHEEL +0 -0
- {camel_ai-0.2.73a4.dist-info → camel_ai-0.2.80a2.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
# See the License for the specific language governing permissions and
|
|
12
|
+
# limitations under the License.
|
|
13
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
import platform
|
|
17
|
+
import shutil
|
|
18
|
+
import subprocess
|
|
19
|
+
from typing import Optional, Tuple
|
|
20
|
+
|
|
21
|
+
from camel.logger import get_logger
|
|
22
|
+
|
|
23
|
+
logger = get_logger(__name__)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def find_command(
|
|
27
|
+
cmd_base: str,
|
|
28
|
+
windows_variants: Optional[list] = None,
|
|
29
|
+
unix_variant: Optional[str] = None,
|
|
30
|
+
) -> Optional[str]:
|
|
31
|
+
"""Find command across platforms."""
|
|
32
|
+
is_windows = platform.system() == 'Windows'
|
|
33
|
+
|
|
34
|
+
if is_windows and windows_variants:
|
|
35
|
+
for variant in windows_variants:
|
|
36
|
+
if shutil.which(variant):
|
|
37
|
+
return variant
|
|
38
|
+
else:
|
|
39
|
+
variant = unix_variant or cmd_base
|
|
40
|
+
if shutil.which(variant):
|
|
41
|
+
return variant
|
|
42
|
+
|
|
43
|
+
if shutil.which(cmd_base):
|
|
44
|
+
return cmd_base
|
|
45
|
+
return None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def create_command_not_found_error(
|
|
49
|
+
command: str, error: Optional[Exception] = None
|
|
50
|
+
) -> RuntimeError:
|
|
51
|
+
base_msg = f"{command} is not installed or not in PATH. "
|
|
52
|
+
if command in ['npm', 'node']:
|
|
53
|
+
base_msg += (
|
|
54
|
+
f"Please install Node.js{' and npm' if command == 'npm' else ''} "
|
|
55
|
+
f"from https://nodejs.org/ to use the hybrid browser toolkit."
|
|
56
|
+
)
|
|
57
|
+
if not error:
|
|
58
|
+
base_msg += (
|
|
59
|
+
" If already installed, ensure the Node.js installation "
|
|
60
|
+
"directory (e.g., C:\\Program Files\\nodejs on Windows) is "
|
|
61
|
+
"in your system PATH."
|
|
62
|
+
)
|
|
63
|
+
if error:
|
|
64
|
+
base_msg += f" Error details: {error!s}"
|
|
65
|
+
return RuntimeError(base_msg)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def create_npm_command_error(command: str, error: Exception) -> RuntimeError:
|
|
69
|
+
return RuntimeError(
|
|
70
|
+
f"Failed to run {command}: {error!s}. "
|
|
71
|
+
f"Please ensure npm is properly installed and in PATH."
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
async def check_and_install_dependencies(ts_dir: str) -> Tuple[str, str]:
|
|
76
|
+
"""Check Node.js/npm and install dependencies if needed.
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
Tuple of (npm_cmd, node_cmd) that can be used for running commands
|
|
80
|
+
"""
|
|
81
|
+
is_windows = platform.system() == 'Windows'
|
|
82
|
+
use_shell = is_windows
|
|
83
|
+
|
|
84
|
+
npm_cmd = find_command('npm', windows_variants=['npm.cmd', 'npm.exe'])
|
|
85
|
+
if not npm_cmd:
|
|
86
|
+
raise create_command_not_found_error('npm')
|
|
87
|
+
|
|
88
|
+
try:
|
|
89
|
+
npm_check = subprocess.run(
|
|
90
|
+
[npm_cmd, '--version'],
|
|
91
|
+
capture_output=True,
|
|
92
|
+
text=True,
|
|
93
|
+
shell=use_shell,
|
|
94
|
+
)
|
|
95
|
+
if npm_check.returncode != 0:
|
|
96
|
+
raise RuntimeError(
|
|
97
|
+
f"npm command failed with error: {npm_check.stderr}. "
|
|
98
|
+
"Please ensure Node.js and npm are properly installed."
|
|
99
|
+
)
|
|
100
|
+
except (FileNotFoundError, OSError) as e:
|
|
101
|
+
raise create_command_not_found_error('npm', e)
|
|
102
|
+
|
|
103
|
+
node_cmd = find_command('node', windows_variants=['node.exe'])
|
|
104
|
+
if not node_cmd:
|
|
105
|
+
raise create_command_not_found_error('node')
|
|
106
|
+
|
|
107
|
+
try:
|
|
108
|
+
node_check = subprocess.run(
|
|
109
|
+
[node_cmd, '--version'],
|
|
110
|
+
capture_output=True,
|
|
111
|
+
text=True,
|
|
112
|
+
shell=use_shell,
|
|
113
|
+
)
|
|
114
|
+
if node_check.returncode != 0:
|
|
115
|
+
raise RuntimeError(
|
|
116
|
+
f"node command failed with error: {node_check.stderr}. "
|
|
117
|
+
"Please ensure Node.js is properly installed."
|
|
118
|
+
)
|
|
119
|
+
except (FileNotFoundError, OSError) as e:
|
|
120
|
+
raise create_command_not_found_error('node', e)
|
|
121
|
+
|
|
122
|
+
node_modules_path = os.path.join(ts_dir, 'node_modules')
|
|
123
|
+
if not os.path.exists(node_modules_path):
|
|
124
|
+
logger.warning("Node modules not found. Running npm install...")
|
|
125
|
+
try:
|
|
126
|
+
install_result = subprocess.run(
|
|
127
|
+
[npm_cmd, 'install'],
|
|
128
|
+
cwd=ts_dir,
|
|
129
|
+
capture_output=True,
|
|
130
|
+
text=True,
|
|
131
|
+
shell=use_shell,
|
|
132
|
+
)
|
|
133
|
+
if install_result.returncode != 0:
|
|
134
|
+
logger.error(f"npm install failed: {install_result.stderr}")
|
|
135
|
+
raise RuntimeError(
|
|
136
|
+
f"Failed to install npm dependencies: {install_result.stderr}\n" # noqa:E501
|
|
137
|
+
f"Please run 'npm install' in {ts_dir} manually."
|
|
138
|
+
)
|
|
139
|
+
except (FileNotFoundError, OSError) as e:
|
|
140
|
+
raise create_npm_command_error("npm install", e)
|
|
141
|
+
logger.info("npm dependencies installed successfully")
|
|
142
|
+
|
|
143
|
+
dist_dir = os.path.join(ts_dir, 'dist')
|
|
144
|
+
if not os.path.exists(dist_dir) or not os.listdir(dist_dir):
|
|
145
|
+
logger.info("Building TypeScript...")
|
|
146
|
+
try:
|
|
147
|
+
build_result = subprocess.run(
|
|
148
|
+
[npm_cmd, 'run', 'build'],
|
|
149
|
+
cwd=ts_dir,
|
|
150
|
+
capture_output=True,
|
|
151
|
+
text=True,
|
|
152
|
+
shell=use_shell,
|
|
153
|
+
)
|
|
154
|
+
if build_result.returncode != 0:
|
|
155
|
+
logger.error(f"TypeScript build failed: {build_result.stderr}")
|
|
156
|
+
raise RuntimeError(
|
|
157
|
+
f"TypeScript build failed: {build_result.stderr}"
|
|
158
|
+
)
|
|
159
|
+
logger.info("TypeScript build completed successfully")
|
|
160
|
+
except (FileNotFoundError, OSError) as e:
|
|
161
|
+
raise create_npm_command_error("npm run build", e)
|
|
162
|
+
else:
|
|
163
|
+
logger.info("TypeScript already built, skipping build")
|
|
164
|
+
|
|
165
|
+
playwright_marker = os.path.join(ts_dir, '.playwright_installed')
|
|
166
|
+
if not os.path.exists(playwright_marker):
|
|
167
|
+
logger.info("Installing Playwright browsers...")
|
|
168
|
+
npx_cmd = find_command('npx', windows_variants=['npx.cmd', 'npx.exe'])
|
|
169
|
+
if not npx_cmd:
|
|
170
|
+
logger.warning(
|
|
171
|
+
"npx not found. Skipping Playwright browser installation. "
|
|
172
|
+
"Users may need to run 'npx playwright install' manually."
|
|
173
|
+
)
|
|
174
|
+
else:
|
|
175
|
+
try:
|
|
176
|
+
playwright_install = subprocess.run(
|
|
177
|
+
[npx_cmd, 'playwright', 'install'],
|
|
178
|
+
cwd=ts_dir,
|
|
179
|
+
capture_output=True,
|
|
180
|
+
text=True,
|
|
181
|
+
shell=use_shell,
|
|
182
|
+
)
|
|
183
|
+
if playwright_install.returncode == 0:
|
|
184
|
+
logger.info("Playwright browsers installed successfully")
|
|
185
|
+
with open(playwright_marker, 'w') as f:
|
|
186
|
+
f.write('installed')
|
|
187
|
+
else:
|
|
188
|
+
logger.warning(
|
|
189
|
+
f"Playwright browser installation failed: "
|
|
190
|
+
f"{playwright_install.stderr}"
|
|
191
|
+
)
|
|
192
|
+
logger.warning(
|
|
193
|
+
"Users may need to run 'npx playwright install' "
|
|
194
|
+
"manually"
|
|
195
|
+
)
|
|
196
|
+
except (FileNotFoundError, OSError) as e:
|
|
197
|
+
logger.warning(
|
|
198
|
+
f"Failed to install Playwright browsers: {e!s}. "
|
|
199
|
+
f"Users may need to run 'npx playwright install' "
|
|
200
|
+
f"manually"
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
return npm_cmd, node_cmd
|