camel-ai 0.2.3a1__py3-none-any.whl → 0.2.4__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 +93 -69
  3. camel/agents/knowledge_graph_agent.py +4 -6
  4. camel/bots/__init__.py +16 -2
  5. camel/bots/discord_app.py +138 -0
  6. camel/bots/slack/__init__.py +30 -0
  7. camel/bots/slack/models.py +158 -0
  8. camel/bots/slack/slack_app.py +255 -0
  9. camel/configs/__init__.py +1 -2
  10. camel/configs/anthropic_config.py +2 -5
  11. camel/configs/base_config.py +6 -6
  12. camel/configs/groq_config.py +2 -3
  13. camel/configs/ollama_config.py +1 -2
  14. camel/configs/openai_config.py +2 -23
  15. camel/configs/samba_config.py +2 -2
  16. camel/configs/togetherai_config.py +1 -1
  17. camel/configs/vllm_config.py +1 -1
  18. camel/configs/zhipuai_config.py +2 -3
  19. camel/embeddings/openai_embedding.py +2 -2
  20. camel/loaders/__init__.py +2 -0
  21. camel/loaders/chunkr_reader.py +163 -0
  22. camel/loaders/firecrawl_reader.py +3 -3
  23. camel/loaders/unstructured_io.py +35 -33
  24. camel/messages/__init__.py +1 -0
  25. camel/models/__init__.py +2 -4
  26. camel/models/anthropic_model.py +32 -26
  27. camel/models/azure_openai_model.py +39 -36
  28. camel/models/base_model.py +31 -20
  29. camel/models/gemini_model.py +37 -29
  30. camel/models/groq_model.py +29 -23
  31. camel/models/litellm_model.py +44 -61
  32. camel/models/mistral_model.py +32 -29
  33. camel/models/model_factory.py +66 -76
  34. camel/models/nemotron_model.py +33 -23
  35. camel/models/ollama_model.py +42 -47
  36. camel/models/{openai_compatibility_model.py → openai_compatible_model.py} +31 -49
  37. camel/models/openai_model.py +48 -29
  38. camel/models/reka_model.py +30 -28
  39. camel/models/samba_model.py +82 -177
  40. camel/models/stub_model.py +2 -2
  41. camel/models/togetherai_model.py +37 -43
  42. camel/models/vllm_model.py +43 -50
  43. camel/models/zhipuai_model.py +33 -27
  44. camel/retrievers/auto_retriever.py +29 -97
  45. camel/retrievers/vector_retriever.py +58 -47
  46. camel/societies/babyagi_playing.py +6 -3
  47. camel/societies/role_playing.py +5 -3
  48. camel/storages/graph_storages/graph_element.py +2 -2
  49. camel/storages/key_value_storages/json.py +6 -1
  50. camel/toolkits/__init__.py +20 -7
  51. camel/toolkits/arxiv_toolkit.py +155 -0
  52. camel/toolkits/ask_news_toolkit.py +653 -0
  53. camel/toolkits/base.py +2 -3
  54. camel/toolkits/code_execution.py +6 -7
  55. camel/toolkits/dalle_toolkit.py +6 -6
  56. camel/toolkits/{openai_function.py → function_tool.py} +34 -11
  57. camel/toolkits/github_toolkit.py +9 -10
  58. camel/toolkits/google_maps_toolkit.py +7 -7
  59. camel/toolkits/google_scholar_toolkit.py +146 -0
  60. camel/toolkits/linkedin_toolkit.py +7 -7
  61. camel/toolkits/math_toolkit.py +8 -8
  62. camel/toolkits/open_api_toolkit.py +5 -5
  63. camel/toolkits/reddit_toolkit.py +7 -7
  64. camel/toolkits/retrieval_toolkit.py +5 -5
  65. camel/toolkits/search_toolkit.py +9 -9
  66. camel/toolkits/slack_toolkit.py +11 -11
  67. camel/toolkits/twitter_toolkit.py +378 -452
  68. camel/toolkits/weather_toolkit.py +6 -6
  69. camel/toolkits/whatsapp_toolkit.py +177 -0
  70. camel/types/__init__.py +6 -1
  71. camel/types/enums.py +40 -85
  72. camel/types/openai_types.py +3 -0
  73. camel/types/unified_model_type.py +104 -0
  74. camel/utils/__init__.py +0 -2
  75. camel/utils/async_func.py +7 -7
  76. camel/utils/commons.py +32 -3
  77. camel/utils/token_counting.py +30 -212
  78. camel/workforce/role_playing_worker.py +1 -1
  79. camel/workforce/single_agent_worker.py +1 -1
  80. camel/workforce/task_channel.py +4 -3
  81. camel/workforce/workforce.py +4 -4
  82. camel_ai-0.2.4.dist-info/LICENSE +201 -0
  83. {camel_ai-0.2.3a1.dist-info → camel_ai-0.2.4.dist-info}/METADATA +27 -56
  84. {camel_ai-0.2.3a1.dist-info → camel_ai-0.2.4.dist-info}/RECORD +85 -76
  85. {camel_ai-0.2.3a1.dist-info → camel_ai-0.2.4.dist-info}/WHEEL +1 -1
  86. camel/bots/discord_bot.py +0 -206
  87. camel/models/open_source_model.py +0 -170
@@ -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 OpenAIFunction
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[OpenAIFunction]:
136
- r"""Returns a list of OpenAIFunction objects representing the
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[OpenAIFunction]: A list of OpenAIFunction objects
140
+ List[FunctionTool]: A list of FunctionTool objects
141
141
  representing the functions in the toolkit.
142
142
  """
