camel-ai 0.2.75a6__py3-none-any.whl → 0.2.76__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 +1001 -205
- camel/agents/mcp_agent.py +30 -27
- camel/configs/__init__.py +6 -0
- camel/configs/amd_config.py +70 -0
- camel/configs/cometapi_config.py +104 -0
- camel/data_collectors/alpaca_collector.py +15 -6
- camel/environments/tic_tac_toe.py +1 -1
- camel/interpreters/__init__.py +2 -0
- camel/interpreters/docker/Dockerfile +3 -12
- camel/interpreters/microsandbox_interpreter.py +395 -0
- camel/loaders/__init__.py +11 -2
- camel/loaders/chunkr_reader.py +9 -0
- camel/memories/__init__.py +2 -1
- camel/memories/agent_memories.py +3 -1
- camel/memories/blocks/chat_history_block.py +21 -3
- camel/memories/records.py +88 -8
- camel/messages/base.py +127 -34
- camel/models/__init__.py +4 -0
- camel/models/amd_model.py +101 -0
- camel/models/azure_openai_model.py +0 -6
- camel/models/base_model.py +30 -0
- camel/models/cometapi_model.py +83 -0
- camel/models/model_factory.py +4 -0
- camel/models/openai_compatible_model.py +0 -6
- camel/models/openai_model.py +0 -6
- camel/models/zhipuai_model.py +61 -2
- 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/workforce/prompts.py +131 -50
- camel/societies/workforce/single_agent_worker.py +434 -49
- camel/societies/workforce/structured_output_handler.py +30 -18
- camel/societies/workforce/task_channel.py +43 -0
- camel/societies/workforce/utils.py +105 -12
- camel/societies/workforce/workforce.py +1322 -311
- camel/societies/workforce/workforce_logger.py +24 -5
- camel/storages/key_value_storages/json.py +15 -2
- camel/storages/object_storages/google_cloud.py +1 -1
- camel/storages/vectordb_storages/oceanbase.py +10 -11
- camel/storages/vectordb_storages/tidb.py +8 -6
- camel/tasks/task.py +4 -3
- camel/toolkits/__init__.py +18 -5
- camel/toolkits/aci_toolkit.py +45 -0
- camel/toolkits/code_execution.py +28 -1
- camel/toolkits/context_summarizer_toolkit.py +684 -0
- camel/toolkits/dingtalk.py +1135 -0
- camel/toolkits/edgeone_pages_mcp_toolkit.py +11 -31
- camel/toolkits/{file_write_toolkit.py → file_toolkit.py} +194 -34
- camel/toolkits/function_tool.py +6 -1
- camel/toolkits/google_drive_mcp_toolkit.py +12 -31
- camel/toolkits/hybrid_browser_toolkit/config_loader.py +12 -0
- camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit.py +79 -2
- camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit_ts.py +95 -59
- 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 +619 -95
- camel/toolkits/hybrid_browser_toolkit/ts/src/config-loader.ts +7 -2
- camel/toolkits/hybrid_browser_toolkit/ts/src/hybrid-browser-toolkit.ts +115 -219
- 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 +1 -0
- camel/toolkits/hybrid_browser_toolkit/ts/websocket-server.js +39 -6
- camel/toolkits/hybrid_browser_toolkit/ws_wrapper.py +405 -131
- camel/toolkits/hybrid_browser_toolkit_py/hybrid_browser_toolkit.py +9 -5
- camel/toolkits/{openai_image_toolkit.py → image_generation_toolkit.py} +98 -31
- camel/toolkits/markitdown_toolkit.py +27 -1
- camel/toolkits/mcp_toolkit.py +348 -348
- camel/toolkits/message_integration.py +3 -0
- camel/toolkits/minimax_mcp_toolkit.py +195 -0
- camel/toolkits/note_taking_toolkit.py +18 -8
- camel/toolkits/notion_mcp_toolkit.py +16 -26
- 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/slack_toolkit.py +50 -1
- camel/toolkits/terminal_toolkit/__init__.py +18 -0
- camel/toolkits/terminal_toolkit/terminal_toolkit.py +924 -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/types/enums.py +124 -1
- camel/types/unified_model_type.py +5 -0
- camel/utils/commons.py +17 -0
- camel/utils/context_utils.py +804 -0
- camel/utils/mcp.py +136 -2
- camel/utils/token_counting.py +25 -17
- {camel_ai-0.2.75a6.dist-info → camel_ai-0.2.76.dist-info}/METADATA +158 -59
- {camel_ai-0.2.75a6.dist-info → camel_ai-0.2.76.dist-info}/RECORD +95 -76
- camel/loaders/pandas_reader.py +0 -368
- camel/toolkits/terminal_toolkit.py +0 -1788
- {camel_ai-0.2.75a6.dist-info → camel_ai-0.2.76.dist-info}/WHEEL +0 -0
- {camel_ai-0.2.75a6.dist-info → camel_ai-0.2.76.dist-info}/licenses/LICENSE +0 -0
|
@@ -92,11 +92,12 @@ class HybridBrowserToolkit(BaseToolkit, RegisteredAgentToolkit):
|
|
|
92
92
|
user_data_dir: Optional[str] = None,
|
|
93
93
|
stealth: bool = False,
|
|
94
94
|
web_agent_model: Optional[BaseModelBackend] = None,
|
|
95
|
-
cache_dir: str =
|
|
95
|
+
cache_dir: Optional[str] = None,
|
|
96
96
|
enabled_tools: Optional[List[str]] = None,
|
|
97
97
|
browser_log_to_file: bool = False,
|
|
98
|
+
log_dir: Optional[str] = None,
|
|
98
99
|
session_id: Optional[str] = None,
|
|
99
|
-
default_start_url: str =
|
|
100
|
+
default_start_url: Optional[str] = None,
|
|
100
101
|
default_timeout: Optional[int] = None,
|
|
101
102
|
short_timeout: Optional[int] = None,
|
|
102
103
|
navigation_timeout: Optional[int] = None,
|
|
@@ -144,6 +145,8 @@ class HybridBrowserToolkit(BaseToolkit, RegisteredAgentToolkit):
|
|
|
144
145
|
and page loading times.
|
|
145
146
|
Logs are saved to an auto-generated timestamped file.
|
|
146
147
|
Defaults to `False`.
|
|
148
|
+
log_dir (Optional[str]): Custom directory path for log files.
|
|
149
|
+
If None, defaults to "browser_log". Defaults to `None`.
|
|
147
150
|
session_id (Optional[str]): A unique identifier for this browser
|
|
148
151
|
session. When multiple HybridBrowserToolkit instances are
|
|
149
152
|
used
|
|
@@ -199,9 +202,10 @@ class HybridBrowserToolkit(BaseToolkit, RegisteredAgentToolkit):
|
|
|
199
202
|
self._user_data_dir = user_data_dir
|
|
200
203
|
self._stealth = stealth
|
|
201
204
|
self._web_agent_model = web_agent_model
|
|
202
|
-
self._cache_dir = cache_dir
|
|
205
|
+
self._cache_dir = cache_dir or "tmp/"
|
|
203
206
|
self._browser_log_to_file = browser_log_to_file
|
|
204
|
-
self.
|
|
207
|
+
self._log_dir = log_dir
|
|
208
|
+
self._default_start_url = default_start_url or "https://google.com/"
|
|
205
209
|
self._session_id = session_id or "default"
|
|
206
210
|
self._viewport_limit = viewport_limit
|
|
207
211
|
|
|
@@ -237,7 +241,7 @@ class HybridBrowserToolkit(BaseToolkit, RegisteredAgentToolkit):
|
|
|
237
241
|
# Set up log file if needed
|
|
238
242
|
if self.log_to_file:
|
|
239
243
|
# Create log directory if it doesn't exist
|
|
240
|
-
log_dir = "browser_log"
|
|
244
|
+
log_dir = self._log_dir if self._log_dir else "browser_log"
|
|
241
245
|
os.makedirs(log_dir, exist_ok=True)
|
|
242
246
|
|
|
243
247
|
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import base64
|
|
16
16
|
import os
|
|
17
17
|
from io import BytesIO
|
|
18
|
-
from typing import List, Literal, Optional, Union
|
|
18
|
+
from typing import ClassVar, List, Literal, Optional, Tuple, Union
|
|
19
19
|
|
|
20
20
|
from openai import OpenAI
|
|
21
21
|
from PIL import Image
|
|
@@ -29,21 +29,32 @@ logger = get_logger(__name__)
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
@MCPServer()
|
|
32
|
-
class
|
|
33
|
-
r"""A class toolkit for image generation using OpenAI
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
class ImageGenToolkit(BaseToolkit):
|
|
33
|
+
r"""A class toolkit for image generation using Grok and OpenAI models."""
|
|
34
|
+
|
|
35
|
+
GROK_MODELS: ClassVar[List[str]] = [
|
|
36
|
+
"grok-2-image",
|
|
37
|
+
"grok-2-image-latest",
|
|
38
|
+
"grok-2-image-1212",
|
|
39
|
+
]
|
|
40
|
+
OPENAI_MODELS: ClassVar[List[str]] = [
|
|
41
|
+
"gpt-image-1",
|
|
42
|
+
"dall-e-3",
|
|
43
|
+
"dall-e-2",
|
|
44
|
+
]
|
|
45
|
+
|
|
42
46
|
def __init__(
|
|
43
47
|
self,
|
|
44
48
|
model: Optional[
|
|
45
|
-
Literal[
|
|
46
|
-
|
|
49
|
+
Literal[
|
|
50
|
+
"gpt-image-1",
|
|
51
|
+
"dall-e-3",
|
|
52
|
+
"dall-e-2",
|
|
53
|
+
"grok-2-image",
|
|
54
|
+
"grok-2-image-latest",
|
|
55
|
+
"grok-2-image-1212",
|
|
56
|
+
]
|
|
57
|
+
] = "dall-e-3",
|
|
47
58
|
timeout: Optional[float] = None,
|
|
48
59
|
api_key: Optional[str] = None,
|
|
49
60
|
url: Optional[str] = None,
|
|
@@ -72,12 +83,12 @@ class OpenAIImageToolkit(BaseToolkit):
|
|
|
72
83
|
# NOTE: Some arguments are set in the constructor to prevent the agent
|
|
73
84
|
# from making invalid API calls with model-specific parameters. For
|
|
74
85
|
# example, the 'style' argument is only supported by 'dall-e-3'.
|
|
75
|
-
r"""Initializes a new instance of the
|
|
86
|
+
r"""Initializes a new instance of the ImageGenToolkit class.
|
|
76
87
|
|
|
77
88
|
Args:
|
|
78
89
|
api_key (Optional[str]): The API key for authenticating
|
|
79
|
-
with the
|
|
80
|
-
url (Optional[str]): The url to the
|
|
90
|
+
with the image model service. (default: :obj:`None`)
|
|
91
|
+
url (Optional[str]): The url to the image model service.
|
|
81
92
|
(default: :obj:`None`)
|
|
82
93
|
model (Optional[str]): The model to use.
|
|
83
94
|
(default: :obj:`"dall-e-3"`)
|
|
@@ -103,9 +114,23 @@ class OpenAIImageToolkit(BaseToolkit):
|
|
|
103
114
|
image.(default: :obj:`"image_save"`)
|
|
104
115
|
"""
|
|
105
116
|
super().__init__(timeout=timeout)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
117
|
+
if model not in self.GROK_MODELS + self.OPENAI_MODELS:
|
|
118
|
+
available_models = sorted(self.OPENAI_MODELS + self.GROK_MODELS)
|
|
119
|
+
raise ValueError(
|
|
120
|
+
f"Unsupported model: {model}. "
|
|
121
|
+
f"Supported models are: {available_models}"
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
# Set default url for Grok models
|
|
125
|
+
url = "https://api.x.ai/v1" if model in self.GROK_MODELS else url
|
|
126
|
+
|
|
127
|
+
api_key, base_url = (
|
|
128
|
+
self.get_openai_credentials(url, api_key)
|
|
129
|
+
if model in self.OPENAI_MODELS
|
|
130
|
+
else self.get_grok_credentials(url, api_key)
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
self.client = OpenAI(api_key=api_key, base_url=base_url)
|
|
109
134
|
self.model = model
|
|
110
135
|
self.size = size
|
|
111
136
|
self.quality = quality
|
|
@@ -139,7 +164,7 @@ class OpenAIImageToolkit(BaseToolkit):
|
|
|
139
164
|
return None
|
|
140
165
|
|
|
141
166
|
def _build_base_params(self, prompt: str, n: Optional[int] = None) -> dict:
|
|
142
|
-
r"""Build base parameters dict for
|
|
167
|
+
r"""Build base parameters dict for Image Model API calls.
|
|
143
168
|
|
|
144
169
|
Args:
|
|
145
170
|
prompt (str): The text prompt for the image operation.
|
|
@@ -153,6 +178,10 @@ class OpenAIImageToolkit(BaseToolkit):
|
|
|
153
178
|
# basic parameters supported by all models
|
|
154
179
|
if n is not None:
|
|
155
180
|
params["n"] = n # type: ignore[assignment]
|
|
181
|
+
|
|
182
|
+
if self.model in self.GROK_MODELS:
|
|
183
|
+
return params
|
|
184
|
+
|
|
156
185
|
if self.size is not None:
|
|
157
186
|
params["size"] = self.size
|
|
158
187
|
|
|
@@ -179,16 +208,18 @@ class OpenAIImageToolkit(BaseToolkit):
|
|
|
179
208
|
params["quality"] = self.quality
|
|
180
209
|
if self.background is not None:
|
|
181
210
|
params["background"] = self.background
|
|
182
|
-
|
|
183
211
|
return params
|
|
184
212
|
|
|
185
213
|
def _handle_api_response(
|
|
186
|
-
self,
|
|
214
|
+
self,
|
|
215
|
+
response,
|
|
216
|
+
image_name: Union[str, List[str]],
|
|
217
|
+
operation: str,
|
|
187
218
|
) -> str:
|
|
188
|
-
r"""Handle API response from
|
|
219
|
+
r"""Handle API response from image operations.
|
|
189
220
|
|
|
190
221
|
Args:
|
|
191
|
-
response: The response object from
|
|
222
|
+
response: The response object from image model API.
|
|
192
223
|
image_name (Union[str, List[str]]): Name(s) for the saved image
|
|
193
224
|
file(s). If str, the same name is used for all images (will
|
|
194
225
|
cause error for multiple images). If list, must have exactly
|
|
@@ -198,8 +229,9 @@ class OpenAIImageToolkit(BaseToolkit):
|
|
|
198
229
|
Returns:
|
|
199
230
|
str: Success message with image path/URL or error message.
|
|
200
231
|
"""
|
|
232
|
+
source = "Grok" if self.model in self.GROK_MODELS else "OpenAI"
|
|
201
233
|
if response.data is None or len(response.data) == 0:
|
|
202
|
-
error_msg = "No image data returned from
|
|
234
|
+
error_msg = f"No image data returned from {source} API."
|
|
203
235
|
logger.error(error_msg)
|
|
204
236
|
return error_msg
|
|
205
237
|
|
|
@@ -283,7 +315,7 @@ class OpenAIImageToolkit(BaseToolkit):
|
|
|
283
315
|
image_name: Union[str, List[str]] = "image.png",
|
|
284
316
|
n: int = 1,
|
|
285
317
|
) -> str:
|
|
286
|
-
r"""Generate an image using
|
|
318
|
+
r"""Generate an image using image models.
|
|
287
319
|
The generated image will be saved locally (for ``b64_json`` response
|
|
288
320
|
formats) or an image URL will be returned (for ``url`` response
|
|
289
321
|
formats).
|
|
@@ -309,15 +341,50 @@ class OpenAIImageToolkit(BaseToolkit):
|
|
|
309
341
|
logger.error(error_msg)
|
|
310
342
|
return error_msg
|
|
311
343
|
|
|
344
|
+
@api_keys_required([("api_key", "XAI_API_KEY")])
|
|
345
|
+
def get_grok_credentials(self, url, api_key) -> Tuple[str, str]: # type: ignore[return-value]
|
|
346
|
+
r"""Get API credentials for the specified Grok model.
|
|
347
|
+
|
|
348
|
+
Args:
|
|
349
|
+
url (str): The base URL for the Grok API.
|
|
350
|
+
api_key (str): The API key for the Grok API.
|
|
351
|
+
|
|
352
|
+
Returns:
|
|
353
|
+
tuple: (api_key, base_url)
|
|
354
|
+
"""
|
|
355
|
+
|
|
356
|
+
# Get credentials based on model type
|
|
357
|
+
api_key = api_key or os.getenv("XAI_API_KEY")
|
|
358
|
+
return api_key, url
|
|
359
|
+
|
|
360
|
+
@api_keys_required([("api_key", "OPENAI_API_KEY")])
|
|
361
|
+
def get_openai_credentials(self, url, api_key) -> Tuple[str, str | None]: # type: ignore[return-value]
|
|
362
|
+
r"""Get API credentials for the specified OpenAI model.
|
|
363
|
+
|
|
364
|
+
Args:
|
|
365
|
+
url (str): The base URL for the OpenAI API.
|
|
366
|
+
api_key (str): The API key for the OpenAI API.
|
|
367
|
+
|
|
368
|
+
Returns:
|
|
369
|
+
Tuple[str, str | None]: (api_key, base_url)
|
|
370
|
+
"""
|
|
371
|
+
|
|
372
|
+
api_key = api_key or os.getenv("OPENAI_API_KEY")
|
|
373
|
+
base_url = url or os.getenv("OPENAI_API_BASE_URL")
|
|
374
|
+
return api_key, base_url
|
|
375
|
+
|
|
312
376
|
def get_tools(self) -> List[FunctionTool]:
|
|
313
|
-
r"""Returns a list of FunctionTool objects representing the
|
|
314
|
-
|
|
377
|
+
r"""Returns a list of FunctionTool objects representing the functions
|
|
378
|
+
in the toolkit.
|
|
315
379
|
|
|
316
380
|
Returns:
|
|
317
|
-
List[FunctionTool]: A list of FunctionTool objects
|
|
318
|
-
|
|
381
|
+
List[FunctionTool]: A list of FunctionTool objects representing the
|
|
382
|
+
functions in the toolkit.
|
|
319
383
|
"""
|
|
320
384
|
return [
|
|
321
385
|
FunctionTool(self.generate_image),
|
|
322
|
-
# could add edit_image function later
|
|
323
386
|
]
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
# Backward compatibility alias
|
|
390
|
+
OpenAIImageToolkit = ImageGenToolkit
|
|
@@ -25,12 +25,38 @@ logger = get_logger(__name__)
|
|
|
25
25
|
|
|
26
26
|
@MCPServer()
|
|
27
27
|
class MarkItDownToolkit(BaseToolkit):
|
|
28
|
-
r"""A class representing a toolkit for MarkItDown.
|
|
28
|
+
r"""A class representing a toolkit for MarkItDown.
|
|
29
|
+
|
|
30
|
+
.. deprecated::
|
|
31
|
+
MarkItDownToolkit is deprecated. Use FileToolkit instead, which now
|
|
32
|
+
includes the same functionality through its read_file method that
|
|
33
|
+
supports both single files and multiple files.
|
|
34
|
+
|
|
35
|
+
Example migration:
|
|
36
|
+
# Old way
|
|
37
|
+
from camel.toolkits import MarkItDownToolkit
|
|
38
|
+
toolkit = MarkItDownToolkit()
|
|
39
|
+
content = toolkit.read_files(['file1.pdf', 'file2.docx'])
|
|
40
|
+
|
|
41
|
+
# New way
|
|
42
|
+
from camel.toolkits import FileToolkit
|
|
43
|
+
toolkit = FileToolkit()
|
|
44
|
+
content = toolkit.read_file(['file1.pdf', 'file2.docx'])
|
|
45
|
+
"""
|
|
29
46
|
|
|
30
47
|
def __init__(
|
|
31
48
|
self,
|
|
32
49
|
timeout: Optional[float] = None,
|
|
33
50
|
):
|
|
51
|
+
import warnings
|
|
52
|
+
|
|
53
|
+
warnings.warn(
|
|
54
|
+
"MarkItDownToolkit is deprecated and will be removed in a future "
|
|
55
|
+
"version. Please use FileToolkit instead, which now includes "
|
|
56
|
+
"read_file method that supports both single and multiple files.",
|
|
57
|
+
DeprecationWarning,
|
|
58
|
+
stacklevel=2,
|
|
59
|
+
)
|
|
34
60
|
super().__init__(timeout=timeout)
|
|
35
61
|
|
|
36
62
|
def read_files(self, file_paths: List[str]) -> Dict[str, str]:
|