camel-ai 0.1.9__py3-none-any.whl → 0.2.0__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 CHANGED
@@ -12,7 +12,7 @@
12
12
  # limitations under the License.
13
13
  # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
14
14
 
15
- __version__ = '0.1.9'
15
+ __version__ = '0.2.0'
16
16
 
17
17
  __all__ = [
18
18
  '__version__',
@@ -181,6 +181,16 @@ class ChatAgent(BaseAgent):
181
181
  tool.get_function_name(): tool.func for tool in all_tools
182
182
  }
183
183
 
184
+ # If the user hasn't configured tools in `BaseModelBackend`,
185
+ # the tools set from `ChatAgent` will be used.
186
+ # This design simplifies the interface while retaining tool-running
187
+ # capabilities for `BaseModelBackend`.
188
+ if all_tools and not self.model_backend.model_config_dict['tools']:
189
+ tool_schema_list = [
190
+ tool.get_openai_tool_schema() for tool in all_tools
191
+ ]
192
+ self.model_backend.model_config_dict['tools'] = tool_schema_list
193
+
184
194
  self.model_config_dict = self.model_backend.model_config_dict
185
195
 
186
196
  self.model_token_limit = token_limit or self.model_backend.token_limit
@@ -93,6 +93,22 @@ class OpenAIModel(BaseModelBackend):
93
93
  `ChatCompletion` in the non-stream mode, or
94
94
  `Stream[ChatCompletionChunk]` in the stream mode.
95
95
  """
96
+ # o1-preview and o1-mini have Beta limitations
97
+ # reference: https://platform.openai.com/docs/guides/reasoning
98
+ if self.model_type in [ModelType.O1_MINI, ModelType.O1_PREVIEW]:
99
+ # Remove system message that is not supported in o1 model.
100
+ messages = [msg for msg in messages if msg.get("role") != "system"]
101
+
102
+ # Remove unsupported parameters and reset the fixed parameters
103
+ del self.model_config_dict["stream"]
104
+ del self.model_config_dict["tools"]
105
+ del self.model_config_dict["tool_choice"]
106
+ self.model_config_dict["temperature"] = 1.0
107
+ self.model_config_dict["top_p"] = 1.0
108
+ self.model_config_dict["n"] = 1.0
109
+ self.model_config_dict["presence_penalty"] = 0.0
110
+ self.model_config_dict["frequency_penalty"] = 0.0
111
+
96
112
  response = self._client.chat.completions.create(
97
113
  messages=messages,
98
114
  model=self.model_type.value,
@@ -19,19 +19,18 @@ from .openai_function import (
19
19
  )
20
20
  from .open_api_specs.security_config import openapi_security_config
21
21
 
22
- from .google_maps_toolkit import MAP_FUNCS, GoogleMapsToolkit
23
- from .math_toolkit import MATH_FUNCS, MathToolkit
24
- from .open_api_toolkit import OPENAPI_FUNCS, OpenAPIToolkit
25
- from .retrieval_toolkit import RETRIEVAL_FUNCS, RetrievalToolkit
26
- from .search_toolkit import SEARCH_FUNCS, SearchToolkit
27
- from .twitter_toolkit import TWITTER_FUNCS, TwitterToolkit
28
- from .weather_toolkit import WEATHER_FUNCS, WeatherToolkit
29
- from .slack_toolkit import SLACK_FUNCS, SlackToolkit
30
- from .dalle_toolkit import DALLE_FUNCS, DalleToolkit
31
- from .linkedin_toolkit import LINKEDIN_FUNCS, LinkedInToolkit
32
- from .reddit_toolkit import REDDIT_FUNCS, RedditToolkit
22
+ from .google_maps_toolkit import GoogleMapsToolkit
23
+ from .math_toolkit import MathToolkit, MATH_FUNCS
24
+ from .open_api_toolkit import OpenAPIToolkit
25
+ from .retrieval_toolkit import RetrievalToolkit
26
+ from .search_toolkit import SearchToolkit, SEARCH_FUNCS
27
+ from .twitter_toolkit import TwitterToolkit
28
+ from .weather_toolkit import WeatherToolkit, WEATHER_FUNCS
29
+ from .slack_toolkit import SlackToolkit
30
+ from .dalle_toolkit import DalleToolkit, DALLE_FUNCS
31
+ from .linkedin_toolkit import LinkedInToolkit
32
+ from .reddit_toolkit import RedditToolkit
33
33
 
34
- from .base import BaseToolkit
35
34
  from .code_execution import CodeExecutionToolkit
36
35
  from .github_toolkit import GithubToolkit
37
36
 
@@ -40,18 +39,6 @@ __all__ = [
40
39
  'get_openai_function_schema',
41
40
  'get_openai_tool_schema',
42
41
  'openapi_security_config',
43
- 'MATH_FUNCS',
44
- 'MAP_FUNCS',
45
- 'OPENAPI_FUNCS',
46
- 'RETRIEVAL_FUNCS',
47
- 'SEARCH_FUNCS',
48
- 'TWITTER_FUNCS',
49
- 'WEATHER_FUNCS',
50
- 'SLACK_FUNCS',
51
- 'DALLE_FUNCS',
52
- 'LINKEDIN_FUNCS',
53
- 'REDDIT_FUNCS',
54
- 'BaseToolkit',
55
42
  'GithubToolkit',
56
43
  'MathToolkit',
57
44
  'GoogleMapsToolkit',
@@ -65,4 +52,8 @@ __all__ = [
65
52
  'LinkedInToolkit',
66
53
  'RedditToolkit',
67
54
  'CodeExecutionToolkit',
55
+ 'MATH_FUNCS',
56
+ 'SEARCH_FUNCS',
57
+ 'WEATHER_FUNCS',
58
+ 'DALLE_FUNCS',
68
59
  ]
@@ -142,10 +142,6 @@ class GoogleMapsToolkit(BaseToolkit):
142
142
  information on address completion, formatted address,
143
143
  geographical coordinates (latitude and longitude), and metadata
144
144
  types true for the address.
145
-
146
- Raises:
147
- ImportError: If the `googlemaps` library is not installed.
148
- Exception: For unexpected errors during the address validation.
149
145
  """
