camel-ai 0.2.61__py3-none-any.whl → 0.2.62__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 +1 -1
- camel/agents/mcp_agent.py +5 -5
- camel/{data_collector → data_collectors}/alpaca_collector.py +1 -1
- camel/{data_collector → data_collectors}/sharegpt_collector.py +1 -1
- camel/retrievers/auto_retriever.py +20 -1
- camel/{runtime → runtimes}/daytona_runtime.py +1 -1
- camel/{runtime → runtimes}/docker_runtime.py +1 -1
- camel/{runtime → runtimes}/llm_guard_runtime.py +2 -2
- camel/{runtime → runtimes}/remote_http_runtime.py +1 -1
- camel/{runtime → runtimes}/ubuntu_docker_runtime.py +1 -1
- camel/societies/workforce/base.py +7 -3
- camel/societies/workforce/single_agent_worker.py +2 -1
- camel/societies/workforce/worker.py +5 -3
- camel/toolkits/__init__.py +2 -0
- camel/toolkits/file_write_toolkit.py +4 -2
- camel/toolkits/mcp_toolkit.py +469 -733
- camel/toolkits/pptx_toolkit.py +777 -0
- camel/utils/mcp_client.py +979 -0
- {camel_ai-0.2.61.dist-info → camel_ai-0.2.62.dist-info}/METADATA +4 -1
- {camel_ai-0.2.61.dist-info → camel_ai-0.2.62.dist-info}/RECORD +32 -30
- /camel/{data_collector → data_collectors}/__init__.py +0 -0
- /camel/{data_collector → data_collectors}/base.py +0 -0
- /camel/{runtime → runtimes}/__init__.py +0 -0
- /camel/{runtime → runtimes}/api.py +0 -0
- /camel/{runtime → runtimes}/base.py +0 -0
- /camel/{runtime → runtimes}/configs.py +0 -0
- /camel/{runtime → runtimes}/utils/__init__.py +0 -0
- /camel/{runtime → runtimes}/utils/function_risk_toolkit.py +0 -0
- /camel/{runtime → runtimes}/utils/ignore_risk_toolkit.py +0 -0
- {camel_ai-0.2.61.dist-info → camel_ai-0.2.62.dist-info}/WHEEL +0 -0
- {camel_ai-0.2.61.dist-info → camel_ai-0.2.62.dist-info}/licenses/LICENSE +0 -0
camel/__init__.py
CHANGED
camel/agents/chat_agent.py
CHANGED
|
@@ -204,7 +204,7 @@ class ChatAgent(BaseAgent):
|
|
|
204
204
|
self.model_type = self.model_backend.model_type
|
|
205
205
|
|
|
206
206
|
# Assign unique ID
|
|
207
|
-
self.agent_id = agent_id if agent_id else str(uuid.uuid4())
|
|
207
|
+
self.agent_id = agent_id if agent_id else str(uuid.uuid4())[:6]
|
|
208
208
|
|
|
209
209
|
# Set up memory
|
|
210
210
|
context_creator = ScoreBasedContextCreator(
|
camel/agents/mcp_agent.py
CHANGED
|
@@ -191,7 +191,7 @@ class MCPAgent(ChatAgent):
|
|
|
191
191
|
self.mcp_toolkit = self._initialize_mcp_toolkit()
|
|
192
192
|
|
|
193
193
|
# If already connected, reconnect to apply changes
|
|
194
|
-
if self.mcp_toolkit and self.mcp_toolkit.is_connected
|
|
194
|
+
if self.mcp_toolkit and self.mcp_toolkit.is_connected:
|
|
195
195
|
try:
|
|
196
196
|
asyncio.run(self.disconnect())
|
|
197
197
|
asyncio.run(self.connect())
|
|
@@ -325,7 +325,7 @@ class MCPAgent(ChatAgent):
|
|
|
325
325
|
Returns:
|
|
326
326
|
ChatAgentResponse: The response from the agent.
|
|
327
327
|
"""
|
|
328
|
-
if self.mcp_toolkit and not self.mcp_toolkit.is_connected
|
|
328
|
+
if self.mcp_toolkit and not self.mcp_toolkit.is_connected:
|
|
329
329
|
await self.connect()
|
|
330
330
|
|
|
331
331
|
if self.function_calling_available:
|
|
@@ -378,14 +378,14 @@ class MCPAgent(ChatAgent):
|
|
|
378
378
|
if (
|
|
379
379
|
not isinstance(server_idx, int)
|
|
380
380
|
or server_idx < 0
|
|
381
|
-
or server_idx >= len(self.mcp_toolkit.
|
|
381
|
+
or server_idx >= len(self.mcp_toolkit.clients)
|
|
382
382
|
):
|
|
383
383
|
logger.warning(
|
|
384
384
|
f"Invalid server index: {server_idx}"
|
|
385
385
|
)
|
|
386
386
|
continue
|
|
387
387
|
|
|
388
|
-
server = self.mcp_toolkit.
|
|
388
|
+
server = self.mcp_toolkit.clients[server_idx]
|
|
389
389
|
result = await server.call_tool(tool_name, tool_args)
|
|
390
390
|
|
|
391
391
|
# Safely access content
|
|
@@ -431,7 +431,7 @@ class MCPAgent(ChatAgent):
|
|
|
431
431
|
# Use create_task and run with a future
|
|
432
432
|
coro = self.astep(input_message, *args, **kwargs)
|
|
433
433
|
future = asyncio.ensure_future(coro)
|
|
434
|
-
return asyncio.run_coroutine_threadsafe(future, loop).result()
|
|
434
|
+
return asyncio.run_coroutine_threadsafe(future, loop).result() # type: ignore [arg-type]
|
|
435
435
|
else:
|
|
436
436
|
# Safe to run normally
|
|
437
437
|
return asyncio.run(self.astep(input_message, *args, **kwargs))
|
|
@@ -17,7 +17,7 @@ from typing import Any, Dict, List, Optional, Union
|
|
|
17
17
|
from typing_extensions import Self
|
|
18
18
|
|
|
19
19
|
from camel.agents import ChatAgent
|
|
20
|
-
from camel.
|
|
20
|
+
from camel.data_collectors.base import BaseDataCollector
|
|
21
21
|
from camel.messages import AlpacaItem, BaseMessage
|
|
22
22
|
from camel.schemas import OpenAISchemaConverter
|
|
23
23
|
|
|
@@ -19,7 +19,7 @@ from pydantic import BaseModel
|
|
|
19
19
|
from typing_extensions import Self
|
|
20
20
|
|
|
21
21
|
from camel.agents import ChatAgent
|
|
22
|
-
from camel.
|
|
22
|
+
from camel.data_collectors.base import BaseDataCollector
|
|
23
23
|
from camel.messages import BaseMessage
|
|
24
24
|
from camel.messages.conversion.conversation_models import (
|
|
25
25
|
ShareGPTConversation,
|
|
@@ -128,12 +128,31 @@ class AutoRetriever:
|
|
|
128
128
|
Returns:
|
|
129
129
|
str: A sanitized, valid collection name suitable for use.
|
|
130
130
|
"""
|
|
131
|
+
import hashlib
|
|
132
|
+
import os
|
|
133
|
+
|
|
131
134
|
from unstructured.documents.elements import Element
|
|
132
135
|
|
|
133
136
|
if isinstance(content, Element):
|
|
134
137
|
content = content.metadata.file_directory or str(uuid.uuid4())
|
|
135
138
|
|
|
136
|
-
|
|
139
|
+
# For file paths, use a combination of directory hash and filename
|
|
140
|
+
if os.path.isfile(content):
|
|
141
|
+
# Get directory and filename
|
|
142
|
+
directory = os.path.dirname(content)
|
|
143
|
+
filename = os.path.basename(content)
|
|
144
|
+
# Create a short hash of the directory path
|
|
145
|
+
dir_hash = hashlib.md5(directory.encode()).hexdigest()[:6]
|
|
146
|
+
# Get filename without extension and remove special chars
|
|
147
|
+
base_name = os.path.splitext(filename)[0]
|
|
148
|
+
clean_name = re.sub(r'[^a-zA-Z0-9]', '', base_name)[:10]
|
|
149
|
+
# Combine for a unique name
|
|
150
|
+
collection_name = f"{clean_name}_{dir_hash}"
|
|
151
|
+
else:
|
|
152
|
+
# For URL content
|
|
153
|
+
content_hash = hashlib.md5(content.encode()).hexdigest()[:6]
|
|
154
|
+
clean_content = re.sub(r'[^a-zA-Z0-9]', '', content)[-10:]
|
|
155
|
+
collection_name = f"{clean_content}_{content_hash}"
|
|
137
156
|
|
|
138
157
|
# Ensure the first character is either an underscore or a letter for
|
|
139
158
|
# Milvus
|
|
@@ -21,7 +21,7 @@ from typing import Any, Dict, List, Optional, Union
|
|
|
21
21
|
from pydantic import BaseModel
|
|
22
22
|
|
|
23
23
|
from camel.logger import get_logger
|
|
24
|
-
from camel.
|
|
24
|
+
from camel.runtimes import BaseRuntime
|
|
25
25
|
from camel.toolkits.function_tool import FunctionTool
|
|
26
26
|
|
|
27
27
|
logger = get_logger(__name__)
|
|
@@ -19,8 +19,8 @@ from typing import List, Optional, Union
|
|
|
19
19
|
from camel.agents import ChatAgent
|
|
20
20
|
from camel.configs import ChatGPTConfig
|
|
21
21
|
from camel.models import BaseModelBackend, ModelFactory
|
|
22
|
-
from camel.
|
|
23
|
-
from camel.
|
|
22
|
+
from camel.runtimes import BaseRuntime
|
|
23
|
+
from camel.runtimes.utils import FunctionRiskToolkit, IgnoreRiskToolkit
|
|
24
24
|
from camel.toolkits import FunctionTool
|
|
25
25
|
from camel.types import ModelPlatformType, ModelType
|
|
26
26
|
|
|
@@ -24,7 +24,7 @@ from typing import Any, Dict, List, Optional, Union
|
|
|
24
24
|
import requests
|
|
25
25
|
from pydantic import BaseModel
|
|
26
26
|
|
|
27
|
-
from camel.
|
|
27
|
+
from camel.runtimes import BaseRuntime
|
|
28
28
|
from camel.toolkits.function_tool import FunctionTool
|
|
29
29
|
|
|
30
30
|
logger = logging.getLogger(__name__)
|
|
@@ -18,7 +18,7 @@ import time
|
|
|
18
18
|
from pathlib import Path
|
|
19
19
|
from typing import Callable, List, Optional, Union
|
|
20
20
|
|
|
21
|
-
from camel.
|
|
21
|
+
from camel.runtimes.docker_runtime import DockerRuntime
|
|
22
22
|
from camel.toolkits import FunctionTool
|
|
23
23
|
|
|
24
24
|
logger = logging.getLogger(__name__)
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# limitations under the License.
|
|
13
13
|
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
14
|
from abc import ABC, abstractmethod
|
|
15
|
-
from typing import Any
|
|
15
|
+
from typing import Any, Optional
|
|
16
16
|
|
|
17
17
|
from camel.societies.workforce.task_channel import TaskChannel
|
|
18
18
|
from camel.societies.workforce.utils import check_if_running
|
|
@@ -23,10 +23,14 @@ class BaseNode(ABC):
|
|
|
23
23
|
|
|
24
24
|
Args:
|
|
25
25
|
description (str): Description of the node.
|
|
26
|
+
node_id (Optional[str]): ID of the node. If not provided, it will
|
|
27
|
+
be generated automatically. (default: :obj:`None`)
|
|
26
28
|
"""
|
|
27
29
|
|
|
28
|
-
def __init__(
|
|
29
|
-
self
|
|
30
|
+
def __init__(
|
|
31
|
+
self, description: str, node_id: Optional[str] = None
|
|
32
|
+
) -> None:
|
|
33
|
+
self.node_id = node_id if node_id is not None else str(id(self))
|
|
30
34
|
self.description = description
|
|
31
35
|
self._channel: TaskChannel = TaskChannel()
|
|
32
36
|
self._running = False
|
|
@@ -15,7 +15,7 @@ from __future__ import annotations
|
|
|
15
15
|
|
|
16
16
|
import logging
|
|
17
17
|
from abc import ABC, abstractmethod
|
|
18
|
-
from typing import List
|
|
18
|
+
from typing import List, Optional
|
|
19
19
|
|
|
20
20
|
from colorama import Fore
|
|
21
21
|
|
|
@@ -33,14 +33,16 @@ class Worker(BaseNode, ABC):
|
|
|
33
33
|
|
|
34
34
|
Args:
|
|
35
35
|
description (str): Description of the node.
|
|
36
|
-
|
|
36
|
+
node_id (Optional[str]): ID of the node. If not provided, it will
|
|
37
|
+
be generated automatically. (default: :obj:`None`)
|
|
37
38
|
"""
|
|
38
39
|
|
|
39
40
|
def __init__(
|
|
40
41
|
self,
|
|
41
42
|
description: str,
|
|
43
|
+
node_id: Optional[str] = None,
|
|
42
44
|
) -> None:
|
|
43
|
-
super().__init__(description)
|
|
45
|
+
super().__init__(description, node_id=node_id)
|
|
44
46
|
|
|
45
47
|
def __repr__(self):
|
|
46
48
|
return f"Worker node {self.node_id} ({self.description})"
|
camel/toolkits/__init__.py
CHANGED
|
@@ -62,6 +62,7 @@ from .mcp_toolkit import MCPToolkit
|
|
|
62
62
|
from .browser_toolkit import BrowserToolkit
|
|
63
63
|
from .async_browser_toolkit import AsyncBrowserToolkit
|
|
64
64
|
from .file_write_toolkit import FileWriteToolkit
|
|
65
|
+
from .pptx_toolkit import PPTXToolkit
|
|
65
66
|
from .terminal_toolkit import TerminalToolkit
|
|
66
67
|
from .pubmed_toolkit import PubMedToolkit
|
|
67
68
|
from .data_commons_toolkit import DataCommonsToolkit
|
|
@@ -124,6 +125,7 @@ __all__ = [
|
|
|
124
125
|
'BrowserToolkit',
|
|
125
126
|
'AsyncBrowserToolkit',
|
|
126
127
|
'FileWriteToolkit',
|
|
128
|
+
'PPTXToolkit',
|
|
127
129
|
'TerminalToolkit',
|
|
128
130
|
'PubMedToolkit',
|
|
129
131
|
'DataCommonsToolkit',
|
|
@@ -338,8 +338,10 @@ class FileWriteToolkit(BaseToolkit):
|
|
|
338
338
|
|
|
339
339
|
Args:
|
|
340
340
|
content (Union[str, List[List[str]]]): The content to write to the
|
|
341
|
-
file.
|
|
342
|
-
|
|
341
|
+
file. Content format varies by file type:
|
|
342
|
+
- Text formats (txt, md, html, yaml): string
|
|
343
|
+
- CSV: string or list of lists
|
|
344
|
+
- JSON: string or serializable object
|
|
343
345
|
filename (str): The name or path of the file. If a relative path is
|
|
344
346
|
supplied, it is resolved to self.output_dir.
|
|
345
347
|
encoding (Optional[str]): The character encoding to use. (default:
|