camel-ai 0.2.3a1__py3-none-any.whl → 0.2.3a2__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 +93 -69
- camel/agents/knowledge_graph_agent.py +4 -6
- camel/bots/__init__.py +16 -2
- camel/bots/discord_app.py +138 -0
- camel/bots/slack/__init__.py +30 -0
- camel/bots/slack/models.py +158 -0
- camel/bots/slack/slack_app.py +255 -0
- camel/configs/__init__.py +1 -2
- camel/configs/anthropic_config.py +2 -5
- camel/configs/base_config.py +6 -6
- camel/configs/groq_config.py +2 -3
- camel/configs/ollama_config.py +1 -2
- camel/configs/openai_config.py +2 -23
- camel/configs/samba_config.py +2 -2
- camel/configs/togetherai_config.py +1 -1
- camel/configs/vllm_config.py +1 -1
- camel/configs/zhipuai_config.py +2 -3
- camel/embeddings/openai_embedding.py +2 -2
- camel/loaders/__init__.py +2 -0
- camel/loaders/chunkr_reader.py +163 -0
- camel/loaders/firecrawl_reader.py +3 -3
- camel/loaders/unstructured_io.py +35 -33
- camel/messages/__init__.py +1 -0
- camel/models/__init__.py +2 -4
- camel/models/anthropic_model.py +32 -26
- camel/models/azure_openai_model.py +39 -36
- camel/models/base_model.py +31 -20
- camel/models/gemini_model.py +37 -29
- camel/models/groq_model.py +29 -23
- camel/models/litellm_model.py +44 -61
- camel/models/mistral_model.py +32 -29
- camel/models/model_factory.py +66 -76
- camel/models/nemotron_model.py +33 -23
- camel/models/ollama_model.py +42 -47
- camel/models/{openai_compatibility_model.py → openai_compatible_model.py} +31 -49
- camel/models/openai_model.py +48 -29
- camel/models/reka_model.py +30 -28
- camel/models/samba_model.py +82 -177
- camel/models/stub_model.py +2 -2
- camel/models/togetherai_model.py +37 -43
- camel/models/vllm_model.py +43 -50
- camel/models/zhipuai_model.py +33 -27
- camel/retrievers/auto_retriever.py +28 -10
- camel/retrievers/vector_retriever.py +58 -47
- camel/societies/babyagi_playing.py +6 -3
- camel/societies/role_playing.py +5 -3
- camel/storages/graph_storages/graph_element.py +3 -5
- camel/storages/key_value_storages/json.py +6 -1
- camel/toolkits/__init__.py +20 -7
- camel/toolkits/arxiv_toolkit.py +155 -0
- camel/toolkits/ask_news_toolkit.py +653 -0
- camel/toolkits/base.py +2 -3
- camel/toolkits/code_execution.py +6 -7
- camel/toolkits/dalle_toolkit.py +6 -6
- camel/toolkits/{openai_function.py → function_tool.py} +34 -11
- camel/toolkits/github_toolkit.py +9 -10
- camel/toolkits/google_maps_toolkit.py +7 -7
- camel/toolkits/google_scholar_toolkit.py +146 -0
- camel/toolkits/linkedin_toolkit.py +7 -7
- camel/toolkits/math_toolkit.py +8 -8
- camel/toolkits/open_api_toolkit.py +5 -5
- camel/toolkits/reddit_toolkit.py +7 -7
- camel/toolkits/retrieval_toolkit.py +5 -5
- camel/toolkits/search_toolkit.py +9 -9
- camel/toolkits/slack_toolkit.py +11 -11
- camel/toolkits/twitter_toolkit.py +378 -452
- camel/toolkits/weather_toolkit.py +6 -6
- camel/toolkits/whatsapp_toolkit.py +177 -0
- camel/types/__init__.py +6 -1
- camel/types/enums.py +40 -85
- camel/types/openai_types.py +3 -0
- camel/types/unified_model_type.py +104 -0
- camel/utils/__init__.py +0 -2
- camel/utils/async_func.py +7 -7
- camel/utils/commons.py +32 -3
- camel/utils/token_counting.py +30 -212
- camel/workforce/role_playing_worker.py +1 -1
- camel/workforce/single_agent_worker.py +1 -1
- camel/workforce/task_channel.py +4 -3
- camel/workforce/workforce.py +4 -4
- camel_ai-0.2.3a2.dist-info/LICENSE +201 -0
- {camel_ai-0.2.3a1.dist-info → camel_ai-0.2.3a2.dist-info}/METADATA +27 -56
- {camel_ai-0.2.3a1.dist-info → camel_ai-0.2.3a2.dist-info}/RECORD +85 -76
- {camel_ai-0.2.3a1.dist-info → camel_ai-0.2.3a2.dist-info}/WHEEL +1 -1
- camel/bots/discord_bot.py +0 -206
- camel/models/open_source_model.py +0 -170
camel/toolkits/dalle_toolkit.py
CHANGED
|
@@ -20,7 +20,7 @@ from typing import List, Optional
|
|
|
20
20
|
from openai import OpenAI
|
|
21
21
|
from PIL import Image
|
|
22
22
|
|
|
23
|
-
from camel.toolkits import
|
|
23
|
+
from camel.toolkits import FunctionTool
|
|
24
24
|
from camel.toolkits.base import BaseToolkit
|
|
25
25
|
|
|
26
26
|
|
|
@@ -132,15 +132,15 @@ class DalleToolkit(BaseToolkit):
|
|
|
132
132
|
|
|
133
133
|
return image_path
|
|
134
134
|
|
|
135
|
-
def get_tools(self) -> List[
|
|
136
|
-
r"""Returns a list of
|
|
135
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
136
|
+
r"""Returns a list of FunctionTool objects representing the
|
|
137
137
|
functions in the toolkit.
|
|
138
138
|
|
|
139
139
|
Returns:
|
|
140
|
-
List[
|
|
140
|
+
List[FunctionTool]: A list of FunctionTool objects
|
|
141
141
|
representing the functions in the toolkit.
|
|
142
142
|
"""
|
|
143
|
-
return [
|
|
143
|
+
return [FunctionTool(self.get_dalle_img)]
|
|
144
144
|
|
|
145
145
|
|
|
146
|
-
DALLE_FUNCS: List[
|
|
146
|
+
DALLE_FUNCS: List[FunctionTool] = DalleToolkit().get_tools()
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
# See the License for the specific language governing permissions and
|
|
12
12
|
# limitations under the License.
|
|
13
13
|
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
|
|
14
|
+
import warnings
|
|
14
15
|
from inspect import Parameter, signature
|
|
15
16
|
from typing import Any, Callable, Dict, Mapping, Optional, Tuple
|
|
16
17
|
|
|
@@ -142,7 +143,7 @@ def get_openai_tool_schema(func: Callable) -> Dict[str, Any]:
|
|
|
142
143
|
return openai_tool_schema
|
|
143
144
|
|
|
144
145
|
|
|
145
|
-
class
|
|
146
|
+
class FunctionTool:
|
|
146
147
|
r"""An abstraction of a function that OpenAI chat models can call. See
|
|
147
148
|
https://platform.openai.com/docs/api-reference/chat/create.
|
|
148
149
|
|
|
@@ -184,17 +185,18 @@ class OpenAIFunction:
|
|
|
184
185
|
Raises:
|
|
185
186
|
ValidationError: If the schema does not comply with the
|
|
186
187
|
specifications.
|
|
187
|
-
ValueError: If the function description or parameter descriptions
|
|
188
|
-
are missing in the schema.
|
|
189
188
|
SchemaError: If the parameters do not meet JSON Schema reference
|
|
190
189
|
specifications.
|
|
191
190
|
"""
|
|
192
191
|
# Check the type
|
|
193
192
|
if not openai_tool_schema["type"]:
|
|
194
|
-
raise ValueError("miss type")
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
raise ValueError("miss `type` in tool schema.")
|
|
194
|
+
|
|
195
|
+
# Check the function description, if no description then raise warming
|
|
196
|
+
if not openai_tool_schema["function"].get("description"):
|
|
197
|
+
warnings.warn(f"""Function description is missing for
|
|
198
|
+
{openai_tool_schema['function']['name']}. This may
|
|
199
|
+
affect the quality of tool calling.""")
|
|
198
200
|
|
|
199
201
|
# Validate whether parameters
|
|
200
202
|
# meet the JSON Schema reference specifications.
|
|
@@ -207,14 +209,15 @@ class OpenAIFunction:
|
|
|
207
209
|
JSONValidator.check_schema(parameters)
|
|
208
210
|
except SchemaError as e:
|
|
209
211
|
raise e
|
|
210
|
-
|
|
212
|
+
|
|
213
|
+
# Check the parameter description, if no description then raise warming
|
|
211
214
|
properties: Dict[str, Any] = parameters["properties"]
|
|
212
215
|
for param_name in properties.keys():
|
|
213
216
|
param_dict = properties[param_name]
|
|
214
217
|
if "description" not in param_dict:
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
+
warnings.warn(f"""Parameter description is missing for
|
|
219
|
+
{param_dict}. This may affect the quality of tool
|
|
220
|
+
calling.""")
|
|
218
221
|
|
|
219
222
|
def get_openai_tool_schema(self) -> Dict[str, Any]:
|
|
220
223
|
r"""Gets the OpenAI tool schema for this function.
|
|
@@ -387,3 +390,23 @@ class OpenAIFunction:
|
|
|
387
390
|
except SchemaError as e:
|
|
388
391
|
raise e
|
|
389
392
|
self.openai_tool_schema["function"]["parameters"]["properties"] = value
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
warnings.simplefilter('always', DeprecationWarning)
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
# Alias for backwards compatibility
|
|
399
|
+
class OpenAIFunction(FunctionTool):
|
|
400
|
+
def __init__(self, *args, **kwargs):
|
|
401
|
+
PURPLE = '\033[95m'
|
|
402
|
+
RESET = '\033[0m'
|
|
403
|
+
|
|
404
|
+
def purple_warning(msg):
|
|
405
|
+
warnings.warn(
|
|
406
|
+
PURPLE + msg + RESET, DeprecationWarning, stacklevel=2
|
|
407
|
+
)
|
|
408
|
+
|
|
409
|
+
purple_warning(
|
|
410
|
+
"OpenAIFunction is deprecated, please use FunctionTool instead."
|
|
411
|
+
)
|
|
412
|
+
super().__init__(*args, **kwargs)
|
camel/toolkits/github_toolkit.py
CHANGED
|
@@ -18,11 +18,10 @@ from typing import List, Optional
|
|
|
18
18
|
|
|
19
19
|
from pydantic import BaseModel
|
|
20
20
|
|
|
21
|
+
from camel.toolkits import FunctionTool
|
|
22
|
+
from camel.toolkits.base import BaseToolkit
|
|
21
23
|
from camel.utils import dependencies_required
|
|
22
24
|
|
|
23
|
-
from .base import BaseToolkit
|
|
24
|
-
from .openai_function import OpenAIFunction
|
|
25
|
-
|
|
26
25
|
|
|
27
26
|
class GithubIssue(BaseModel):
|
|
28
27
|
r"""Represents a GitHub issue.
|
|
@@ -131,19 +130,19 @@ class GithubToolkit(BaseToolkit):
|
|
|
131
130
|
self.github = Github(auth=Auth.Token(access_token))
|
|
132
131
|
self.repo = self.github.get_repo(repo_name)
|
|
133
132
|
|
|
134
|
-
def get_tools(self) -> List[
|
|
135
|
-
r"""Returns a list of
|
|
133
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
134
|
+
r"""Returns a list of FunctionTool objects representing the
|
|
136
135
|
functions in the toolkit.
|
|
137
136
|
|
|
138
137
|
Returns:
|
|
139
|
-
List[
|
|
138
|
+
List[FunctionTool]: A list of FunctionTool objects
|
|
140
139
|
representing the functions in the toolkit.
|
|
141
140
|
"""
|
|
142
141
|
return [
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
FunctionTool(self.retrieve_issue_list),
|
|
143
|
+
FunctionTool(self.retrieve_issue),
|
|
144
|
+
FunctionTool(self.create_pull_request),
|
|
145
|
+
FunctionTool(self.retrieve_pull_requests),
|
|
147
146
|
]
|
|
148
147
|
|
|
149
148
|
def get_github_access_token(self) -> str:
|
|
@@ -16,7 +16,7 @@ from functools import wraps
|
|
|
16
16
|
from typing import Any, Callable, List, Optional, Union
|
|
17
17
|
|
|
18
18
|
from camel.toolkits.base import BaseToolkit
|
|
19
|
-
from camel.toolkits.
|
|
19
|
+
from camel.toolkits.function_tool import FunctionTool
|
|
20
20
|
from camel.utils import dependencies_required
|
|
21
21
|
|
|
22
22
|
|
|
@@ -287,16 +287,16 @@ class GoogleMapsToolkit(BaseToolkit):
|
|
|
287
287
|
|
|
288
288
|
return description
|
|
289
289
|
|
|
290
|
-
def get_tools(self) -> List[
|
|
291
|
-
r"""Returns a list of
|
|
290
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
291
|
+
r"""Returns a list of FunctionTool objects representing the
|
|
292
292
|
functions in the toolkit.
|
|
293
293
|
|
|
294
294
|
Returns:
|
|
295
|
-
List[
|
|
295
|
+
List[FunctionTool]: A list of FunctionTool objects
|
|
296
296
|
representing the functions in the toolkit.
|
|
297
297
|
"""
|
|
298
298
|
return [
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
299
|
+
FunctionTool(self.get_address_description),
|
|
300
|
+
FunctionTool(self.get_elevation),
|
|
301
|
+
FunctionTool(self.get_timezone),
|
|
302
302
|
]
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# =========== Copyright 2023 @ 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 @ CAMEL-AI.org. All Rights Reserved. ===========
|
|
14
|
+
import re
|
|
15
|
+
from typing import List, Optional
|
|
16
|
+
|
|
17
|
+
from camel.toolkits import FunctionTool
|
|
18
|
+
from camel.toolkits.base import BaseToolkit
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class GoogleScholarToolkit(BaseToolkit):
|
|
22
|
+
r"""A toolkit for retrieving information about authors and their
|
|
23
|
+
publications from Google Scholar.
|
|
24
|
+
|
|
25
|
+
Attributes:
|
|
26
|
+
author_identifier (Union[str, None]): The author's Google Scholar URL
|
|
27
|
+
or name of the author to search for.
|
|
28
|
+
is_author_name (bool): Flag to indicate if the identifier is a name.
|
|
29
|
+
(default: :obj:`False`)
|
|
30
|
+
scholarly (module): The scholarly module for querying Google Scholar.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def __init__(
|
|
34
|
+
self, author_identifier: str, is_author_name: bool = False
|
|
35
|
+
) -> None:
|
|
36
|
+
r"""Initializes the GoogleScholarToolkit with the author's identifier.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
author_identifier (str): The author's Google Scholar URL or name
|
|
40
|
+
of the author to search for.
|
|
41
|
+
is_author_name (bool): Flag to indicate if the identifier is a
|
|
42
|
+
name. (default: :obj:`False`)
|
|
43
|
+
"""
|
|
44
|
+
from scholarly import scholarly
|
|
45
|
+
|
|
46
|
+
self.scholarly = scholarly
|
|
47
|
+
self.author_identifier = author_identifier
|
|
48
|
+
self.is_author_name = is_author_name
|
|
49
|
+
|
|
50
|
+
def _extract_author_id(self) -> Optional[str]:
|
|
51
|
+
r"""Extracts the author ID from a Google Scholar URL if provided.
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
Optional[str]: The extracted author ID, or None if not found.
|
|
55
|
+
"""
|
|
56
|
+
match = re.search(r'user=([A-Za-z0-9-]+)', self.author_identifier)
|
|
57
|
+
return match.group(1) if match else None
|
|
58
|
+
|
|
59
|
+
def get_author_detailed_info(
|
|
60
|
+
self,
|
|
61
|
+
) -> dict:
|
|
62
|
+
r"""Retrieves detailed information about the author.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
dict: A dictionary containing detailed information about the
|
|
66
|
+
author.
|
|
67
|
+
"""
|
|
68
|
+
if self.is_author_name:
|
|
69
|
+
search_query = self.scholarly.search_author(self.author_identifier)
|
|
70
|
+
# Retrieve the first result from the iterator
|
|
71
|
+
first_author_result = next(search_query)
|
|
72
|
+
else:
|
|
73
|
+
author_id = self._extract_author_id()
|
|
74
|
+
first_author_result = self.scholarly.search_author_id(id=author_id)
|
|
75
|
+
|
|
76
|
+
author = self.scholarly.fill(first_author_result)
|
|
77
|
+
return author
|
|
78
|
+
|
|
79
|
+
def get_author_publications(
|
|
80
|
+
self,
|
|
81
|
+
) -> List[str]:
|
|
82
|
+
r"""Retrieves the titles of the author's publications.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
List[str]: A list of publication titles authored by the author.
|
|
86
|
+
"""
|
|
87
|
+
author = self.get_author_detailed_info()
|
|
88
|
+
publication_titles = [
|
|
89
|
+
pub['bib']['title'] for pub in author['publications']
|
|
90
|
+
]
|
|
91
|
+
return publication_titles
|
|
92
|
+
|
|
93
|
+
def get_publication_by_title(
|
|
94
|
+
self, publication_title: str
|
|
95
|
+
) -> Optional[dict]:
|
|
96
|
+
r"""Retrieves detailed information about a specific publication by its
|
|
97
|
+
title. Note that this method cannot retrieve the full content of the
|
|
98
|
+
paper.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
publication_title (str): The title of the publication to search
|
|
102
|
+
for.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
Optional[dict]: A dictionary containing detailed information about
|
|
106
|
+
the publication if found; otherwise, `None`.
|
|
107
|
+
"""
|
|
108
|
+
author = self.get_author_detailed_info()
|
|
109
|
+
publications = author['publications']
|
|
110
|
+
for publication in publications:
|
|
111
|
+
if publication['bib']['title'] == publication_title:
|
|
112
|
+
return self.scholarly.fill(publication)
|
|
113
|
+
return None # Return None if not found
|
|
114
|
+
|
|
115
|
+
def get_full_paper_content_by_link(self, pdf_url: str) -> Optional[str]:
|
|
116
|
+
r"""Retrieves the full paper content from a given PDF URL using the
|
|
117
|
+
arxiv2text tool.
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
pdf_url (str): The URL of the PDF file.
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
Optional[str]: The full text extracted from the PDF, or `None` if
|
|
124
|
+
an error occurs.
|
|
125
|
+
"""
|
|
126
|
+
from arxiv2text import arxiv_to_text
|
|
127
|
+
|
|
128
|
+
try:
|
|
129
|
+
return arxiv_to_text(pdf_url)
|
|
130
|
+
except Exception:
|
|
131
|
+
return None # Return None in case of any error
|
|
132
|
+
|
|
133
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
134
|
+
r"""Returns a list of FunctionTool objects representing the
|
|
135
|
+
functions in the toolkit.
|
|
136
|
+
|
|
137
|
+
Returns:
|
|
138
|
+
List[FunctionTool]: A list of FunctionTool objects
|
|
139
|
+
representing the functions in the toolkit.
|
|
140
|
+
"""
|
|
141
|
+
return [
|
|
142
|
+
FunctionTool(self.get_author_detailed_info),
|
|
143
|
+
FunctionTool(self.get_author_publications),
|
|
144
|
+
FunctionTool(self.get_publication_by_title),
|
|
145
|
+
FunctionTool(self.get_full_paper_content_by_link),
|
|
146
|
+
]
|
|
@@ -19,7 +19,7 @@ from typing import List
|
|
|
19
19
|
|
|
20
20
|
import requests
|
|
21
21
|
|
|
22
|
-
from camel.toolkits import
|
|
22
|
+
from camel.toolkits import FunctionTool
|
|
23
23
|
from camel.toolkits.base import BaseToolkit
|
|
24
24
|
from camel.utils import handle_http_error
|
|
25
25
|
|
|
@@ -194,18 +194,18 @@ class LinkedInToolkit(BaseToolkit):
|
|
|
194
194
|
|
|
195
195
|
return profile_report
|
|
196
196
|
|
|
197
|
-
def get_tools(self) -> List[
|
|
198
|
-
r"""Returns a list of
|
|
197
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
198
|
+
r"""Returns a list of FunctionTool objects representing the
|
|
199
199
|
functions in the toolkit.
|
|
200
200
|
|
|
201
201
|
Returns:
|
|
202
|
-
List[
|
|
202
|
+
List[FunctionTool]: A list of FunctionTool objects
|
|
203
203
|
representing the functions in the toolkit.
|
|
204
204
|
"""
|
|
205
205
|
return [
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
FunctionTool(self.create_post),
|
|
207
|
+
FunctionTool(self.delete_post),
|
|
208
|
+
FunctionTool(self.get_profile),
|
|
209
209
|
]
|
|
210
210
|
|
|
211
211
|
def _get_access_token(self) -> str:
|
camel/toolkits/math_toolkit.py
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
from typing import List
|
|
16
16
|
|
|
17
17
|
from camel.toolkits.base import BaseToolkit
|
|
18
|
-
from camel.toolkits.
|
|
18
|
+
from camel.toolkits.function_tool import FunctionTool
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class MathToolkit(BaseToolkit):
|
|
@@ -61,19 +61,19 @@ class MathToolkit(BaseToolkit):
|
|
|
61
61
|
"""
|
|
62
62
|
return a * b
|
|
63
63
|
|
|
64
|
-
def get_tools(self) -> List[
|
|
65
|
-
r"""Returns a list of
|
|
64
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
65
|
+
r"""Returns a list of FunctionTool objects representing the
|
|
66
66
|
functions in the toolkit.
|
|
67
67
|
|
|
68
68
|
Returns:
|
|
69
|
-
List[
|
|
69
|
+
List[FunctionTool]: A list of FunctionTool objects
|
|
70
70
|
representing the functions in the toolkit.
|
|
71
71
|
"""
|
|
72
72
|
return [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
FunctionTool(self.add),
|
|
74
|
+
FunctionTool(self.sub),
|
|
75
|
+
FunctionTool(self.mul),
|
|
76
76
|
]
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
MATH_FUNCS: List[
|
|
79
|
+
MATH_FUNCS: List[FunctionTool] = MathToolkit().get_tools()
|
|
@@ -17,7 +17,7 @@ from typing import Any, Callable, Dict, List, Optional, Tuple
|
|
|
17
17
|
|
|
18
18
|
import requests
|
|
19
19
|
|
|
20
|
-
from camel.toolkits import
|
|
20
|
+
from camel.toolkits import FunctionTool, openapi_security_config
|
|
21
21
|
from camel.types import OpenAPIName
|
|
22
22
|
|
|
23
23
|
|
|
@@ -526,12 +526,12 @@ class OpenAPIToolkit:
|
|
|
526
526
|
apinames_filepaths.append((api_name.value, file_path))
|
|
527
527
|
return apinames_filepaths
|
|
528
528
|
|
|
529
|
-
def get_tools(self) -> List[
|
|
530
|
-
r"""Returns a list of
|
|
529
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
530
|
+
r"""Returns a list of FunctionTool objects representing the
|
|
531
531
|
functions in the toolkit.
|
|
532
532
|
|
|
533
533
|
Returns:
|
|
534
|
-
List[
|
|
534
|
+
List[FunctionTool]: A list of FunctionTool objects
|
|
535
535
|
representing the functions in the toolkit.
|
|
536
536
|
"""
|
|
537
537
|
apinames_filepaths = self.generate_apinames_filepaths()
|
|
@@ -539,6 +539,6 @@ class OpenAPIToolkit:
|
|
|
539
539
|
self.apinames_filepaths_to_funs_schemas(apinames_filepaths)
|
|
540
540
|
)
|
|
541
541
|
return [
|
|
542
|
-
|
|
542
|
+
FunctionTool(a_func, a_schema)
|
|
543
543
|
for a_func, a_schema in zip(all_funcs_lst, all_schemas_lst)
|
|
544
544
|
]
|
camel/toolkits/reddit_toolkit.py
CHANGED
|
@@ -18,7 +18,7 @@ from typing import Any, Dict, List, Union
|
|
|
18
18
|
|
|
19
19
|
from requests.exceptions import RequestException
|
|
20
20
|
|
|
21
|
-
from camel.toolkits import
|
|
21
|
+
from camel.toolkits import FunctionTool
|
|
22
22
|
from camel.toolkits.base import BaseToolkit
|
|
23
23
|
|
|
24
24
|
|
|
@@ -219,16 +219,16 @@ class RedditToolkit(BaseToolkit):
|
|
|
219
219
|
data = self.perform_sentiment_analysis(data)
|
|
220
220
|
return data
|
|
221
221
|
|
|
222
|
-
def get_tools(self) -> List[
|
|
223
|
-
r"""Returns a list of
|
|
222
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
223
|
+
r"""Returns a list of FunctionTool objects representing the
|
|
224
224
|
functions in the toolkit.
|
|
225
225
|
|
|
226
226
|
Returns:
|
|
227
|
-
List[
|
|
227
|
+
List[FunctionTool]: A list of FunctionTool objects for the
|
|
228
228
|
toolkit methods.
|
|
229
229
|
"""
|
|
230
230
|
return [
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
FunctionTool(self.collect_top_posts),
|
|
232
|
+
FunctionTool(self.perform_sentiment_analysis),
|
|
233
|
+
FunctionTool(self.track_keyword_discussions),
|
|
234
234
|
]
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
from typing import List, Optional, Union
|
|
15
15
|
|
|
16
16
|
from camel.retrievers import AutoRetriever
|
|
17
|
-
from camel.toolkits import
|
|
17
|
+
from camel.toolkits import FunctionTool
|
|
18
18
|
from camel.toolkits.base import BaseToolkit
|
|
19
19
|
from camel.types import StorageType
|
|
20
20
|
from camel.utils import Constants
|
|
@@ -75,14 +75,14 @@ class RetrievalToolkit(BaseToolkit):
|
|
|
75
75
|
)
|
|
76
76
|
return str(retrieved_info)
|
|
77
77
|
|
|
78
|
-
def get_tools(self) -> List[
|
|
79
|
-
r"""Returns a list of
|
|
78
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
79
|
+
r"""Returns a list of FunctionTool objects representing the
|
|
80
80
|
functions in the toolkit.
|
|
81
81
|
|
|
82
82
|
Returns:
|
|
83
|
-
List[
|
|
83
|
+
List[FunctionTool]: A list of FunctionTool objects
|
|
84
84
|
representing the functions in the toolkit.
|
|
85
85
|
"""
|
|
86
86
|
return [
|
|
87
|
-
|
|
87
|
+
FunctionTool(self.information_retrieval),
|
|
88
88
|
]
|
camel/toolkits/search_toolkit.py
CHANGED
|
@@ -15,7 +15,7 @@ import os
|
|
|
15
15
|
from typing import Any, Dict, List
|
|
16
16
|
|
|
17
17
|
from camel.toolkits.base import BaseToolkit
|
|
18
|
-
from camel.toolkits.
|
|
18
|
+
from camel.toolkits.function_tool import FunctionTool
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class SearchToolkit(BaseToolkit):
|
|
@@ -307,20 +307,20 @@ class SearchToolkit(BaseToolkit):
|
|
|
307
307
|
|
|
308
308
|
return result.rstrip() # Remove trailing whitespace
|
|
309
309
|
|
|
310
|
-
def get_tools(self) -> List[
|
|
311
|
-
r"""Returns a list of
|
|
310
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
311
|
+
r"""Returns a list of FunctionTool objects representing the
|
|
312
312
|
functions in the toolkit.
|
|
313
313
|
|
|
314
314
|
Returns:
|
|
315
|
-
List[
|
|
315
|
+
List[FunctionTool]: A list of FunctionTool objects
|
|
316
316
|
representing the functions in the toolkit.
|
|
317
317
|
"""
|
|
318
318
|
return [
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
319
|
+
FunctionTool(self.search_wiki),
|
|
320
|
+
FunctionTool(self.search_google),
|
|
321
|
+
FunctionTool(self.search_duckduckgo),
|
|
322
|
+
FunctionTool(self.query_wolfram_alpha),
|
|
323
323
|
]
|
|
324
324
|
|
|
325
325
|
|
|
326
|
-
SEARCH_FUNCS: List[
|
|
326
|
+
SEARCH_FUNCS: List[FunctionTool] = SearchToolkit().get_tools()
|
camel/toolkits/slack_toolkit.py
CHANGED
|
@@ -26,7 +26,7 @@ if TYPE_CHECKING:
|
|
|
26
26
|
|
|
27
27
|
from slack_sdk import WebClient
|
|
28
28
|
|
|
29
|
-
from camel.toolkits import
|
|
29
|
+
from camel.toolkits import FunctionTool
|
|
30
30
|
|
|
31
31
|
logger = logging.getLogger(__name__)
|
|
32
32
|
|
|
@@ -286,20 +286,20 @@ class SlackToolkit(BaseToolkit):
|
|
|
286
286
|
except SlackApiError as e:
|
|
287
287
|
return f"Error creating conversation: {e.response['error']}"
|
|
288
288
|
|
|
289
|
-
def get_tools(self) -> List[
|
|
290
|
-
r"""Returns a list of
|
|
289
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
290
|
+
r"""Returns a list of FunctionTool objects representing the
|
|
291
291
|
functions in the toolkit.
|
|
292
292
|
|
|
293
293
|
Returns:
|
|
294
|
-
List[
|
|
294
|
+
List[FunctionTool]: A list of FunctionTool objects
|
|
295
295
|
representing the functions in the toolkit.
|
|
296
296
|
"""
|
|
297
297
|
return [
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
298
|
+
FunctionTool(self.create_slack_channel),
|
|
299
|
+
FunctionTool(self.join_slack_channel),
|
|
300
|
+
FunctionTool(self.leave_slack_channel),
|
|
301
|
+
FunctionTool(self.get_slack_channel_information),
|
|
302
|
+
FunctionTool(self.get_slack_channel_message),
|
|
303
|
+
FunctionTool(self.send_slack_message),
|
|
304
|
+
FunctionTool(self.delete_slack_message),
|
|
305
305
|
]
|