150
146
  addressvalidation_result = self.gmaps.addressvalidation(
151
147
  [address],
@@ -304,6 +300,3 @@ class GoogleMapsToolkit(BaseToolkit):
304
300
  OpenAIFunction(self.get_elevation),
305
301
  OpenAIFunction(self.get_timezone),
306
302
  ]
307
-
308
-
309
- MAP_FUNCS: List[OpenAIFunction] = GoogleMapsToolkit().get_tools()
@@ -225,6 +225,3 @@ class LinkedInToolkit(BaseToolkit):
225
225
  if not token:
226
226
  return "Access token not found. Please set LINKEDIN_ACCESS_TOKEN."
227
227
  return token
228
-
229
-
230
- LINKEDIN_FUNCS: List[OpenAIFunction] = LinkedInToolkit().get_tools()
@@ -542,6 +542,3 @@ class OpenAPIToolkit:
542
542
  OpenAIFunction(a_func, a_schema)
543
543
  for a_func, a_schema in zip(all_funcs_lst, all_schemas_lst)
544
544
  ]
545
-
546
-
547
- OPENAPI_FUNCS: List[OpenAIFunction] = OpenAPIToolkit().get_tools()
@@ -232,6 +232,3 @@ class RedditToolkit(BaseToolkit):
232
232
  OpenAIFunction(self.perform_sentiment_analysis),
233
233
  OpenAIFunction(self.track_keyword_discussions),
234
234
  ]
235
-
236
-
237
- REDDIT_FUNCS: List[OpenAIFunction] = RedditToolkit().get_tools()
@@ -86,7 +86,3 @@ class RetrievalToolkit(BaseToolkit):
86
86
  return [
87
87
  OpenAIFunction(self.information_retrieval),
88
88
  ]
