camel-ai 0.2.3__py3-none-any.whl → 0.2.3a0__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.

Files changed (87) hide show
  1. camel/__init__.py +1 -1
  2. camel/agents/chat_agent.py +69 -93
  3. camel/agents/knowledge_graph_agent.py +6 -4
  4. camel/bots/__init__.py +2 -16
  5. camel/bots/discord_bot.py +206 -0
  6. camel/configs/__init__.py +2 -1
  7. camel/configs/anthropic_config.py +5 -2
  8. camel/configs/base_config.py +6 -6
  9. camel/configs/groq_config.py +3 -2
  10. camel/configs/ollama_config.py +2 -1
  11. camel/configs/openai_config.py +23 -2
  12. camel/configs/samba_config.py +2 -2
  13. camel/configs/togetherai_config.py +1 -1
  14. camel/configs/vllm_config.py +1 -1
  15. camel/configs/zhipuai_config.py +3 -2
  16. camel/embeddings/openai_embedding.py +2 -2
  17. camel/loaders/__init__.py +0 -2
  18. camel/loaders/firecrawl_reader.py +3 -3
  19. camel/loaders/unstructured_io.py +33 -35
  20. camel/messages/__init__.py +0 -1
  21. camel/models/__init__.py +4 -2
  22. camel/models/anthropic_model.py +26 -32
  23. camel/models/azure_openai_model.py +36 -39
  24. camel/models/base_model.py +20 -31
  25. camel/models/gemini_model.py +29 -37
  26. camel/models/groq_model.py +23 -29
  27. camel/models/litellm_model.py +61 -44
  28. camel/models/mistral_model.py +29 -32
  29. camel/models/model_factory.py +76 -66
  30. camel/models/nemotron_model.py +23 -33
  31. camel/models/ollama_model.py +47 -42
  32. camel/models/open_source_model.py +170 -0
  33. camel/models/{openai_compatible_model.py → openai_compatibility_model.py} +49 -31
  34. camel/models/openai_model.py +29 -48
  35. camel/models/reka_model.py +28 -30
  36. camel/models/samba_model.py +177 -82
  37. camel/models/stub_model.py +2 -2
  38. camel/models/togetherai_model.py +43 -37
  39. camel/models/vllm_model.py +50 -43
  40. camel/models/zhipuai_model.py +27 -33
  41. camel/retrievers/auto_retriever.py +10 -28
  42. camel/retrievers/vector_retriever.py +47 -58
  43. camel/societies/babyagi_playing.py +3 -6
  44. camel/societies/role_playing.py +3 -5
  45. camel/storages/graph_storages/graph_element.py +5 -3
  46. camel/storages/key_value_storages/json.py +1 -6
  47. camel/toolkits/__init__.py +7 -20
  48. camel/toolkits/base.py +3 -2
  49. camel/toolkits/code_execution.py +7 -6
  50. camel/toolkits/dalle_toolkit.py +6 -6
  51. camel/toolkits/github_toolkit.py +10 -9
  52. camel/toolkits/google_maps_toolkit.py +7 -7
  53. camel/toolkits/linkedin_toolkit.py +7 -7
  54. camel/toolkits/math_toolkit.py +8 -8
  55. camel/toolkits/open_api_toolkit.py +5 -5
  56. camel/toolkits/{function_tool.py → openai_function.py} +11 -34
  57. camel/toolkits/reddit_toolkit.py +7 -7
  58. camel/toolkits/retrieval_toolkit.py +5 -5
  59. camel/toolkits/search_toolkit.py +9 -9
  60. camel/toolkits/slack_toolkit.py +11 -11
  61. camel/toolkits/twitter_toolkit.py +452 -378
  62. camel/toolkits/weather_toolkit.py +6 -6
  63. camel/types/__init__.py +1 -6
  64. camel/types/enums.py +85 -40
  65. camel/types/openai_types.py +0 -3
  66. camel/utils/__init__.py +2 -0
  67. camel/utils/async_func.py +7 -7
  68. camel/utils/commons.py +3 -32
  69. camel/utils/token_counting.py +212 -30
  70. camel/workforce/role_playing_worker.py +1 -1
  71. camel/workforce/single_agent_worker.py +1 -1
  72. camel/workforce/task_channel.py +3 -4
  73. camel/workforce/workforce.py +4 -4
  74. {camel_ai-0.2.3.dist-info → camel_ai-0.2.3a0.dist-info}/METADATA +56 -27
  75. {camel_ai-0.2.3.dist-info → camel_ai-0.2.3a0.dist-info}/RECORD +76 -85
  76. {camel_ai-0.2.3.dist-info → camel_ai-0.2.3a0.dist-info}/WHEEL +1 -1
  77. camel/bots/discord_app.py +0 -138
  78. camel/bots/slack/__init__.py +0 -30
  79. camel/bots/slack/models.py +0 -158
  80. camel/bots/slack/slack_app.py +0 -255
  81. camel/loaders/chunkr_reader.py +0 -163
  82. camel/toolkits/arxiv_toolkit.py +0 -155
  83. camel/toolkits/ask_news_toolkit.py +0 -653
  84. camel/toolkits/google_scholar_toolkit.py +0 -146
  85. camel/toolkits/whatsapp_toolkit.py +0 -177
  86. camel/types/unified_model_type.py +0 -104
  87. 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 FunctionTool
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[FunctionTool]:
198
- r"""Returns a list of FunctionTool objects representing the
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[FunctionTool]: A list of FunctionTool objects
202
+ List[OpenAIFunction]: A list of OpenAIFunction objects
203
203
  representing the functions in the toolkit.
204
204
  """