143
- return [OpenAIFunction(self.get_dalle_img)]
143
+ return [FunctionTool(self.get_dalle_img)]
144
144
 
145
145
 
146
- DALLE_FUNCS: List[OpenAIFunction] = DalleToolkit().get_tools()
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 OpenAIFunction:
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
- # Check the function description
196
- if not openai_tool_schema["function"]["description"]:
197
- raise ValueError("miss function description")
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
- # Check the parameter description
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
- raise ValueError(
216
- f'miss description of parameter "{param_name}"'
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)
@@ -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[OpenAIFunction]:
135
- r"""Returns a list of OpenAIFunction objects representing the
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[OpenAIFunction]: A list of OpenAIFunction objects
138
+ List[FunctionTool]: A list of FunctionTool objects
140
139
  representing the functions in the toolkit.
141
140
  """
142
141
  return [
143
- OpenAIFunction(self.retrieve_issue_list),
144
- OpenAIFunction(self.retrieve_issue),
145
- OpenAIFunction(self.create_pull_request),
146
- OpenAIFunction(self.retrieve_pull_requests),
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.openai_function import OpenAIFunction
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[OpenAIFunction]:
291
- r"""Returns a list of OpenAIFunction objects representing the
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[OpenAIFunction]: A list of OpenAIFunction objects
295
+ List[FunctionTool]: A list of FunctionTool objects
296
296
  representing the functions in the toolkit.
297
297
  """
298
298
  return [
299
- OpenAIFunction(self.get_address_description),
300
- OpenAIFunction(self.get_elevation),
301
- OpenAIFunction(self.get_timezone),
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 OpenAIFunction
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[OpenAIFunction]:
198
- r"""Returns a list of OpenAIFunction objects representing the
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[OpenAIFunction]: A list of OpenAIFunction objects
202
+ List[FunctionTool]: A list of FunctionTool objects
203
203
  representing the functions in the toolkit.
204
204
  """
205
205
  return [
206
- OpenAIFunction(self.create_post),
207
- OpenAIFunction(self.delete_post),
208
- OpenAIFunction(self.get_profile),
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:
@@ -15,7 +15,7 @@
15
15
  from typing import List
16
16
 
17
17
  from camel.toolkits.base import BaseToolkit
18
- from camel.toolkits.openai_function import OpenAIFunction
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[OpenAIFunction]:
65
- r"""Returns a list of OpenAIFunction objects representing the
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[OpenAIFunction]: A list of OpenAIFunction objects
69
+ List[FunctionTool]: A list of FunctionTool objects
70
70
  representing the functions in the toolkit.
71
71
  """
72
72
  return [
73
- OpenAIFunction(self.add),
74
- OpenAIFunction(self.sub),
75
- OpenAIFunction(self.mul),
73
+ FunctionTool(self.add),
74
+ FunctionTool(self.sub),
75
+ FunctionTool(self.mul),
76
76
  ]
77
77
 
78
78
 
79
- MATH_FUNCS: List[OpenAIFunction] = MathToolkit().get_tools()
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 OpenAIFunction, openapi_security_config
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[OpenAIFunction]:
530
- r"""Returns a list of OpenAIFunction objects representing the
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[OpenAIFunction]: A list of OpenAIFunction objects
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
- OpenAIFunction(a_func, a_schema)
542
+ FunctionTool(a_func, a_schema)
543
543
  for a_func, a_schema in zip(all_funcs_lst, all_schemas_lst)
544
544
  ]
@@ -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 OpenAIFunction
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[OpenAIFunction]:
223
- r"""Returns a list of OpenAIFunction objects representing the
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[OpenAIFunction]: A list of OpenAIFunction objects for the
227
+ List[FunctionTool]: A list of FunctionTool objects for the
228
228
  toolkit methods.
229
229
  """
230
230
  return [
231
- OpenAIFunction(self.collect_top_posts),
232
- OpenAIFunction(self.perform_sentiment_analysis),
233
- OpenAIFunction(self.track_keyword_discussions),
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 OpenAIFunction
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[OpenAIFunction]:
79
- r"""Returns a list of OpenAIFunction objects representing the
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[OpenAIFunction]: A list of OpenAIFunction objects
83
+ List[FunctionTool]: A list of FunctionTool objects
84
84
  representing the functions in the toolkit.
85
85
  """
86
86
  return [
87
- OpenAIFunction(self.information_retrieval),
87
+ FunctionTool(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.openai_function import OpenAIFunction
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[OpenAIFunction]:
311
- r"""Returns a list of OpenAIFunction objects representing the
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[OpenAIFunction]: A list of OpenAIFunction objects
315
+ List[FunctionTool]: A list of FunctionTool objects
316
316
  representing the functions in the toolkit.
317
317
  """
318
318
  return [
319
- OpenAIFunction(self.search_wiki),
320
- OpenAIFunction(self.search_google),
321
- OpenAIFunction(self.search_duckduckgo),
322
- OpenAIFunction(self.query_wolfram_alpha),
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[OpenAIFunction] = SearchToolkit().get_tools()
326
+ SEARCH_FUNCS: List[FunctionTool] = 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 OpenAIFunction
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[OpenAIFunction]:
290
- r"""Returns a list of OpenAIFunction objects representing the
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[OpenAIFunction]: A list of OpenAIFunction objects
294
+ List[FunctionTool]: A list of FunctionTool objects
295
295
  representing the functions in the toolkit.
296
296
  """
297
297
  return [
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),
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
  ]