camel-ai 0.2.3__py3-none-any.whl → 0.2.3a1__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 +69 -93
- camel/agents/knowledge_graph_agent.py +6 -4
- camel/bots/__init__.py +2 -16
- camel/bots/discord_bot.py +206 -0
- camel/configs/__init__.py +2 -1
- camel/configs/anthropic_config.py +5 -2
- camel/configs/base_config.py +6 -6
- camel/configs/groq_config.py +3 -2
- camel/configs/ollama_config.py +2 -1
- camel/configs/openai_config.py +23 -2
- 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 +3 -2
- camel/embeddings/openai_embedding.py +2 -2
- camel/loaders/__init__.py +0 -2
- camel/loaders/firecrawl_reader.py +3 -3
- camel/loaders/unstructured_io.py +33 -35
- camel/messages/__init__.py +0 -1
- camel/models/__init__.py +4 -2
- camel/models/anthropic_model.py +26 -32
- camel/models/azure_openai_model.py +36 -39
- camel/models/base_model.py +20 -31
- camel/models/gemini_model.py +29 -37
- camel/models/groq_model.py +23 -29
- camel/models/litellm_model.py +61 -44
- camel/models/mistral_model.py +29 -32
- camel/models/model_factory.py +76 -66
- camel/models/nemotron_model.py +23 -33
- camel/models/ollama_model.py +47 -42
- camel/models/open_source_model.py +170 -0
- camel/models/{openai_compatible_model.py → openai_compatibility_model.py} +49 -31
- camel/models/openai_model.py +29 -48
- camel/models/reka_model.py +28 -30
- camel/models/samba_model.py +177 -82
- camel/models/stub_model.py +2 -2
- camel/models/togetherai_model.py +43 -37
- camel/models/vllm_model.py +50 -43
- camel/models/zhipuai_model.py +27 -33
- camel/retrievers/auto_retriever.py +10 -28
- camel/retrievers/vector_retriever.py +47 -58
- camel/societies/babyagi_playing.py +3 -6
- camel/societies/role_playing.py +3 -5
- camel/storages/graph_storages/graph_element.py +5 -3
- camel/storages/key_value_storages/json.py +1 -6
- camel/toolkits/__init__.py +7 -20
- camel/toolkits/base.py +3 -2
- camel/toolkits/code_execution.py +7 -6
- camel/toolkits/dalle_toolkit.py +6 -6
- camel/toolkits/github_toolkit.py +10 -9
- camel/toolkits/google_maps_toolkit.py +7 -7
- camel/toolkits/linkedin_toolkit.py +7 -7
- camel/toolkits/math_toolkit.py +8 -8
- camel/toolkits/open_api_toolkit.py +5 -5
- camel/toolkits/{function_tool.py → openai_function.py} +11 -34
- 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 +452 -378
- camel/toolkits/weather_toolkit.py +6 -6
- camel/types/__init__.py +1 -6
- camel/types/enums.py +85 -40
- camel/types/openai_types.py +0 -3
- camel/utils/__init__.py +2 -0
- camel/utils/async_func.py +7 -7
- camel/utils/commons.py +3 -32
- camel/utils/token_counting.py +212 -30
- camel/workforce/role_playing_worker.py +1 -1
- camel/workforce/single_agent_worker.py +1 -1
- camel/workforce/task_channel.py +3 -4
- camel/workforce/workforce.py +4 -4
- {camel_ai-0.2.3.dist-info → camel_ai-0.2.3a1.dist-info}/METADATA +56 -27
- {camel_ai-0.2.3.dist-info → camel_ai-0.2.3a1.dist-info}/RECORD +76 -85
- {camel_ai-0.2.3.dist-info → camel_ai-0.2.3a1.dist-info}/WHEEL +1 -1
- camel/bots/discord_app.py +0 -138
- camel/bots/slack/__init__.py +0 -30
- camel/bots/slack/models.py +0 -158
- camel/bots/slack/slack_app.py +0 -255
- camel/loaders/chunkr_reader.py +0 -163
- camel/toolkits/arxiv_toolkit.py +0 -155
- camel/toolkits/ask_news_toolkit.py +0 -653
- camel/toolkits/google_scholar_toolkit.py +0 -146
- camel/toolkits/whatsapp_toolkit.py +0 -177
- camel/types/unified_model_type.py +0 -104
- camel_ai-0.2.3.dist-info/LICENSE +0 -201
|
@@ -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 OpenAIFunction
|
|
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[OpenAIFunction]:
|
|
198
|
+
r"""Returns a list of OpenAIFunction objects representing the
|
|
199
199
|
functions in the toolkit.
|
|
200
200
|
|
|
201
201
|
Returns:
|
|
202
|
-
List[
|
|
202
|
+
List[OpenAIFunction]: A list of OpenAIFunction objects
|
|
203
203
|
representing the functions in the toolkit.
|
|
204
204
|
"""
|
|
205
205
|
return [
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
OpenAIFunction(self.create_post),
|
|
207
|
+
OpenAIFunction(self.delete_post),
|
|
208
|
+
OpenAIFunction(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.openai_function import OpenAIFunction
|
|
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[OpenAIFunction]:
|
|
65
|
+
r"""Returns a list of OpenAIFunction objects representing the
|
|
66
66
|
functions in the toolkit.
|
|
67
67
|
|
|
68
68
|
Returns:
|
|
69
|
-
List[
|
|
69
|
+
List[OpenAIFunction]: A list of OpenAIFunction objects
|
|
70
70
|
representing the functions in the toolkit.
|
|
71
71
|
"""
|
|
72
72
|
return [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
OpenAIFunction(self.add),
|
|
74
|
+
OpenAIFunction(self.sub),
|
|
75
|
+
OpenAIFunction(self.mul),
|
|
76
76
|
]
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
MATH_FUNCS: List[
|
|
79
|
+
MATH_FUNCS: List[OpenAIFunction] = 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 OpenAIFunction, 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[OpenAIFunction]:
|
|
530
|
+
r"""Returns a list of OpenAIFunction objects representing the
|
|
531
531
|
functions in the toolkit.
|
|
532
532
|
|
|
533
533
|
Returns:
|
|
534
|
-
List[
|
|
534
|
+
List[OpenAIFunction]: A list of OpenAIFunction 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
|
+
OpenAIFunction(a_func, a_schema)
|
|
543
543
|
for a_func, a_schema in zip(all_funcs_lst, all_schemas_lst)
|
|
544
544
|
]
|
|
@@ -11,7 +11,6 @@
|
|
|
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
|
|
15
14
|
from inspect import Parameter, signature
|
|
16
15
|
from typing import Any, Callable, Dict, Mapping, Optional, Tuple
|
|
17
16
|
|
|
@@ -143,7 +142,7 @@ def get_openai_tool_schema(func: Callable) -> Dict[str, Any]:
|
|
|
143
142
|
return openai_tool_schema
|
|
144
143
|
|
|
145
144
|
|
|
146
|
-
class
|
|
145
|
+
class OpenAIFunction:
|
|
147
146
|
r"""An abstraction of a function that OpenAI chat models can call. See
|
|
148
147
|
https://platform.openai.com/docs/api-reference/chat/create.
|
|
149
148
|
|
|
@@ -185,18 +184,17 @@ class FunctionTool:
|
|
|
185
184
|
Raises:
|
|
186
185
|
ValidationError: If the schema does not comply with the
|
|
187
186
|
specifications.
|
|
187
|
+
ValueError: If the function description or parameter descriptions
|
|
188
|
+
are missing in the schema.
|
|
188
189
|
SchemaError: If the parameters do not meet JSON Schema reference
|
|
189
190
|
specifications.
|
|
190
191
|
"""
|
|
191
192
|
# Check the type
|
|
192
193
|
if not openai_tool_schema["type"]:
|
|
193
|
-
raise ValueError("miss
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
warnings.warn(f"""Function description is missing for
|
|
198
|
-
{openai_tool_schema['function']['name']}. This may
|
|
199
|
-
affect the quality of tool calling.""")
|
|
194
|
+
raise ValueError("miss type")
|
|
195
|
+
# Check the function description
|
|
196
|
+
if not openai_tool_schema["function"]["description"]:
|
|
197
|
+
raise ValueError("miss function description")
|
|
200
198
|
|
|
201
199
|
# Validate whether parameters
|
|
202
200
|
# meet the JSON Schema reference specifications.
|
|
@@ -209,15 +207,14 @@ class FunctionTool:
|
|
|
209
207
|
JSONValidator.check_schema(parameters)
|
|
210
208
|
except SchemaError as e:
|
|
211
209
|
raise e
|
|
212
|
-
|
|
213
|
-
# Check the parameter description, if no description then raise warming
|
|
210
|
+
# Check the parameter description
|
|
214
211
|
properties: Dict[str, Any] = parameters["properties"]
|
|
215
212
|
for param_name in properties.keys():
|
|
216
213
|
param_dict = properties[param_name]
|
|
217
214
|
if "description" not in param_dict:
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
215
|
+
raise ValueError(
|
|
216
|
+
f'miss description of parameter "{param_name}"'
|
|
217
|
+
)
|
|
221
218
|
|
|
222
219
|
def get_openai_tool_schema(self) -> Dict[str, Any]:
|
|
223
220
|
r"""Gets the OpenAI tool schema for this function.
|
|
@@ -390,23 +387,3 @@ class FunctionTool:
|
|
|
390
387
|
except SchemaError as e:
|
|
391
388
|
raise e
|
|
392
389
|
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/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 OpenAIFunction
|
|
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[OpenAIFunction]:
|
|
223
|
+
r"""Returns a list of OpenAIFunction objects representing the
|
|
224
224
|
functions in the toolkit.
|
|
225
225
|
|
|
226
226
|
Returns:
|
|
227
|
-
List[
|
|
227
|
+
List[OpenAIFunction]: A list of OpenAIFunction objects for the
|
|
228
228
|
toolkit methods.
|
|
229
229
|
"""
|
|
230
230
|
return [
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
OpenAIFunction(self.collect_top_posts),
|
|
232
|
+
OpenAIFunction(self.perform_sentiment_analysis),
|
|
233
|
+
OpenAIFunction(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 OpenAIFunction
|
|
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[OpenAIFunction]:
|
|
79
|
+
r"""Returns a list of OpenAIFunction objects representing the
|
|
80
80
|
functions in the toolkit.
|
|
81
81
|
|
|
82
82
|
Returns:
|
|
83
|
-
List[
|
|
83
|
+
List[OpenAIFunction]: A list of OpenAIFunction objects
|
|
84
84
|
representing the functions in the toolkit.
|
|
85
85
|
"""
|
|
86
86
|
return [
|
|
87
|
-
|
|
87
|
+
OpenAIFunction(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.openai_function import OpenAIFunction
|
|
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[OpenAIFunction]:
|
|
311
|
+
r"""Returns a list of OpenAIFunction objects representing the
|
|
312
312
|
functions in the toolkit.
|
|
313
313
|
|
|
314
314
|
Returns:
|
|
315
|
-
List[
|
|
315
|
+
List[OpenAIFunction]: A list of OpenAIFunction objects
|
|
316
316
|
representing the functions in the toolkit.
|
|
317
317
|
"""
|
|
318
318
|
return [
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
319
|
+
OpenAIFunction(self.search_wiki),
|
|
320
|
+
OpenAIFunction(self.search_google),
|
|
321
|
+
OpenAIFunction(self.search_duckduckgo),
|
|
322
|
+
OpenAIFunction(self.query_wolfram_alpha),
|
|
323
323
|
]
|
|
324
324
|
|
|
325
325
|
|
|
326
|
-
SEARCH_FUNCS: List[
|
|
326
|
+
SEARCH_FUNCS: List[OpenAIFunction] = 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 OpenAIFunction
|
|
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[OpenAIFunction]:
|
|
290
|
+
r"""Returns a list of OpenAIFunction objects representing the
|
|
291
291
|
functions in the toolkit.
|
|
292
292
|
|
|
293
293
|
Returns:
|
|
294
|
-
List[
|
|
294
|
+
List[OpenAIFunction]: A list of OpenAIFunction objects
|
|
295
295
|
representing the functions in the toolkit.
|
|
296
296
|
"""
|
|
297
297
|
return [
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
298
|
+
OpenAIFunction(self.create_slack_channel),
|
|
299
|
+
OpenAIFunction(self.join_slack_channel),
|
|
300
|
+
OpenAIFunction(self.leave_slack_channel),
|
|
301
|
+
OpenAIFunction(self.get_slack_channel_information),
|
|
302
|
+
OpenAIFunction(self.get_slack_channel_message),
|
|
303
|
+
OpenAIFunction(self.send_slack_message),
|
|
304
|
+
OpenAIFunction(self.delete_slack_message),
|
|
305
305
|
]
|