camel-ai 0.2.68__py3-none-any.whl → 0.2.69a2__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 +170 -11
- camel/configs/vllm_config.py +2 -0
- camel/datagen/self_improving_cot.py +1 -1
- camel/memories/context_creators/score_based.py +129 -87
- camel/runtimes/configs.py +11 -11
- camel/runtimes/daytona_runtime.py +4 -4
- camel/runtimes/docker_runtime.py +6 -6
- camel/runtimes/remote_http_runtime.py +5 -5
- camel/societies/workforce/prompts.py +13 -12
- camel/societies/workforce/single_agent_worker.py +263 -26
- camel/societies/workforce/utils.py +10 -2
- camel/societies/workforce/worker.py +21 -45
- camel/societies/workforce/workforce.py +43 -17
- camel/tasks/task.py +18 -12
- camel/toolkits/__init__.py +2 -0
- camel/toolkits/aci_toolkit.py +19 -19
- camel/toolkits/arxiv_toolkit.py +6 -6
- camel/toolkits/dappier_toolkit.py +5 -5
- camel/toolkits/file_write_toolkit.py +10 -10
- camel/toolkits/function_tool.py +4 -3
- camel/toolkits/github_toolkit.py +3 -3
- camel/toolkits/non_visual_browser_toolkit/__init__.py +18 -0
- camel/toolkits/non_visual_browser_toolkit/actions.py +196 -0
- camel/toolkits/non_visual_browser_toolkit/agent.py +278 -0
- camel/toolkits/non_visual_browser_toolkit/browser_non_visual_toolkit.py +363 -0
- camel/toolkits/non_visual_browser_toolkit/nv_browser_session.py +175 -0
- camel/toolkits/non_visual_browser_toolkit/snapshot.js +188 -0
- camel/toolkits/non_visual_browser_toolkit/snapshot.py +164 -0
- camel/toolkits/pptx_toolkit.py +4 -4
- camel/toolkits/sympy_toolkit.py +1 -1
- camel/toolkits/task_planning_toolkit.py +3 -3
- camel/toolkits/thinking_toolkit.py +1 -1
- camel/toolkits/video_analysis_toolkit.py +77 -3
- {camel_ai-0.2.68.dist-info → camel_ai-0.2.69a2.dist-info}/METADATA +5 -1
- {camel_ai-0.2.68.dist-info → camel_ai-0.2.69a2.dist-info}/RECORD +38 -31
- {camel_ai-0.2.68.dist-info → camel_ai-0.2.69a2.dist-info}/WHEEL +0 -0
- {camel_ai-0.2.68.dist-info → camel_ai-0.2.69a2.dist-info}/licenses/LICENSE +0 -0
|
@@ -674,8 +674,8 @@ class Workforce(BaseNode):
|
|
|
674
674
|
# Reset state for tasks being moved back to pending
|
|
675
675
|
for task in tasks_to_move_back:
|
|
676
676
|
# Handle all possible task states
|
|
677
|
-
if task.state in [TaskState.DONE, TaskState.
|
|
678
|
-
task.state = TaskState.OPEN
|
|
677
|
+
if task.state in [TaskState.DONE, TaskState.OPEN]:
|
|
678
|
+
task.state = TaskState.FAILED # TODO: Add logic for OPEN
|
|
679
679
|
# Clear result to avoid confusion
|
|
680
680
|
task.result = None
|
|
681
681
|
# Reset failure count to give task a fresh start
|
|
@@ -881,12 +881,17 @@ class Workforce(BaseNode):
|
|
|
881
881
|
self.reset()
|
|
882
882
|
self._task = task
|
|
883
883
|
self._state = WorkforceState.RUNNING
|
|
884
|
-
task.state = TaskState.OPEN
|
|
885
|
-
self._pending_tasks.append(task)
|
|
884
|
+
task.state = TaskState.FAILED # TODO: Add logic for OPEN
|
|
886
885
|
|
|
887
886
|
# Decompose the task into subtasks first
|
|
888
887
|
subtasks = self._decompose_task(task)
|
|
889
|
-
|
|
888
|
+
if subtasks:
|
|
889
|
+
# If decomposition happened, the original task becomes a container.
|
|
890
|
+
# We only execute its subtasks.
|
|
891
|
+
self._pending_tasks.extendleft(reversed(subtasks))
|
|
892
|
+
else:
|
|
893
|
+
# If no decomposition, execute the original task.
|
|
894
|
+
self._pending_tasks.append(task)
|
|
890
895
|
self.set_channel(TaskChannel())
|
|
891
896
|
|
|
892
897
|
# Save initial snapshot
|
|
@@ -998,21 +1003,23 @@ class Workforce(BaseNode):
|
|
|
998
1003
|
self,
|
|
999
1004
|
description: str,
|
|
1000
1005
|
worker: ChatAgent,
|
|
1001
|
-
|
|
1006
|
+
pool_max_size: int = 10,
|
|
1002
1007
|
) -> Workforce:
|
|
1003
1008
|
r"""Add a worker node to the workforce that uses a single agent.
|
|
1004
1009
|
|
|
1005
1010
|
Args:
|
|
1006
1011
|
description (str): Description of the worker node.
|
|
1007
1012
|
worker (ChatAgent): The agent to be added.
|
|
1008
|
-
|
|
1009
|
-
|
|
1013
|
+
pool_max_size (int): Maximum size of the agent pool.
|
|
1014
|
+
(default: :obj:`10`)
|
|
1010
1015
|
|
|
1011
1016
|
Returns:
|
|
1012
1017
|
Workforce: The workforce node itself.
|
|
1013
1018
|
"""
|
|
1014
1019
|
worker_node = SingleAgentWorker(
|
|
1015
|
-
description,
|
|
1020
|
+
description=description,
|
|
1021
|
+
worker=worker,
|
|
1022
|
+
pool_max_size=pool_max_size,
|
|
1016
1023
|
)
|
|
1017
1024
|
self._children.append(worker_node)
|
|
1018
1025
|
if self.metrics_logger:
|
|
@@ -1194,6 +1201,13 @@ class Workforce(BaseNode):
|
|
|
1194
1201
|
response = self.coordinator_agent.step(
|
|
1195
1202
|
prompt, response_format=TaskAssignResult
|
|
1196
1203
|
)
|
|
1204
|
+
if response.msg is None or response.msg.content is None:
|
|
1205
|
+
logger.error(
|
|
1206
|
+
"Coordinator agent returned empty response for task assignment"
|
|
1207
|
+
)
|
|
1208
|
+
# Return empty result as fallback
|
|
1209
|
+
return TaskAssignResult(assignments=[])
|
|
1210
|
+
|
|
1197
1211
|
result_dict = json.loads(response.msg.content, parse_int=str)
|
|
1198
1212
|
task_assign_result = TaskAssignResult(**result_dict)
|
|
1199
1213
|
return task_assign_result
|
|
@@ -1231,8 +1245,21 @@ class Workforce(BaseNode):
|
|
|
1231
1245
|
response = self.coordinator_agent.step(
|
|
1232
1246
|
prompt, response_format=WorkerConf
|
|
1233
1247
|
)
|
|
1234
|
-
|
|
1235
|
-
|
|
1248
|
+
if response.msg is None or response.msg.content is None:
|
|
1249
|
+
logger.error(
|
|
1250
|
+
"Coordinator agent returned empty response for worker creation"
|
|
1251
|
+
)
|
|
1252
|
+
# Create a fallback worker configuration
|
|
1253
|
+
new_node_conf = WorkerConf(
|
|
1254
|
+
description=f"Fallback worker for "
|
|
1255
|
+
f"task: {task.content[:50]}...",
|
|
1256
|
+
role="General Assistant",
|
|
1257
|
+
sys_msg="You are a general assistant that can help "
|
|
1258
|
+
"with various tasks.",
|
|
1259
|
+
)
|
|
1260
|
+
else:
|
|
1261
|
+
result_dict = json.loads(response.msg.content)
|
|
1262
|
+
new_node_conf = WorkerConf(**result_dict)
|
|
1236
1263
|
|
|
1237
1264
|
new_agent = self._create_new_agent(
|
|
1238
1265
|
new_node_conf.role,
|
|
@@ -1242,7 +1269,7 @@ class Workforce(BaseNode):
|
|
|
1242
1269
|
new_node = SingleAgentWorker(
|
|
1243
1270
|
description=new_node_conf.description,
|
|
1244
1271
|
worker=new_agent,
|
|
1245
|
-
|
|
1272
|
+
pool_max_size=10, # TODO: make this configurable
|
|
1246
1273
|
)
|
|
1247
1274
|
new_node.set_channel(self._channel)
|
|
1248
1275
|
|
|
@@ -1384,10 +1411,10 @@ class Workforce(BaseNode):
|
|
|
1384
1411
|
metadata={'failure_count': task.failure_count},
|
|
1385
1412
|
)
|
|
1386
1413
|
|
|
1387
|
-
if task.failure_count
|
|
1414
|
+
if task.failure_count > 3:
|
|
1388
1415
|
return True
|
|
1389
1416
|
|
|
1390
|
-
if task.get_depth()
|
|
1417
|
+
if task.get_depth() > 3:
|
|
1391
1418
|
# Create a new worker node and reassign
|
|
1392
1419
|
assignee = self._create_worker_node_for_task(task)
|
|
1393
1420
|
|
|
@@ -1685,7 +1712,7 @@ class Workforce(BaseNode):
|
|
|
1685
1712
|
await self._graceful_shutdown(returned_task)
|
|
1686
1713
|
break
|
|
1687
1714
|
elif returned_task.state == TaskState.OPEN:
|
|
1688
|
-
# TODO:
|
|
1715
|
+
# TODO: Add logic for OPEN
|
|
1689
1716
|
pass
|
|
1690
1717
|
else:
|
|
1691
1718
|
raise ValueError(
|
|
@@ -1797,7 +1824,7 @@ class Workforce(BaseNode):
|
|
|
1797
1824
|
new_instance.add_single_agent_worker(
|
|
1798
1825
|
child.description,
|
|
1799
1826
|
cloned_worker,
|
|
1800
|
-
|
|
1827
|
+
pool_max_size=10,
|
|
1801
1828
|
)
|
|
1802
1829
|
elif isinstance(child, RolePlayingWorker):
|
|
1803
1830
|
new_instance.add_role_playing_worker(
|
|
@@ -1808,7 +1835,6 @@ class Workforce(BaseNode):
|
|
|
1808
1835
|
child.user_agent_kwargs,
|
|
1809
1836
|
child.summarize_agent_kwargs,
|
|
1810
1837
|
child.chat_turn_limit,
|
|
1811
|
-
child.max_concurrent_tasks,
|
|
1812
1838
|
)
|
|
1813
1839
|
elif isinstance(child, Workforce):
|
|
1814
1840
|
new_instance.add_workforce(child.clone(with_memory))
|
camel/tasks/task.py
CHANGED
|
@@ -25,10 +25,12 @@ from typing import (
|
|
|
25
25
|
Union,
|
|
26
26
|
)
|
|
27
27
|
|
|
28
|
-
from pydantic import BaseModel
|
|
28
|
+
from pydantic import BaseModel, Field
|
|
29
29
|
|
|
30
30
|
if TYPE_CHECKING:
|
|
31
31
|
from camel.agents import ChatAgent
|
|
32
|
+
import uuid
|
|
33
|
+
|
|
32
34
|
from camel.logger import get_logger
|
|
33
35
|
from camel.messages import BaseMessage
|
|
34
36
|
from camel.prompts import TextPrompt
|
|
@@ -142,27 +144,29 @@ class Task(BaseModel):
|
|
|
142
144
|
content (str): string content for task.
|
|
143
145
|
id (str): An unique string identifier for the task. This should
|
|
144
146
|
ideally be provided by the provider/model which created the task.
|
|
145
|
-
(default: :obj
|
|
147
|
+
(default: :obj:`uuid.uuid4()`)
|
|
146
148
|
state (TaskState): The state which should be OPEN, RUNNING, DONE or
|
|
147
|
-
DELETED. (default: :obj
|
|
148
|
-
type (Optional[str]): task type. (default: :obj
|
|
149
|
+
DELETED. (default: :obj:`TaskState.FAILED`)
|
|
150
|
+
type (Optional[str]): task type. (default: :obj:`None`)
|
|
149
151
|
parent (Optional[Task]): The parent task, None for root task.
|
|
150
|
-
(default: :obj
|
|
152
|
+
(default: :obj:`None`)
|
|
151
153
|
subtasks (List[Task]): The childrent sub-tasks for the task.
|
|
152
|
-
(default: :obj
|
|
154
|
+
(default: :obj:`[]`)
|
|
153
155
|
result (Optional[str]): The answer for the task.
|
|
154
|
-
(default: :obj
|
|
156
|
+
(default: :obj:`""`)
|
|
155
157
|
failure_count (int): The failure count for the task.
|
|
156
|
-
(default: :obj
|
|
158
|
+
(default: :obj:`0`)
|
|
157
159
|
additional_info (Optional[Dict[str, Any]]): Additional information for
|
|
158
|
-
the task. (default: :obj
|
|
160
|
+
the task. (default: :obj:`None`)
|
|
159
161
|
"""
|
|
160
162
|
|
|
161
163
|
content: str
|
|
162
164
|
|
|
163
|
-
id: str =
|
|
165
|
+
id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
164
166
|
|
|
165
|
-
state: TaskState =
|
|
167
|
+
state: TaskState = (
|
|
168
|
+
TaskState.FAILED
|
|
169
|
+
) # TODO: Add logic for OPEN in workforce.py
|
|
166
170
|
|
|
167
171
|
type: Optional[str] = None
|
|
168
172
|
|
|
@@ -204,7 +208,9 @@ class Task(BaseModel):
|
|
|
204
208
|
|
|
205
209
|
def reset(self):
|
|
206
210
|
r"""Reset Task to initial state."""
|
|
207
|
-
self.state =
|
|
211
|
+
self.state = (
|
|
212
|
+
TaskState.FAILED
|
|
213
|
+
) # TODO: Add logic for OPEN in workforce.py
|
|
208
214
|
self.result = ""
|
|
209
215
|
|
|
210
216
|
def update_result(self, result: str):
|
camel/toolkits/__init__.py
CHANGED
|
@@ -77,6 +77,7 @@ from .aci_toolkit import ACIToolkit
|
|
|
77
77
|
from .playwright_mcp_toolkit import PlaywrightMCPToolkit
|
|
78
78
|
from .wolfram_alpha_toolkit import WolframAlphaToolkit
|
|
79
79
|
from .task_planning_toolkit import TaskPlanningToolkit
|
|
80
|
+
from .non_visual_browser_toolkit import BrowserNonVisualToolkit
|
|
80
81
|
|
|
81
82
|
|
|
82
83
|
__all__ = [
|
|
@@ -142,4 +143,5 @@ __all__ = [
|
|
|
142
143
|
'WolframAlphaToolkit',
|
|
143
144
|
'BohriumToolkit',
|
|
144
145
|
'TaskPlanningToolkit',
|
|
146
|
+
'BrowserNonVisualToolkit',
|
|
145
147
|
]
|
camel/toolkits/aci_toolkit.py
CHANGED
|
@@ -48,14 +48,14 @@ class ACIToolkit(BaseToolkit):
|
|
|
48
48
|
|
|
49
49
|
Args:
|
|
50
50
|
api_key (Optional[str]): The API key for authentication.
|
|
51
|
-
(default: :obj
|
|
51
|
+
(default: :obj:`None`)
|
|
52
52
|
base_url (Optional[str]): The base URL for the ACI API.
|
|
53
|
-
(default: :obj
|
|
53
|
+
(default: :obj:`None`)
|
|
54
54
|
linked_account_owner_id (Optional[str]): ID of the owner of the
|
|
55
55
|
linked account, e.g., "johndoe"
|
|
56
|
-
(default: :obj
|
|
56
|
+
(default: :obj:`None`)
|
|
57
57
|
timeout (Optional[float]): Request timeout.
|
|
58
|
-
(default: :obj
|
|
58
|
+
(default: :obj:`None`)
|
|
59
59
|
"""
|
|
60
60
|
from aci import ACI
|
|
61
61
|
|
|
@@ -80,20 +80,20 @@ class ACIToolkit(BaseToolkit):
|
|
|
80
80
|
Args:
|
|
81
81
|
intent (Optional[str]): Search results will be sorted by relevance
|
|
82
82
|
to this intent.
|
|
83
|
-
(default: :obj
|
|
83
|
+
(default: :obj:`None`)
|
|
84
84
|
allowed_app_only (bool): If true, only return apps that
|
|
85
85
|
are allowed by the agent/accessor, identified by the api key.
|
|
86
|
-
(default: :obj
|
|
86
|
+
(default: :obj:`True`)
|
|
87
87
|
include_functions (bool): If true, include functions
|
|
88
88
|
(name and description) in the search results.
|
|
89
|
-
(default: :obj
|
|
89
|
+
(default: :obj:`False`)
|
|
90
90
|
categories (Optional[List[str]]): List of categories to filter the
|
|
91
91
|
search results. Defaults to an empty list.
|
|
92
|
-
(default: :obj
|
|
92
|
+
(default: :obj:`None`)
|
|
93
93
|
limit (Optional[int]): Maximum number of results to return.
|
|
94
|
-
(default: :obj
|
|
94
|
+
(default: :obj:`10`)
|
|
95
95
|
offset (Optional[int]): Offset for pagination.
|
|
96
|
-
(default: :obj
|
|
96
|
+
(default: :obj:`0`)
|
|
97
97
|
|
|
98
98
|
Returns:
|
|
99
99
|
Optional[List[AppBasic]]: List of matching apps if successful,
|
|
@@ -123,10 +123,10 @@ class ACIToolkit(BaseToolkit):
|
|
|
123
123
|
|
|
124
124
|
Args:
|
|
125
125
|
app_names (Optional[List[str]]): List of app names to filter the
|
|
126
|
-
results. (default: :obj
|
|
126
|
+
results. (default: :obj:`None`)
|
|
127
127
|
limit (Optional[int]): Maximum number of results to return.
|
|
128
|
-
(default: :obj
|
|
129
|
-
offset (Optional[int]): Offset for pagination. (default: :obj
|
|
128
|
+
(default: :obj:`10`)
|
|
129
|
+
offset (Optional[int]): Offset for pagination. (default: :obj:`0`)
|
|
130
130
|
|
|
131
131
|
Returns:
|
|
132
132
|
Union[List[AppConfiguration], str]: List of configured apps if
|
|
@@ -356,15 +356,15 @@ class ACIToolkit(BaseToolkit):
|
|
|
356
356
|
|
|
357
357
|
Args:
|
|
358
358
|
app_names (Optional[List[str]]): List of app names to filter the
|
|
359
|
-
search results. (default: :obj
|
|
359
|
+
search results. (default: :obj:`None`)
|
|
360
360
|
intent (Optional[str]): The search query/intent.
|
|
361
|
-
(default: :obj
|
|
361
|
+
(default: :obj:`None`)
|
|
362
362
|
allowed_apps_only (bool): If true, only return
|
|
363
|
-
functions from allowed apps. (default: :obj
|
|
363
|
+
functions from allowed apps. (default: :obj:`True`)
|
|
364
364
|
limit (Optional[int]): Maximum number of results to return.
|
|
365
|
-
(default: :obj
|
|
365
|
+
(default: :obj:`10`)
|
|
366
366
|
offset (Optional[int]): Offset for pagination.
|
|
367
|
-
(default: :obj
|
|
367
|
+
(default: :obj:`0`)
|
|
368
368
|
|
|
369
369
|
Returns:
|
|
370
370
|
List[Dict]: List of matching functions
|
|
@@ -395,7 +395,7 @@ class ACIToolkit(BaseToolkit):
|
|
|
395
395
|
owner id in the ACI dashboard (https://platform.aci.dev).
|
|
396
396
|
allowed_apps_only (bool): If true, only returns functions/apps
|
|
397
397
|
that are allowed to be used by the agent/accessor, identified
|
|
398
|
-
by the api key. (default: :obj
|
|
398
|
+
by the api key. (default: :obj:`False`)
|
|
399
399
|
|
|
400
400
|
Returns:
|
|
401
401
|
Dict: Result of the function execution
|
camel/toolkits/arxiv_toolkit.py
CHANGED
|
@@ -49,9 +49,9 @@ class ArxivToolkit(BaseToolkit):
|
|
|
49
49
|
query (str): The search query string used to search for papers on
|
|
50
50
|
arXiv.
|
|
51
51
|
paper_ids (List[str], optional): A list of specific arXiv paper
|
|
52
|
-
IDs to search for. (default: :obj
|
|
52
|
+
IDs to search for. (default: :obj:`None`)
|
|
53
53
|
max_results (int, optional): The maximum number of search results
|
|
54
|
-
to retrieve. (default: :obj
|
|
54
|
+
to retrieve. (default: :obj:`5`)
|
|
55
55
|
|
|
56
56
|
Returns:
|
|
57
57
|
Generator: A generator that yields results from the arXiv search
|
|
@@ -80,9 +80,9 @@ class ArxivToolkit(BaseToolkit):
|
|
|
80
80
|
Args:
|
|
81
81
|
query (str): The search query string.
|
|
82
82
|
paper_ids (List[str], optional): A list of specific arXiv paper
|
|
83
|
-
IDs to search for. (default: :obj
|
|
83
|
+
IDs to search for. (default: :obj:`None`)
|
|
84
84
|
max_results (int, optional): The maximum number of search results
|
|
85
|
-
to return. (default: :obj
|
|
85
|
+
to return. (default: :obj:`5`)
|
|
86
86
|
|
|
87
87
|
Returns:
|
|
88
88
|
List[Dict[str, str]]: A list of dictionaries, each containing
|
|
@@ -138,9 +138,9 @@ class ArxivToolkit(BaseToolkit):
|
|
|
138
138
|
Args:
|
|
139
139
|
query (str): The search query string.
|
|
140
140
|
paper_ids (List[str], optional): A list of specific arXiv paper
|
|
141
|
-
IDs to download. (default: :obj
|
|
141
|
+
IDs to download. (default: :obj:`None`)
|
|
142
142
|
max_results (int, optional): The maximum number of search results
|
|
143
|
-
to download. (default: :obj
|
|
143
|
+
to download. (default: :obj:`5`)
|
|
144
144
|
output_dir (str, optional): The directory to save the downloaded
|
|
145
145
|
PDFs. Defaults to the current directory.
|
|
146
146
|
|
|
@@ -126,22 +126,22 @@ class DappierToolkit(BaseToolkit):
|
|
|
126
126
|
query (str): The user query for retrieving recommendations.
|
|
127
127
|
data_model_id (str, optional): The data model ID to use for
|
|
128
128
|
recommendations. Data model IDs always start with the prefix
|
|
129
|
-
"dm_". (default: :obj
|
|
129
|
+
"dm_". (default: :obj:`dm_01j0pb465keqmatq9k83dthx34`)
|
|
130
130
|
similarity_top_k (int, optional): The number of top documents to
|
|
131
|
-
retrieve based on similarity. (default: :obj
|
|
131
|
+
retrieve based on similarity. (default: :obj:`9`)
|
|
132
132
|
ref (Optional[str], optional): The site domain where AI
|
|
133
|
-
recommendations should be displayed. (default: :obj
|
|
133
|
+
recommendations should be displayed. (default: :obj:`None`)
|
|
134
134
|
num_articles_ref (int, optional): The minimum number of articles
|
|
135
135
|
to return from the specified reference domain (`ref`). The
|
|
136
136
|
remaining articles will come from other sites in the RAG
|
|
137
|
-
model. (default: :obj
|
|
137
|
+
model. (default: :obj:`0`)
|
|
138
138
|
search_algorithm (Literal[
|
|
139
139
|
"most_recent",
|
|
140
140
|
"semantic",
|
|
141
141
|
"most_recent_semantic",
|
|
142
142
|
"trending",
|
|
143
143
|
], optional): The search algorithm to use for retrieving
|
|
144
|
-
articles. (default: :obj
|
|
144
|
+
articles. (default: :obj:`most_recent`)
|
|
145
145
|
|
|
146
146
|
Returns:
|
|
147
147
|
List[Dict[str, str]]: A list of recommended articles or content
|
|
@@ -50,11 +50,11 @@ class FileWriteToolkit(BaseToolkit):
|
|
|
50
50
|
output_dir (str): The default directory for output files.
|
|
51
51
|
Defaults to the current working directory.
|
|
52
52
|
timeout (Optional[float]): The timeout for the toolkit.
|
|
53
|
-
(default: :obj
|
|
53
|
+
(default: :obj:`None`)
|
|
54
54
|
default_encoding (str): Default character encoding for text
|
|
55
|
-
operations. (default: :obj
|
|
55
|
+
operations. (default: :obj:`utf-8`)
|
|
56
56
|
backup_enabled (bool): Whether to create backups of existing files
|
|
57
|
-
before overwriting. (default: :obj
|
|
57
|
+
before overwriting. (default: :obj:`True`)
|
|
58
58
|
"""
|
|
59
59
|
super().__init__(timeout=timeout)
|
|
60
60
|
self.output_dir = Path(output_dir).resolve()
|
|
@@ -96,7 +96,7 @@ class FileWriteToolkit(BaseToolkit):
|
|
|
96
96
|
Args:
|
|
97
97
|
file_path (Path): The target file path.
|
|
98
98
|
content (str): The text content to write.
|
|
99
|
-
encoding (str): Character encoding to use. (default: :obj
|
|
99
|
+
encoding (str): Character encoding to use. (default: :obj:`utf-8`)
|
|
100
100
|
"""
|
|
101
101
|
with file_path.open("w", encoding=encoding) as f:
|
|
102
102
|
f.write(content)
|
|
@@ -157,7 +157,7 @@ class FileWriteToolkit(BaseToolkit):
|
|
|
157
157
|
content (str): The text content to write.
|
|
158
158
|
use_latex (bool): Whether to use LaTeX for rendering. (requires
|
|
159
159
|
LaTeX toolchain). If False, uses FPDF for simpler PDF
|
|
160
|
-
generation. (default: :obj
|
|
160
|
+
generation. (default: :obj:`False`)
|
|
161
161
|
|
|
162
162
|
Raises:
|
|
163
163
|
RuntimeError: If the 'pylatex' or 'fpdf' library is not installed
|
|
@@ -236,7 +236,7 @@ class FileWriteToolkit(BaseToolkit):
|
|
|
236
236
|
file_path (Path): The target file path.
|
|
237
237
|
content (Union[str, List[List]]): The CSV content as a string or
|
|
238
238
|
list of lists.
|
|
239
|
-
encoding (str): Character encoding to use. (default: :obj
|
|
239
|
+
encoding (str): Character encoding to use. (default: :obj:`utf-8`)
|
|
240
240
|
"""
|
|
241
241
|
import csv
|
|
242
242
|
|
|
@@ -259,7 +259,7 @@ class FileWriteToolkit(BaseToolkit):
|
|
|
259
259
|
Args:
|
|
260
260
|
file_path (Path): The target file path.
|
|
261
261
|
content (str): The JSON content as a string.
|
|
262
|
-
encoding (str): Character encoding to use. (default: :obj
|
|
262
|
+
encoding (str): Character encoding to use. (default: :obj:`utf-8`)
|
|
263
263
|
"""
|
|
264
264
|
import json
|
|
265
265
|
|
|
@@ -288,7 +288,7 @@ class FileWriteToolkit(BaseToolkit):
|
|
|
288
288
|
Args:
|
|
289
289
|
file_path (Path): The target file path.
|
|
290
290
|
content (str): The YAML content as a string.
|
|
291
|
-
encoding (str): Character encoding to use. (default: :obj
|
|
291
|
+
encoding (str): Character encoding to use. (default: :obj:`utf-8`)
|
|
292
292
|
"""
|
|
293
293
|
with file_path.open("w", encoding=encoding) as f:
|
|
294
294
|
f.write(content)
|
|
@@ -302,7 +302,7 @@ class FileWriteToolkit(BaseToolkit):
|
|
|
302
302
|
Args:
|
|
303
303
|
file_path (Path): The target file path.
|
|
304
304
|
content (str): The HTML content to write.
|
|
305
|
-
encoding (str): Character encoding to use. (default: :obj
|
|
305
|
+
encoding (str): Character encoding to use. (default: :obj:`utf-8`)
|
|
306
306
|
"""
|
|
307
307
|
with file_path.open("w", encoding=encoding) as f:
|
|
308
308
|
f.write(content)
|
|
@@ -316,7 +316,7 @@ class FileWriteToolkit(BaseToolkit):
|
|
|
316
316
|
Args:
|
|
317
317
|
file_path (Path): The target file path.
|
|
318
318
|
content (str): The Markdown content to write.
|
|
319
|
-
encoding (str): Character encoding to use. (default: :obj
|
|
319
|
+
encoding (str): Character encoding to use. (default: :obj:`utf-8`)
|
|
320
320
|
"""
|
|
321
321
|
with file_path.open("w", encoding=encoding) as f:
|
|
322
322
|
f.write(content)
|
camel/toolkits/function_tool.py
CHANGED
|
@@ -531,9 +531,10 @@ class FunctionTool:
|
|
|
531
531
|
param_dict = properties[param_name]
|
|
532
532
|
if "description" not in param_dict:
|
|
533
533
|
warnings.warn(
|
|
534
|
-
f"Parameter description is missing "
|
|
535
|
-
f"
|
|
536
|
-
f"
|
|
534
|
+
f"Parameter description is missing for the "
|
|
535
|
+
f"function '{openai_tool_schema['function']['name']}'. "
|
|
536
|
+
f"The parameter definition is {param_dict}. "
|
|
537
|
+
f"This may affect the quality of tool calling."
|
|
537
538
|
)
|
|
538
539
|
|
|
539
540
|
def get_openai_tool_schema(self) -> Dict[str, Any]:
|
camel/toolkits/github_toolkit.py
CHANGED
|
@@ -158,7 +158,7 @@ class GithubToolkit(BaseToolkit):
|
|
|
158
158
|
Args:
|
|
159
159
|
repo_name (str): The name of the GitHub repository.
|
|
160
160
|
state (Literal["open", "closed", "all"]): The state of pull
|
|
161
|
-
requests to retrieve. (default: :obj
|
|
161
|
+
requests to retrieve. (default: :obj:`all`)
|
|
162
162
|
Options are:
|
|
163
163
|
- "open": Retrieve only open pull requests.
|
|
164
164
|
- "closed": Retrieve only closed pull requests.
|
|
@@ -202,7 +202,7 @@ class GithubToolkit(BaseToolkit):
|
|
|
202
202
|
Args:
|
|
203
203
|
repo_name (str): The name of the GitHub repository.
|
|
204
204
|
state (Literal["open", "closed", "all"]): The state of pull
|
|
205
|
-
requests to retrieve. (default: :obj
|
|
205
|
+
requests to retrieve. (default: :obj:`all`)
|
|
206
206
|
Options are:
|
|
207
207
|
- "open": Retrieve only open pull requests.
|
|
208
208
|
- "closed": Retrieve only closed pull requests.
|
|
@@ -285,7 +285,7 @@ class GithubToolkit(BaseToolkit):
|
|
|
285
285
|
repo_name (str): The name of the GitHub repository.
|
|
286
286
|
path (str): The repository path to start the traversal from.
|
|
287
287
|
empty string means starts from the root directory.
|
|
288
|
-
(default: :obj
|
|
288
|
+
(default: :obj:`""`)
|
|
289
289
|
|
|
290
290
|
Returns:
|
|
291
291
|
List[str]: A list of file paths within the specified directory
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
from .browser_non_visual_toolkit import BrowserNonVisualToolkit
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"BrowserNonVisualToolkit",
|
|
18
|
+
]
|