camel-ai 0.2.76a4__py3-none-any.whl → 0.2.76a5__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 +276 -21
- camel/configs/__init__.py +3 -0
- camel/configs/cometapi_config.py +104 -0
- camel/interpreters/docker/Dockerfile +3 -12
- camel/memories/blocks/chat_history_block.py +4 -1
- camel/memories/records.py +52 -8
- camel/messages/base.py +1 -1
- camel/models/__init__.py +2 -0
- camel/models/cometapi_model.py +83 -0
- camel/models/model_factory.py +2 -0
- camel/retrievers/auto_retriever.py +1 -0
- camel/societies/workforce/workforce.py +9 -7
- camel/storages/key_value_storages/json.py +15 -2
- camel/storages/vectordb_storages/tidb.py +8 -6
- camel/toolkits/__init__.py +4 -0
- camel/toolkits/dingtalk.py +1135 -0
- camel/toolkits/edgeone_pages_mcp_toolkit.py +11 -31
- camel/toolkits/google_drive_mcp_toolkit.py +12 -31
- camel/toolkits/message_integration.py +3 -0
- 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/terminal_toolkit/__init__.py +18 -0
- camel/toolkits/terminal_toolkit/terminal_toolkit.py +909 -0
- camel/toolkits/terminal_toolkit/utils.py +580 -0
- camel/types/enums.py +109 -0
- camel/types/unified_model_type.py +5 -0
- camel/utils/commons.py +2 -0
- {camel_ai-0.2.76a4.dist-info → camel_ai-0.2.76a5.dist-info}/METADATA +25 -6
- {camel_ai-0.2.76a4.dist-info → camel_ai-0.2.76a5.dist-info}/RECORD +34 -28
- camel/toolkits/terminal_toolkit.py +0 -1798
- {camel_ai-0.2.76a4.dist-info → camel_ai-0.2.76a5.dist-info}/WHEEL +0 -0
- {camel_ai-0.2.76a4.dist-info → camel_ai-0.2.76a5.dist-info}/licenses/LICENSE +0 -0
|
@@ -12,14 +12,12 @@
|
|
|
12
12
|
# limitations under the License.
|
|
13
13
|
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
14
|
|
|
15
|
-
from typing import
|
|
16
|
-
|
|
17
|
-
from camel.toolkits import BaseToolkit, FunctionTool
|
|
15
|
+
from typing import Optional
|
|
18
16
|
|
|
19
17
|
from .mcp_toolkit import MCPToolkit
|
|
20
18
|
|
|
21
19
|
|
|
22
|
-
class EdgeOnePagesMCPToolkit(
|
|
20
|
+
class EdgeOnePagesMCPToolkit(MCPToolkit):
|
|
23
21
|
r"""EdgeOnePagesMCPToolkit provides an interface for interacting with
|
|
24
22
|
EdgeOne pages using the EdgeOne Pages MCP server.
|
|
25
23
|
|
|
@@ -38,32 +36,14 @@ class EdgeOnePagesMCPToolkit(BaseToolkit):
|
|
|
38
36
|
timeout (Optional[float]): Connection timeout in seconds.
|
|
39
37
|
(default: :obj:`None`)
|
|
40
38
|
"""
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"edgeone-pages-mcp-server": {
|
|
47
|
-
"command": "npx",
|
|
48
|
-
"args": ["edgeone-pages-mcp"],
|
|
49
|
-
}
|
|
39
|
+
config_dict = {
|
|
40
|
+
"mcpServers": {
|
|
41
|
+
"edgeone-pages-mcp-server": {
|
|
42
|
+
"command": "npx",
|
|
43
|
+
"args": ["edgeone-pages-mcp"],
|
|
50
44
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
async def connect(self):
|
|
56
|
-
r"""Explicitly connect to the EdgeOne Pages MCP server."""
|
|
57
|
-
await self._mcp_toolkit.connect()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
58
47
|
|
|
59
|
-
|
|
60
|
-
|
|
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()
|
|
48
|
+
# Initialize parent MCPToolkit with EdgeOne Pages configuration
|
|
49
|
+
super().__init__(config_dict=config_dict, timeout=timeout)
|
|
@@ -12,14 +12,12 @@
|
|
|
12
12
|
# limitations under the License.
|
|
13
13
|
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
14
|
|
|
15
|
-
from typing import
|
|
16
|
-
|
|
17
|
-
from camel.toolkits import BaseToolkit, FunctionTool
|
|
15
|
+
from typing import Optional
|
|
18
16
|
|
|
19
17
|
from .mcp_toolkit import MCPToolkit
|
|
20
18
|
|
|
21
19
|
|
|
22
|
-
class GoogleDriveMCPToolkit(
|
|
20
|
+
class GoogleDriveMCPToolkit(MCPToolkit):
|
|
23
21
|
r"""GoogleDriveMCPToolkit provides an interface for interacting with
|
|
24
22
|
Google Drive using the Google Drive MCP server.
|
|
25
23
|
|
|
@@ -41,33 +39,16 @@ class GoogleDriveMCPToolkit(BaseToolkit):
|
|
|
41
39
|
credentials_path (Optional[str]): Path to the Google Drive
|
|
42
40
|
credentials file. (default: :obj:`None`)
|
|
43
41
|
"""
|
|
44
|
-
super().__init__(timeout=timeout)
|
|
45
42
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"env": {"GDRIVE_CREDENTIALS_PATH": credentials_path},
|
|
53
|
-
}
|
|
43
|
+
config_dict = {
|
|
44
|
+
"mcpServers": {
|
|
45
|
+
"gdrive": {
|
|
46
|
+
"command": "npx",
|
|
47
|
+
"args": ["-y", "@modelcontextprotocol/server-gdrive"],
|
|
48
|
+
"env": {"GDRIVE_CREDENTIALS_PATH": credentials_path},
|
|
54
49
|
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
async def connect(self):
|
|
60
|
-
r"""Explicitly connect to the Google Drive MCP server."""
|
|
61
|
-
await self._mcp_toolkit.connect()
|
|
62
|
-
|
|
63
|
-
async def disconnect(self):
|
|
64
|
-
r"""Explicitly disconnect from the Google Drive MCP server."""
|
|
65
|
-
await self._mcp_toolkit.disconnect()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
66
52
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Returns:
|
|
71
|
-
List[FunctionTool]: List of available tools.
|
|
72
|
-
"""
|
|
73
|
-
return self._mcp_toolkit.get_tools()
|
|
53
|
+
# Initialize parent MCPToolkit with Playwright configuration
|
|
54
|
+
super().__init__(config_dict=config_dict, timeout=timeout)
|
|
@@ -464,6 +464,9 @@ class ToolkitMessageIntegration:
|
|
|
464
464
|
# Apply the new signature to the wrapper
|
|
465
465
|
wrapper.__signature__ = new_sig # type: ignore[attr-defined]
|
|
466
466
|
|
|
467
|
+
# Mark this function as enhanced by message integration
|
|
468
|
+
wrapper.__message_integration_enhanced__ = True # type: ignore[attr-defined]
|
|
469
|
+
|
|
467
470
|
# Create a hybrid approach:
|
|
468
471
|
# store toolkit instance info but preserve calling behavior
|
|
469
472
|
# We'll use a property-like
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
|
|
15
15
|
from typing import Any, ClassVar, Dict, List, Optional, Set
|
|
16
16
|
|
|
17
|
-
from camel.toolkits import
|
|
17
|
+
from camel.toolkits import FunctionTool
|
|
18
18
|
|
|
19
19
|
from .mcp_toolkit import MCPToolkit
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
class NotionMCPToolkit(
|
|
22
|
+
class NotionMCPToolkit(MCPToolkit):
|
|
23
23
|
r"""NotionMCPToolkit provides an interface for interacting with Notion
|
|
24
24
|
through the Model Context Protocol (MCP).
|
|
25
25
|
|
|
@@ -75,31 +75,21 @@ class NotionMCPToolkit(BaseToolkit):
|
|
|
75
75
|
timeout (Optional[float]): Connection timeout in seconds.
|
|
76
76
|
(default: :obj:`None`)
|
|
77
77
|
"""
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
"mcp-remote",
|
|
88
|
-
"https://mcp.notion.com/mcp",
|
|
89
|
-
],
|
|
90
|
-
}
|
|
78
|
+
config_dict = {
|
|
79
|
+
"mcpServers": {
|
|
80
|
+
"notionMCP": {
|
|
81
|
+
"command": "npx",
|
|
82
|
+
"args": [
|
|
83
|
+
"-y",
|
|
84
|
+
"mcp-remote",
|
|
85
|
+
"https://mcp.notion.com/mcp",
|
|
86
|
+
],
|
|
91
87
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
async def connect(self):
|
|
97
|
-
r"""Explicitly connect to the Notion MCP server."""
|
|
98
|
-
await self._mcp_toolkit.connect()
|
|
88
|
+
}
|
|
89
|
+
}
|
|
99
90
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
await self._mcp_toolkit.disconnect()
|
|
91
|
+
# Initialize parent MCPToolkit with Notion configuration
|
|
92
|
+
super().__init__(config_dict=config_dict, timeout=timeout)
|
|
103
93
|
|
|
104
94
|
def get_tools(self) -> List[FunctionTool]:
|
|
105
95
|
r"""Returns a list of tools provided by the NotionMCPToolkit.
|
|
@@ -108,7 +98,7 @@ class NotionMCPToolkit(BaseToolkit):
|
|
|
108
98
|
List[FunctionTool]: List of available tools.
|
|
109
99
|
"""
|
|
110
100
|
all_tools = []
|
|
111
|
-
for client in self.
|
|
101
|
+
for client in self.clients:
|
|
112
102
|
try:
|
|
113
103
|
original_build_schema = client._build_tool_schema
|
|
114
104
|
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
# limitations under the License.
|
|
13
13
|
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
14
|
|
|
15
|
-
from typing import Dict,
|
|
15
|
+
from typing import Dict, Optional
|
|
16
16
|
|
|
17
|
-
from
|
|
17
|
+
from .mcp_toolkit import MCPToolkit
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
class OrigeneToolkit(
|
|
20
|
+
class OrigeneToolkit(MCPToolkit):
|
|
21
21
|
r"""OrigeneToolkit provides an interface for interacting with
|
|
22
22
|
Origene MCP server.
|
|
23
23
|
|
|
@@ -43,55 +43,14 @@ class OrigeneToolkit(BaseToolkit):
|
|
|
43
43
|
|
|
44
44
|
Args:
|
|
45
45
|
config_dict (Optional[Dict]): Configuration dictionary for MCP
|
|
46
|
-
servers. If None,
|
|
47
|
-
(default: :obj:`None`)
|
|
46
|
+
servers. If None, raises ValueError as configuration is
|
|
47
|
+
required. (default: :obj:`None`)
|
|
48
48
|
timeout (Optional[float]): Connection timeout in seconds.
|
|
49
49
|
(default: :obj:`None`)
|
|
50
50
|
"""
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
# Use default configuration if none provided
|
|
51
|
+
# Validate that config_dict is provided
|
|
54
52
|
if config_dict is None:
|
|
55
53
|
raise ValueError("config_dict must be provided")
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
timeout=timeout,
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
async def connect(self):
|
|
63
|
-
r"""Explicitly connect to the Origene MCP server."""
|
|
64
|
-
await self._mcp_toolkit.connect()
|
|
65
|
-
|
|
66
|
-
async def disconnect(self):
|
|
67
|
-
r"""Explicitly disconnect from the Origene MCP server."""
|
|
68
|
-
await self._mcp_toolkit.disconnect()
|
|
69
|
-
|
|
70
|
-
async def __aenter__(self) -> "OrigeneToolkit":
|
|
71
|
-
r"""Async context manager entry point.
|
|
72
|
-
|
|
73
|
-
Returns:
|
|
74
|
-
OrigeneToolkit: The connected toolkit instance.
|
|
75
|
-
|
|
76
|
-
Example:
|
|
77
|
-
async with OrigeneToolkit(config_dict=config) as toolkit:
|
|
78
|
-
tools = toolkit.get_tools()
|
|
79
|
-
"""
|
|
80
|
-
await self.connect()
|
|
81
|
-
return self
|
|
82
|
-
|
|
83
|
-
async def __aexit__(self, exc_type, exc_val, exc_tb) -> None:
|
|
84
|
-
r"""Async context manager exit point.
|
|
85
|
-
|
|
86
|
-
Automatically disconnects from the Origene MCP server.
|
|
87
|
-
"""
|
|
88
|
-
await self.disconnect()
|
|
89
|
-
return None
|
|
90
|
-
|
|
91
|
-
def get_tools(self) -> List[FunctionTool]:
|
|
92
|
-
r"""Returns a list of tools provided by the Origene MCP server.
|
|
93
|
-
|
|
94
|
-
Returns:
|
|
95
|
-
List[FunctionTool]: List of available tools.
|
|
96
|
-
"""
|
|
97
|
-
return self._mcp_toolkit.get_tools()
|
|
55
|
+
# Initialize parent MCPToolkit with provided configuration
|
|
56
|
+
super().__init__(config_dict=config_dict, timeout=timeout)
|
|
@@ -14,12 +14,10 @@
|
|
|
14
14
|
|
|
15
15
|
from typing import List, Optional
|
|
16
16
|
|
|
17
|
-
from camel.toolkits import BaseToolkit, FunctionTool
|
|
18
|
-
|
|
19
17
|
from .mcp_toolkit import MCPToolkit
|
|
20
18
|
|
|
21
19
|
|
|
22
|
-
class PlaywrightMCPToolkit(
|
|
20
|
+
class PlaywrightMCPToolkit(MCPToolkit):
|
|
23
21
|
r"""PlaywrightMCPToolkit provides an interface for interacting with web
|
|
24
22
|
browsers using the Playwright automation library through the Model Context
|
|
25
23
|
Protocol (MCP).
|
|
@@ -51,33 +49,16 @@ class PlaywrightMCPToolkit(BaseToolkit):
|
|
|
51
49
|
`["--cdp-endpoint=http://localhost:9222"]`.
|
|
52
50
|
(default: :obj:`None`)
|
|
53
51
|
"""
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
"args": ["@playwright/mcp@latest"]
|
|
62
|
-
+ (additional_args or []),
|
|
63
|
-
}
|
|
52
|
+
# Create config for Playwright MCP server
|
|
53
|
+
config_dict = {
|
|
54
|
+
"mcpServers": {
|
|
55
|
+
"playwright": {
|
|
56
|
+
"command": "npx",
|
|
57
|
+
"args": ["@playwright/mcp@latest"]
|
|
58
|
+
+ (additional_args or []),
|
|
64
59
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
async def connect(self):
|
|
70
|
-
r"""Explicitly connect to the Playwright MCP server."""
|
|
71
|
-
await self._mcp_toolkit.connect()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
72
62
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
await self._mcp_toolkit.disconnect()
|
|
76
|
-
|
|
77
|
-
def get_tools(self) -> List[FunctionTool]:
|
|
78
|
-
r"""Returns a list of tools provided by the PlaywrightMCPToolkit.
|
|
79
|
-
|
|
80
|
-
Returns:
|
|
81
|
-
List[FunctionTool]: List of available tools.
|
|
82
|
-
"""
|
|
83
|
-
return self._mcp_toolkit.get_tools()
|
|
63
|
+
# Initialize parent MCPToolkit with Playwright configuration
|
|
64
|
+
super().__init__(config_dict=config_dict, timeout=timeout)
|
|
@@ -0,0 +1,168 @@
|
|
|
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 Dict, List, Optional, cast
|
|
16
|
+
|
|
17
|
+
from camel.toolkits.base import BaseToolkit
|
|
18
|
+
from camel.toolkits.function_tool import FunctionTool
|
|
19
|
+
from camel.utils import MCPServer, api_keys_required
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@MCPServer()
|
|
23
|
+
class ResendToolkit(BaseToolkit):
|
|
24
|
+
r"""A toolkit for sending emails using the Resend API.
|
|
25
|
+
|
|
26
|
+
This toolkit provides functionality to send emails using Resend's
|
|
27
|
+
Python SDK.It supports sending both HTML and plain text emails,
|
|
28
|
+
with options for multiple recipients, CC, BCC, reply-to
|
|
29
|
+
addresses, and custom headers.
|
|
30
|
+
|
|
31
|
+
Notes:
|
|
32
|
+
To use this toolkit, you need to set the following environment
|
|
33
|
+
variable:
|
|
34
|
+
- RESEND_API_KEY: Your Resend API key. You can get one from
|
|
35
|
+
https://resend.com/api-keys
|
|
36
|
+
|
|
37
|
+
Example:
|
|
38
|
+
.. code-block:: python
|
|
39
|
+
|
|
40
|
+
from camel.toolkits import ResendToolkit
|
|
41
|
+
|
|
42
|
+
# Initialize the toolkit
|
|
43
|
+
toolkit = ResendToolkit()
|
|
44
|
+
|
|
45
|
+
# Get tools
|
|
46
|
+
tools = toolkit.get_tools()
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
@api_keys_required([(None, "RESEND_API_KEY")])
|
|
50
|
+
def send_email(
|
|
51
|
+
self,
|
|
52
|
+
to: List[str],
|
|
53
|
+
subject: str,
|
|
54
|
+
from_email: str,
|
|
55
|
+
html: Optional[str] = None,
|
|
56
|
+
text: Optional[str] = None,
|
|
57
|
+
cc: Optional[List[str]] = None,
|
|
58
|
+
bcc: Optional[List[str]] = None,
|
|
59
|
+
reply_to: Optional[str] = None,
|
|
60
|
+
tags: Optional[List[Dict[str, str]]] = None,
|
|
61
|
+
headers: Optional[Dict[str, str]] = None,
|
|
62
|
+
) -> str:
|
|
63
|
+
r"""Send an email using the Resend API.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
to (List[str]): List of recipient email addresses.
|
|
67
|
+
subject (str): The email subject line.
|
|
68
|
+
from_email (str): The sender email address. Must be from a verified
|
|
69
|
+
domain.
|
|
70
|
+
html (Optional[str]): The HTML content of the email. Either html or
|
|
71
|
+
text must be provided. (default: :obj:`None`)
|
|
72
|
+
text (Optional[str]): The plain text content of the email. Either
|
|
73
|
+
html or text must be provided. (default: :obj:`None`)
|
|
74
|
+
cc (Optional[List[str]]): List of CC recipient email addresses.
|
|
75
|
+
(default: :obj:`None`)
|
|
76
|
+
bcc (Optional[List[str]]): List of BCC recipient email addresses.
|
|
77
|
+
(default: :obj:`None`)
|
|
78
|
+
reply_to (Optional[str]): The reply-to email address.
|
|
79
|
+
(default: :obj:`None`)
|
|
80
|
+
tags (Optional[List[Dict[str, str]]]): List of tags to attach to
|
|
81
|
+
the email. Each tag should be a dict with 'name' and
|
|
82
|
+
'value' keys. (default: :obj:`None`)
|
|
83
|
+
headers (Optional[Dict[str, str]]): Custom headers to include in
|
|
84
|
+
the email.(default: :obj:`None`)
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
str: A success message with the email ID if sent successfully,
|
|
88
|
+
or an error message if the send failed.
|
|
89
|
+
|
|
90
|
+
Raises:
|
|
91
|
+
ValueError: If neither html nor text content is provided.
|
|
92
|
+
|
|
93
|
+
Example:
|
|
94
|
+
.. code-block:: python
|
|
95
|
+
|
|
96
|
+
toolkit = ResendToolkit()
|
|
97
|
+
result = toolkit.send_email(
|
|
98
|
+
to=["recipient@example.com"],
|
|
99
|
+
subject="Hello World",
|
|
100
|
+
from_email="sender@yourdomain.com",
|
|
101
|
+
html="<h1>Hello, World!</h1>",
|
|
102
|
+
text="Hello, World!"
|
|
103
|
+
)
|
|
104
|
+
"""
|
|
105
|
+
import os
|
|
106
|
+
|
|
107
|
+
if not html and not text:
|
|
108
|
+
raise ValueError(
|
|
109
|
+
"Either 'html' or 'text' content must be provided"
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
try:
|
|
113
|
+
import resend
|
|
114
|
+
except ImportError:
|
|
115
|
+
raise ImportError(
|
|
116
|
+
"Please install the resend package first. "
|
|
117
|
+
"You can install it by running `pip install resend`."
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
# Set the API key
|
|
121
|
+
resend.api_key = os.getenv("RESEND_API_KEY")
|
|
122
|
+
|
|
123
|
+
# Prepare email parameters
|
|
124
|
+
params: resend.Emails.SendParams = {
|
|
125
|
+
"from": from_email,
|
|
126
|
+
"to": to,
|
|
127
|
+
"subject": subject,
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# Add content
|
|
131
|
+
if html:
|
|
132
|
+
params["html"] = html
|
|
133
|
+
if text:
|
|
134
|
+
params["text"] = text
|
|
135
|
+
|
|
136
|
+
# Add optional parameters
|
|
137
|
+
if cc:
|
|
138
|
+
params["cc"] = cc
|
|
139
|
+
if bcc:
|
|
140
|
+
params["bcc"] = bcc
|
|
141
|
+
if reply_to:
|
|
142
|
+
params["reply_to"] = reply_to
|
|
143
|
+
if tags:
|
|
144
|
+
params["tags"] = cast('list[resend.emails._tag.Tag]', tags)
|
|
145
|
+
if headers:
|
|
146
|
+
params["headers"] = headers
|
|
147
|
+
|
|
148
|
+
try:
|
|
149
|
+
# Send the email
|
|
150
|
+
email = resend.Emails.send(params)
|
|
151
|
+
return (
|
|
152
|
+
f"Email sent successfully. "
|
|
153
|
+
f"Email ID: {email.get('id', 'Unknown')}"
|
|
154
|
+
)
|
|
155
|
+
except Exception as e:
|
|
156
|
+
return f"Failed to send email: {e!s}"
|
|
157
|
+
|
|
158
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
159
|
+
r"""Returns a list of FunctionTool objects representing the
|
|
160
|
+
functions in the toolkit.
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
List[FunctionTool]: A list of FunctionTool objects
|
|
164
|
+
representing the functions in the toolkit.
|
|
165
|
+
"""
|
|
166
|
+
return [
|
|
167
|
+
FunctionTool(self.send_email),
|
|
168
|
+
]
|
|
@@ -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 .terminal_toolkit import TerminalToolkit
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"TerminalToolkit",
|
|
18
|
+
]
|