205
205
  return [
206
- FunctionTool(self.create_post),
207
- FunctionTool(self.delete_post),
208
- FunctionTool(self.get_profile),
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:
@@ -15,7 +15,7 @@
15
15
  from typing import List
16
16
 
17
17
  from camel.toolkits.base import BaseToolkit
18
- from camel.toolkits.function_tool import FunctionTool
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[FunctionTool]:
65
- r"""Returns a list of FunctionTool objects representing the
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[FunctionTool]: A list of FunctionTool objects
69
+ List[OpenAIFunction]: A list of OpenAIFunction objects
70
70
  representing the functions in the toolkit.
71
71
  """
72
72
  return [
73
- FunctionTool(self.add),
74
- FunctionTool(self.sub),
75
- FunctionTool(self.mul),
73
+ OpenAIFunction(self.add),
74
+ OpenAIFunction(self.sub),
75
+ OpenAIFunction(self.mul),
76
76
  ]
77
77
 
78
78
 
79
- MATH_FUNCS: List[FunctionTool] = MathToolkit().get_tools()
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 FunctionTool, openapi_security_config
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[FunctionTool]:
530
- r"""Returns a list of FunctionTool objects representing the
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[FunctionTool]: A list of FunctionTool objects
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
- FunctionTool(a_func, a_schema)
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 FunctionTool:
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 `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.""")
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
- warnings.warn(f"""Parameter description is missing for
219
- {param_dict}. This may affect the quality of tool
220
- calling.""")
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)
@@ -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 FunctionTool
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[FunctionTool]:
223
- r"""Returns a list of FunctionTool objects representing the
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[FunctionTool]: A list of FunctionTool objects for the
227
+ List[OpenAIFunction]: A list of OpenAIFunction objects for the
228
228
  toolkit methods.
229
229
  """
230
230
  return [
231
- FunctionTool(self.collect_top_posts),
232
- FunctionTool(self.perform_sentiment_analysis),
233
- FunctionTool(self.track_keyword_discussions),
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 FunctionTool
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[FunctionTool]:
79
- r"""Returns a list of FunctionTool objects representing the
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[FunctionTool]: A list of FunctionTool objects
83
+ List[OpenAIFunction]: A list of OpenAIFunction objects
84
84
  representing the functions in the toolkit.
85
85
  """
86
86
  return [
87
- FunctionTool(self.information_retrieval),
87
+ OpenAIFunction(self.information_retrieval),
88
88
  ]
@@ -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.function_tool import FunctionTool
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[FunctionTool]:
311
- r"""Returns a list of FunctionTool objects representing the
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[FunctionTool]: A list of FunctionTool objects
315
+ List[OpenAIFunction]: A list of OpenAIFunction objects
316
316
  representing the functions in the toolkit.
317
317
  """
318
318
  return [
319
- FunctionTool(self.search_wiki),
320
- FunctionTool(self.search_google),
321
- FunctionTool(self.search_duckduckgo),
322
- FunctionTool(self.query_wolfram_alpha),
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[FunctionTool] = SearchToolkit().get_tools()
326
+ SEARCH_FUNCS: List[OpenAIFunction] = SearchToolkit().get_tools()
@@ -26,7 +26,7 @@ if TYPE_CHECKING:
26
26
 
27
27
  from slack_sdk import WebClient
28
28
 
29
- from camel.toolkits import FunctionTool
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[FunctionTool]:
290
- r"""Returns a list of FunctionTool objects representing the
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[FunctionTool]: A list of FunctionTool objects
294
+ List[OpenAIFunction]: A list of OpenAIFunction objects
295
295
  representing the functions in the toolkit.
296
296
  """
297
297
  return [
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),
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
  ]