89
-
90
-
91
- # add the function to OpenAIFunction list
92
- RETRIEVAL_FUNCS: List[OpenAIFunction] = RetrievalToolkit().get_tools()
@@ -303,6 +303,3 @@ class SlackToolkit(BaseToolkit):
303
303
  OpenAIFunction(self.send_slack_message),
304
304
  OpenAIFunction(self.delete_slack_message),
305
305
  ]
306
-
307
-
308
- SLACK_FUNCS: List[OpenAIFunction] = SlackToolkit().get_tools()
@@ -410,7 +410,7 @@ class TwitterToolkit(BaseToolkit):
410
410
  return TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET
411
411
 
412
412
  def _get_oauth_session(self) -> requests.Session:
413
- r'''Initiates an OAuth1Session with Twitter's API and returns it.
413
+ r"""Initiates an OAuth1Session with Twitter's API and returns it.
414
414
 
415
415
  The function first fetches a request token, then prompts the user to
416
416
  authorize the application. After the user has authorized the
@@ -431,7 +431,7 @@ class TwitterToolkit(BaseToolkit):
431
431
  Manage-Tweets/create_tweet.py
432
432
  https://github.com/twitterdev/Twitter-API-v2-sample-code/blob/main/
433
433
  User-Lookup/get_users_me_user_context.py
434
- '''
434
+ """
435
435
  try:
436
436
  from requests_oauthlib import OAuth1Session
437
437
  except ImportError:
@@ -517,6 +517,3 @@ class TwitterToolkit(BaseToolkit):
517
517
  return "HTTP Exception"
518
518
  else:
519
519
  return "Unexpected Exception"
520
-
521
-
522
- TWITTER_FUNCS: List[OpenAIFunction] = TwitterToolkit().get_tools()
@@ -193,8 +193,14 @@ def get_model_encoding(value_for_tiktoken: str):
193
193
  try:
194
194
  encoding = tiktoken.encoding_for_model(value_for_tiktoken)
195
195
  except KeyError:
196
- print("Model not found. Using cl100k_base encoding.")
197
- encoding = tiktoken.get_encoding("cl100k_base")
196
+ if value_for_tiktoken in [
197
+ ModelType.O1_MINI.value,
198
+ ModelType.O1_PREVIEW.value,
199
+ ]:
200
+ encoding = tiktoken.get_encoding("o200k_base")
201
+ else:
202
+ print("Model not found. Using cl100k_base encoding.")
203
+ encoding = tiktoken.get_encoding("cl100k_base")
198
204
  return encoding
199
205
 
200
206
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: camel-ai
3
- Version: 0.1.9
3
+ Version: 0.2.0
4
4
  Summary: Communicative Agents for AI Society Study
5
5
  Home-page: https://www.camel-ai.org/
6
6
  License: Apache-2.0
@@ -59,6 +59,7 @@ Requires-Dist: numpy (>=1,<2)
59
59
  Requires-Dist: openai (>=1.45.0,<2.0.0)
60
60
  Requires-Dist: openapi-spec-validator (>=0.7.1,<0.8.0) ; extra == "tools" or extra == "all"
61
61
  Requires-Dist: opencv-python (>=4,<5) ; extra == "huggingface-agent" or extra == "all"
62
+ Requires-Dist: pandoc
62
63
  Requires-Dist: pathlib (>=1.0.1,<2.0.0)
63
64
  Requires-Dist: pillow (>=10.2.0,<11.0.0) ; extra == "tools" or extra == "all"
64
65
  Requires-Dist: prance (>=23.6.21.0,<24.0.0.0) ; extra == "tools" or extra == "all"
@@ -213,7 +214,7 @@ conda create --name camel python=3.10
213
214
  conda activate camel
214
215
 
215
216
  # Clone github repo
216
- git clone -b v0.1.9 https://github.com/camel-ai/camel.git
217
+ git clone -b v0.2.0 https://github.com/camel-ai/camel.git
217
218
 
218
219
  # Change directory into project directory
219
220
  cd camel
@@ -1,7 +1,7 @@
1
- camel/__init__.py,sha256=0t0atK37gcEwQ9syAnmmC8-6jJFevBMXq-PGtcDpcic,778
1
+ camel/__init__.py,sha256=zzLXt4OmIHyizUAU7n1idW4aN99Vcbjpo9JHPUUprko,778
2
2
  camel/agents/__init__.py,sha256=SSU1wbhZXWwQnE0rRxkpyN57kEu72KklsZNcdLkXfTs,1551
3
3
  camel/agents/base.py,sha256=X39qWSiT1WnDqaJ9k3gQrTpOQSwUKzNEVpp5AY6fDH8,1130
4
- camel/agents/chat_agent.py,sha256=ikYGo5ahcmubb5OHNcHlehTC0adnGxCMx0iKPnyUYoU,35760
4
+ camel/agents/chat_agent.py,sha256=cIAGXDTbZVrVsq8UsZRv8Et9eAx-lFIT73DsYTVopo0,36276
5
5
  camel/agents/critic_agent.py,sha256=To-istnO-9Eb0iabdeIDrgfvkxYYfsdX9xIZiSrc3oM,7493
6
6
  camel/agents/deductive_reasoner_agent.py,sha256=49vwglWYHgXf-VRftdMN9OFGOwqdsXyTt45PP6z-pbg,13473
7
7
  camel/agents/embodied_agent.py,sha256=3ABuiRQXBpplKbuhPY5KNLJyKc6Z8SgXgzIges3ZwVs,7542
@@ -72,7 +72,7 @@ camel/models/ollama_model.py,sha256=FSMwH2-856Zhxusm4B773xBBHdlD3UOw9OAuH5eTJTw,
72
72
  camel/models/open_source_model.py,sha256=p5a2sCeZl5SyrgkygClndOrHEjpJxmyhE1CqKE2fZSw,6363
73
73
  camel/models/openai_audio_models.py,sha256=_ddOxqzFZCVZaK6h33Z0THU6HXk2XlJTxVWquZ3oOaQ,10042
74
74
  camel/models/openai_compatibility_model.py,sha256=7h1zSFBgg_mQojFvtSqC54tcZOZY0NFsZ7ZNlns5CWk,4229
75
- camel/models/openai_model.py,sha256=uOtiLmbdH7sDKqk9oV0i1HEVni_4ApPXCukShZwQDKA,4611
75
+ camel/models/openai_model.py,sha256=27NbN0bU_cAPmWjwsWceNO4zW8WS2j3P_YWNTXeg1O8,5464
76
76
  camel/models/reka_model.py,sha256=_ERZvtkK0Gd7GUx3f4VVqqtH093clVMoJfa896t9f2M,8043
77
77
  camel/models/samba_model.py,sha256=CgAYMIVJFAEoyCOsYS7qD_bvWhzOkvA6SD5nGBClbzE,17699
78
78
  camel/models/stub_model.py,sha256=DuqaBsS55STSbcLJsk025Uwo_u4ixrSSKqKEoZj2ihY,3680
@@ -132,13 +132,13 @@ camel/terminators/__init__.py,sha256=pE7fcfDUNngdbm1BhzSQPRMXNbdd28rl9YbF4gKWwXE
132
132
  camel/terminators/base.py,sha256=TSkl3maNEsdjyAniJaSgFfD4UF8RQ1LwNIiGw0dN8Gg,1396
133
133
  camel/terminators/response_terminator.py,sha256=zcXuigbvlclUoBv4xcVbfU36ZohUT1RhI-rSnukloUY,4951
134
134
  camel/terminators/token_limit_terminator.py,sha256=mK30wVUnoqNAvIo-wxkqY5gUSNay2M04rsAktKqoiOI,2087
135
- camel/toolkits/__init__.py,sha256=CfWQm901AVP_Eq-PMxJAej8EZ9ZAUoWDPnGlCJkkZL4,2326
135
+ camel/toolkits/__init__.py,sha256=g5xQo15tx1WiR6MEHS6IXayLSnwSWk88VK7dosEG79M,2033
136
136
  camel/toolkits/base.py,sha256=ez04Ei8jwIAws023bM19EGkOPUkQMouULqBvOKfM4kM,986
137
137
  camel/toolkits/code_execution.py,sha256=fWBhn1_3adiv7YYuA0gJzEBlc_dYNS6_hVtDbgB-zX0,2425
138
138
  camel/toolkits/dalle_toolkit.py,sha256=IalDFfNCz58LMRdCZNSJfLMiauHGBGN9XNRV7pzuf28,5261
139
139
  camel/toolkits/github_toolkit.py,sha256=ZauRY-kW8nx_L6igVEF62hD16j3KhqU2r49t1j6hO78,10979
140
- camel/toolkits/google_maps_toolkit.py,sha256=o81DvsOaqmpk-EUkMHlXwEoM7JOvdY8eInTsgTF8EFs,12204
141
- camel/toolkits/linkedin_toolkit.py,sha256=gdqj-6XnVUH-YpkZMS042t-FQ4yB1KRj3syCwjfLrnw,8004
140
+ camel/toolkits/google_maps_toolkit.py,sha256=7kTWBp6hzh10MryFY4RLIBAWD-9fjiecHIQcRm0OsvA,11972
141
+ camel/toolkits/linkedin_toolkit.py,sha256=JgO8vpuum_KBijvKvDSjM9QpRPedT1azVSZHJb4EtfM,7933
142
142
  camel/toolkits/math_toolkit.py,sha256=r-85DHvihR87DU6n_W75pecV1P9xV3Hylfp6u-ue7T4,2521
143
143
  camel/toolkits/open_api_specs/biztoc/__init__.py,sha256=f3LXNDzN2XWWoF2D0nesG8VuEA6Zd14i2aiTDbCm5bA,708
144
144
  camel/toolkits/open_api_specs/biztoc/ai-plugin.json,sha256=IJinQbLv5MFPGFwdN7PbOhwArFVExSEZdJspe-mOBIo,866
@@ -165,13 +165,13 @@ camel/toolkits/open_api_specs/web_scraper/ai-plugin.json,sha256=jjHvbj0DQ4AYcL9J
165
165
  camel/toolkits/open_api_specs/web_scraper/openapi.yaml,sha256=u_WalQ01e8W1D27VnZviOylpGmJ-zssYrfAgkzqdoyk,2191
166
166
  camel/toolkits/open_api_specs/web_scraper/paths/__init__.py,sha256=f3LXNDzN2XWWoF2D0nesG8VuEA6Zd14i2aiTDbCm5bA,708
167
167
  camel/toolkits/open_api_specs/web_scraper/paths/scraper.py,sha256=SQGbFkshLN4xm-Ya49ssbSvaU1nFVNFYhWsEPYVeFe0,1123
168
- camel/toolkits/open_api_toolkit.py,sha256=rbQrhY6gHoZi9kiX9138pah9qZ2S8K5Vex1zFGWeCK8,23403
168
+ camel/toolkits/open_api_toolkit.py,sha256=dwXd-msNKVAOmqF1WIkdsK8bcOjDH9rV2sT1AJy8pMY,23334
169
169
  camel/toolkits/openai_function.py,sha256=eaE441qxLvuRKr_WrpYLGkr5P2Nav07VVdR29n76RkU,14767
170
- camel/toolkits/reddit_toolkit.py,sha256=FMHK7k9UHN-IqdabqyBavpo0ZOloveuPsOe3Ou-tq4o,8975
171
- camel/toolkits/retrieval_toolkit.py,sha256=UFByIxMB8m_C8HH-a65MeBJJACoJcVrcKMU9TGzm_SI,3828
170
+ camel/toolkits/reddit_toolkit.py,sha256=zVojG_dM_ZbU8lZDM7AnxfMsL2JVWnNYdWqvdYUwVeM,8908
171
+ camel/toolkits/retrieval_toolkit.py,sha256=qE1IS2WZnFtnxvj4t7eSUYMhKpK5-4ifExbIBgLEPT8,3713
172
172
  camel/toolkits/search_toolkit.py,sha256=vXe026bQpLic09iwY5PN4RS6SXeHYBBkjfnOlJYB670,12943
173
- camel/toolkits/slack_toolkit.py,sha256=JdgDJe7iExTmG7dDXOG6v5KpVjZ6_My_d_WFTYSxkw4,10839
174
- camel/toolkits/twitter_toolkit.py,sha256=oQw8wRkU7iDxaocsmWvio4pU75pmq6FJAorPdQ2xEAE,19810
173
+ camel/toolkits/slack_toolkit.py,sha256=gblCbN_RCsOdgo1GGUF-R8YJneNRjezJMHhYoRFjCE0,10774
174
+ camel/toolkits/twitter_toolkit.py,sha256=0QYLlsg4hUVev2Z0hPJHksDNHG_54IiVHsB3IxCqrXs,19741
175
175
  camel/toolkits/weather_toolkit.py,sha256=n4YrUI_jTIH7oqH918IdHbXLgfQ2BPGIWWK8Jp8G1Uw,7054
176
176
  camel/types/__init__.py,sha256=ArKXATj3z_Vv4ISmROVeo6Mv3tj5kE1dTkqfgwyxVY4,1975
177
177
  camel/types/enums.py,sha256=APqZIKtR2tVbUe-1JZWi7a50gjjDC7QHw9A0eKJuefA,17642
@@ -180,7 +180,7 @@ camel/utils/__init__.py,sha256=IdI9v0FetNR-nx-Hg4bmNHoYto6Xfcs_uaomksdewmo,2303
180
180
  camel/utils/async_func.py,sha256=SLo8KPkrNKdsONvFf3KBb33EgFn4gH2EKSX1aI_LKes,1578
181
181
  camel/utils/commons.py,sha256=y7eng5QF5Hkt5tuNhtEOJycTIq9hXymrUuwIS5nRad4,16481
182
182
  camel/utils/constants.py,sha256=8n4F8Y-DZy4z2F0hRvAq6f-d9SbS59kK5FyLrnJ3mkY,1360
183
- camel/utils/token_counting.py,sha256=HLzpKADWxn8g9YnXaiUnIeIkbic6wkxmGJb17MT7VyI,21114
183
+ camel/utils/token_counting.py,sha256=AVGml8X_qq3rPdzw2tc9I3n-oEkGyNH_vPsedhVtew0,21318
184
184
  camel/workforce/__init__.py,sha256=6jwJWDlESEqcnWCm61WCyjzFUF6KLzXA_fGI86rHfiE,878
185
185
  camel/workforce/base.py,sha256=lEHqgOV1tmsy7y4wuuKClcDkoPCRvXVdMrBngsM_6yY,1722
186
186
  camel/workforce/manager_node.py,sha256=eMmsOAoy0Wtk92b_06GhGnwKDgrTo0w-UgQorkh-az0,11529
@@ -191,6 +191,6 @@ camel/workforce/utils.py,sha256=Z-kODz5PMPtfeKKVqpcQq-b-B8oqC7XSwi_F3__Ijhs,3526
191
191
  camel/workforce/worker_node.py,sha256=wsRqk2rugCvvkcmCzvn-y-gQuyuJGAG8PIr1KtgqJFw,3878
192
192
  camel/workforce/workforce.py,sha256=SVJJgSSkYvk05RgL9oaJzHwzziH7u51KLINRuzLB8BI,1773
193
193
  camel/workforce/workforce_prompt.py,sha256=cAWYEIA0rau5itEekSoUIFttBzpKM9RzB6x-mfukGSU,4665
194
- camel_ai-0.1.9.dist-info/METADATA,sha256=pHRs4KpziV_Nc7wl43oQfYqYNVVo15HdgI9XqgzC1yc,24655
195
- camel_ai-0.1.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
196
- camel_ai-0.1.9.dist-info/RECORD,,
194
+ camel_ai-0.2.0.dist-info/METADATA,sha256=6mTZQestY-Rvn1pkyLO2-DycdgKFKy6YO7yDf37Vmq8,24677
195
+ camel_ai-0.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
196
+ camel_ai-0.2.0.dist-info/RECORD,,