camel-ai 0.2.69a4__py3-none-any.whl → 0.2.69a7__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 +220 -7
- camel/interpreters/internal_python_interpreter.py +51 -2
- camel/memories/context_creators/score_based.py +11 -6
- camel/messages/base.py +2 -2
- camel/models/base_model.py +91 -2
- camel/societies/workforce/workforce.py +214 -22
- camel/storages/__init__.py +2 -0
- camel/storages/vectordb_storages/__init__.py +2 -0
- camel/storages/vectordb_storages/chroma.py +731 -0
- camel/tasks/task.py +30 -2
- camel/toolkits/__init__.py +8 -1
- camel/toolkits/craw4ai_toolkit.py +73 -0
- camel/toolkits/edgeone_pages_mcp_toolkit.py +69 -0
- camel/toolkits/excel_toolkit.py +814 -69
- camel/toolkits/google_drive_mcp_toolkit.py +73 -0
- camel/toolkits/markitdown_toolkit.py +78 -0
- camel/toolkits/mcp_toolkit.py +31 -1
- camel/toolkits/non_visual_browser_toolkit/browser_non_visual_toolkit.py +91 -57
- camel/types/enums.py +6 -6
- {camel_ai-0.2.69a4.dist-info → camel_ai-0.2.69a7.dist-info}/METADATA +5 -6
- {camel_ai-0.2.69a4.dist-info → camel_ai-0.2.69a7.dist-info}/RECORD +24 -19
- {camel_ai-0.2.69a4.dist-info → camel_ai-0.2.69a7.dist-info}/WHEEL +0 -0
- {camel_ai-0.2.69a4.dist-info → camel_ai-0.2.69a7.dist-info}/licenses/LICENSE +0 -0
camel/tasks/task.py
CHANGED
|
@@ -25,7 +25,8 @@ from typing import (
|
|
|
25
25
|
Union,
|
|
26
26
|
)
|
|
27
27
|
|
|
28
|
-
from
|
|
28
|
+
from PIL import Image
|
|
29
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
29
30
|
|
|
30
31
|
if TYPE_CHECKING:
|
|
31
32
|
from camel.agents import ChatAgent
|
|
@@ -158,6 +159,14 @@ class Task(BaseModel):
|
|
|
158
159
|
(default: :obj:`0`)
|
|
159
160
|
additional_info (Optional[Dict[str, Any]]): Additional information for
|
|
160
161
|
the task. (default: :obj:`None`)
|
|
162
|
+
image_list (Optional[List[Image.Image]]): Optional list of PIL Image
|
|
163
|
+
objects associated with the task. (default: :obj:`None`)
|
|
164
|
+
image_detail (Literal["auto", "low", "high"]): Detail level of the
|
|
165
|
+
images associated with the task. (default: :obj:`auto`)
|
|
166
|
+
video_bytes (Optional[bytes]): Optional bytes of a video associated
|
|
167
|
+
with the task. (default: :obj:`None`)
|
|
168
|
+
video_detail (Literal["auto", "low", "high"]): Detail level of the
|
|
169
|
+
videos associated with the task. (default: :obj:`auto`)
|
|
161
170
|
"""
|
|
162
171
|
|
|
163
172
|
content: str
|
|
@@ -180,6 +189,16 @@ class Task(BaseModel):
|
|
|
180
189
|
|
|
181
190
|
additional_info: Optional[Dict[str, Any]] = None
|
|
182
191
|
|
|
192
|
+
image_list: Optional[List[Image.Image]] = None
|
|
193
|
+
|
|
194
|
+
image_detail: Literal["auto", "low", "high"] = "auto"
|
|
195
|
+
|
|
196
|
+
video_bytes: Optional[bytes] = None
|
|
197
|
+
|
|
198
|
+
video_detail: Literal["auto", "low", "high"] = "auto"
|
|
199
|
+
|
|
200
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
201
|
+
|
|
183
202
|
def __repr__(self) -> str:
|
|
184
203
|
r"""Return a string representation of the task."""
|
|
185
204
|
content_preview = self.content
|
|
@@ -363,6 +382,10 @@ class Task(BaseModel):
|
|
|
363
382
|
role_name=role_name,
|
|
364
383
|
content=self.content,
|
|
365
384
|
additional_info=self.additional_info,
|
|
385
|
+
image_list=self.image_list,
|
|
386
|
+
image_detail=self.image_detail,
|
|
387
|
+
video_bytes=self.video_bytes,
|
|
388
|
+
video_detail=self.video_detail,
|
|
366
389
|
other_results=sub_tasks_result,
|
|
367
390
|
)
|
|
368
391
|
msg = BaseMessage.make_user_message(
|
|
@@ -513,7 +536,12 @@ class TaskManager:
|
|
|
513
536
|
role_name = agent.role_name
|
|
514
537
|
content = template.format(role_name=role_name, content=task.content)
|
|
515
538
|
msg = BaseMessage.make_user_message(
|
|
516
|
-
role_name=role_name,
|
|
539
|
+
role_name=role_name,
|
|
540
|
+
content=content,
|
|
541
|
+
image_list=task.image_list,
|
|
542
|
+
image_detail=task.image_detail,
|
|
543
|
+
video_bytes=task.video_bytes,
|
|
544
|
+
video_detail=task.video_detail,
|
|
517
545
|
)
|
|
518
546
|
response = agent.step(msg)
|
|
519
547
|
if task_parser is None:
|
camel/toolkits/__init__.py
CHANGED
|
@@ -78,7 +78,10 @@ from .playwright_mcp_toolkit import PlaywrightMCPToolkit
|
|
|
78
78
|
from .wolfram_alpha_toolkit import WolframAlphaToolkit
|
|
79
79
|
from .task_planning_toolkit import TaskPlanningToolkit
|
|
80
80
|
from .non_visual_browser_toolkit import BrowserNonVisualToolkit
|
|
81
|
-
|
|
81
|
+
from .edgeone_pages_mcp_toolkit import EdgeOnePagesMCPToolkit
|
|
82
|
+
from .google_drive_mcp_toolkit import GoogleDriveMCPToolkit
|
|
83
|
+
from .craw4ai_toolkit import Crawl4AIToolkit
|
|
84
|
+
from .markitdown_toolkit import MarkItDownToolkit
|
|
82
85
|
|
|
83
86
|
__all__ = [
|
|
84
87
|
'BaseToolkit',
|
|
@@ -144,4 +147,8 @@ __all__ = [
|
|
|
144
147
|
'BohriumToolkit',
|
|
145
148
|
'TaskPlanningToolkit',
|
|
146
149
|
'BrowserNonVisualToolkit',
|
|
150
|
+
'EdgeOnePagesMCPToolkit',
|
|
151
|
+
'GoogleDriveMCPToolkit',
|
|
152
|
+
'Crawl4AIToolkit',
|
|
153
|
+
'MarkItDownToolkit',
|
|
147
154
|
]
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
from typing import List, Optional
|
|
16
|
+
|
|
17
|
+
from camel.logger import get_logger
|
|
18
|
+
from camel.toolkits.base import BaseToolkit
|
|
19
|
+
from camel.toolkits.function_tool import FunctionTool
|
|
20
|
+
from camel.utils import MCPServer
|
|
21
|
+
|
|
22
|
+
logger = get_logger(__name__)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@MCPServer()
|
|
26
|
+
class Crawl4AIToolkit(BaseToolkit):
|
|
27
|
+
r"""A class representing a toolkit for Crawl4AI."""
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
timeout: Optional[float] = None,
|
|
32
|
+
):
|
|
33
|
+
super().__init__(timeout=timeout)
|
|
34
|
+
|
|
35
|
+
async def scrape(self, url: str) -> str:
|
|
36
|
+
r"""Scrapes a webpage and returns its content.
|
|
37
|
+
|
|
38
|
+
This function is designed to fetch the content of a given URL and
|
|
39
|
+
return it as a single string. It's particularly useful for extracting
|
|
40
|
+
text from web pages for further processing. The function
|
|
41
|
+
will try to get the most meaningful content from the page.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
url (str): The URL of the webpage to scrape.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
str: The scraped content of the webpage as a string. If the
|
|
48
|
+
scraping fails, it will return an error message.
|
|
49
|
+
"""
|
|
50
|
+
from crawl4ai import AsyncWebCrawler, CrawlerRunConfig
|
|
51
|
+
|
|
52
|
+
try:
|
|
53
|
+
async with AsyncWebCrawler() as client:
|
|
54
|
+
config = CrawlerRunConfig(
|
|
55
|
+
only_text=True,
|
|
56
|
+
)
|
|
57
|
+
content = await client.arun(url, crawler_config=config)
|
|
58
|
+
return str(content.markdown) if content.markdown else ""
|
|
59
|
+
except Exception as e:
|
|
60
|
+
logger.error(f"Error scraping {url}: {e}")
|
|
61
|
+
return f"Error scraping {url}: {e}"
|
|
62
|
+
|
|
63
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
64
|
+
r"""Returns a list of FunctionTool objects representing the
|
|
65
|
+
functions in the toolkit.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
List[FunctionTool]: A list of FunctionTool objects
|
|
69
|
+
representing the functions in the toolkit.
|
|
70
|
+
"""
|
|
71
|
+
return [
|
|
72
|
+
FunctionTool(self.scrape),
|
|
73
|
+
]
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
from typing import List, Optional
|
|
16
|
+
|
|
17
|
+
from camel.toolkits import BaseToolkit, FunctionTool
|
|
18
|
+
|
|
19
|
+
from .mcp_toolkit import MCPToolkit
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class EdgeOnePagesMCPToolkit(BaseToolkit):
|
|
23
|
+
r"""EdgeOnePagesMCPToolkit provides an interface for interacting with
|
|
24
|
+
EdgeOne pages using the EdgeOne Pages MCP server.
|
|
25
|
+
|
|
26
|
+
Attributes:
|
|
27
|
+
timeout (Optional[float]): Connection timeout in seconds.
|
|
28
|
+
(default: :obj:`None`)
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(
|
|
32
|
+
self,
|
|
33
|
+
timeout: Optional[float] = None,
|
|
34
|
+
) -> None:
|
|
35
|
+
r"""Initializes the EdgeOnePagesMCPToolkit.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
timeout (Optional[float]): Connection timeout in seconds.
|
|
39
|
+
(default: :obj:`None`)
|
|
40
|
+
"""
|
|
41
|
+
super().__init__(timeout=timeout)
|
|
42
|
+
|
|
43
|
+
self._mcp_toolkit = MCPToolkit(
|
|
44
|
+
config_dict={
|
|
45
|
+
"mcpServers": {
|
|
46
|
+
"edgeone-pages-mcp-server": {
|
|
47
|
+
"command": "npx",
|
|
48
|
+
"args": ["edgeone-pages-mcp"],
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
timeout=timeout,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
async def connect(self):
|
|
56
|
+
r"""Explicitly connect to the EdgeOne Pages MCP server."""
|
|
57
|
+
await self._mcp_toolkit.connect()
|
|
58
|
+
|
|
59
|
+
async def disconnect(self):
|
|
60
|
+
r"""Explicitly disconnect from the EdgeOne Pages MCP server."""
|
|
61
|
+
await self._mcp_toolkit.disconnect()
|
|
62
|
+
|
|
63
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
64
|
+
r"""Returns a list of tools provided by the EdgeOnePagesMCPToolkit.
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
List[FunctionTool]: List of available tools.
|
|
68
|
+
"""
|
|
69
|
+
return self._mcp_toolkit.get_tools()
|