camel-ai 0.2.29__py3-none-any.whl → 0.2.30__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.

@@ -1049,7 +1049,7 @@ check the history actions to avoid the same mistakes.
1049
1049
  - `action_code`: The action code you want to take. It is only one step action
1050
1050
  code, without any other texts (such as annotation)
1051
1051
 
1052
- Here are an example of the output:
1052
+ Here is two example of the output:
1053
1053
  ```json
1054
1054
  {{
1055
1055
  "observation": [IMAGE_DESCRIPTION],
@@ -1057,6 +1057,12 @@ Here are an example of the output:
1057
1057
  "action_code": "fill_input_id([ID], [TEXT])"
1058
1058
  }}
1059
1059
 
1060
+ {{
1061
+ "observation": "The current page is a CAPTCHA verification page on Amazon. It asks the user to ..",
1062
+ "reasoning": "To proceed with the task of searching for products, I need to complete..",
1063
+ "action_code": "fill_input_id(3, 'AUXPMR')"
1064
+ }}
1065
+
1060
1066
  Here are some tips for you:
1061
1067
  - Never forget the overall question: **{task_prompt}**
1062
1068
  - Maybe after a certain operation (e.g. click_id), the page content has not
@@ -1150,6 +1156,58 @@ out the information you need. Sometimes they are extremely useful.
1150
1156
 
1151
1157
  return False
1152
1158
 
1159
+ def _fix_action_code(action_code: str) -> str:
1160
+ r"""Fix potential missing quotes in action code"""
1161
+
1162
+ match = re.match(r'(\w+)\((.*)\)', action_code)
1163
+ if not match:
1164
+ return action_code
1165
+
1166
+ func_name, args_str = match.groups()
1167
+
1168
+ args = []
1169
+ current_arg = ""
1170
+ in_quotes = False
1171
+ quote_char = None
1172
+
1173
+ for char in args_str:
1174
+ if char in ['"', "'"]:
1175
+ if not in_quotes:
1176
+ in_quotes = True
1177
+ quote_char = char
1178
+ current_arg += char
1179
+ elif char == quote_char:
1180
+ in_quotes = False
1181
+ quote_char = None
1182
+ current_arg += char
1183
+ else:
1184
+ current_arg += char
1185
+ elif char == ',' and not in_quotes:
1186
+ args.append(current_arg.strip())
1187
+ current_arg = ""
1188
+ else:
1189
+ current_arg += char
1190
+
1191
+ if current_arg:
1192
+ args.append(current_arg.strip())
1193
+
1194
+ fixed_args = []
1195
+ for arg in args:
1196
+ if (
1197
+ (arg.startswith('"') and arg.endswith('"'))
1198
+ or (arg.startswith("'") and arg.endswith("'"))
1199
+ or re.match(r'^-?\d+(\.\d+)?$', arg)
1200
+ or re.match(r'^-?\d+\.?\d*[eE][-+]?\d+$', arg)
1201
+ or re.match(r'^0[xX][0-9a-fA-F]+$', arg)
1202
+ ):
1203
+ fixed_args.append(arg)
1204
+
1205
+ else:
1206
+ fixed_args.append(f"'{arg}'")
1207
+
1208
+ return f"{func_name}({', '.join(fixed_args)})"
1209
+
1210
+ action_code = _fix_action_code(action_code)
1153
1211
  prefix = "self.browser."
1154
1212
  code = f"{prefix}{action_code}"
1155
1213
 
@@ -766,6 +766,75 @@ class SearchToolkit(BaseToolkit):
766
766
  except requests.exceptions.RequestException as e:
767
767
  return {"error": f"Bocha AI search failed: {e!s}"}
768
768
 
769
+ def search_baidu(self, query: str, max_results: int = 5) -> Dict[str, Any]:
770
+ r"""Search Baidu using web scraping to retrieve relevant search
771
+ results. This method queries Baidu's search engine and extracts search
772
+ results including titles, descriptions, and URLs.
773
+
774
+ Args:
775
+ query (str): Search query string to submit to Baidu.
776
+ max_results (int): Maximum number of results to return.
777
+ (default: :obj:`5`)
778
+
779
+ Returns:
780
+ Dict[str, Any]: A dictionary containing search results or error
781
+ message.
782
+ """
783
+ from bs4 import BeautifulSoup
784
+
785
+ try:
786
+ url = "https://www.baidu.com/s"
787
+ headers = {
788
+ "User-Agent": (
789
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
790
+ "AppleWebKit/537.36 (KHTML, like Gecko) "
791
+ "Chrome/120.0.0.0 Safari/537.36"
792
+ ),
793
+ "Referer": "https://www.baidu.com",
794
+ }
795
+ params = {"wd": query, "rn": str(max_results)}
796
+
797
+ response = requests.get(url, headers=headers, params=params)
798
+ response.encoding = "utf-8"
799
+
800
+ soup = BeautifulSoup(response.text, "html.parser")
801
+
802
+ results = []
803
+ for idx, item in enumerate(soup.select(".result"), 1):
804
+ title_element = item.select_one("h3 > a")
805
+ title = (
806
+ title_element.get_text(strip=True) if title_element else ""
807
+ )
808
+
809
+ link = title_element["href"] if title_element else ""
810
+
811
+ desc_element = item.select_one(".c-abstract, .c-span-last")
812
+ desc = (
813
+ desc_element.get_text(strip=True) if desc_element else ""
814
+ )
815
+
816
+ results.append(
817
+ {
818
+ "result_id": idx,
819
+ "title": title,
820
+ "description": desc,
821
+ "url": link,
822
+ }
823
+ )
824
+ if len(results) >= max_results:
825
+ break
826
+
827
+ if not results:
828
+ print(
829
+ "Warning: No results found. Check "
830
+ "if Baidu HTML structure has changed."
831
+ )
832
+
833
+ return {"results": results}
834
+
835
+ except Exception as e:
836
+ return {"error": f"Baidu scraping error: {e!s}"}
837
+
769
838
  def get_tools(self) -> List[FunctionTool]:
770
839
  r"""Returns a list of FunctionTool objects representing the
771
840
  functions in the toolkit.
@@ -783,4 +852,5 @@ class SearchToolkit(BaseToolkit):
783
852
  FunctionTool(self.tavily_search),
784
853
  FunctionTool(self.search_brave),
785
854
  FunctionTool(self.search_bocha),
855
+ FunctionTool(self.search_baidu),
786
856
  ]
camel/utils/commons.py CHANGED
@@ -336,7 +336,7 @@ def api_keys_required(
336
336
  key_way = "https://api.moonshot.cn/v1"
337
337
  elif env_var_name == 'NVIDIA_API_KEY':
338
338
  key_way = "https://integrate.api.nvidia.com/"
339
- elif env_var_name == 'OPENAI_COMPATIBILIY_API_KEY':
339
+ elif env_var_name == 'OPENAI_COMPATIBILITY_API_KEY':
340
340
  key_way = "https://platform.openai.com/docs/overview"
341
341
  elif env_var_name == 'QWEN_API_KEY':
342
342
  key_way = "https://tongyi.aliyun.com/"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: camel-ai
3
- Version: 0.2.29
3
+ Version: 0.2.30
4
4
  Summary: Communicative Agents for AI Society Study
5
5
  Project-URL: Homepage, https://www.camel-ai.org/
6
6
  Project-URL: Repository, https://github.com/camel-ai/camel
@@ -239,6 +239,7 @@ Requires-Dist: pytest-asyncio<0.24,>=0.23.0; extra == 'test'
239
239
  Requires-Dist: pytest<8,>=7; extra == 'test'
240
240
  Provides-Extra: web-tools
241
241
  Requires-Dist: apify-client<2,>=1.8.1; extra == 'web-tools'
242
+ Requires-Dist: beautifulsoup4<5,>=4; extra == 'web-tools'
242
243
  Requires-Dist: dappier<0.4,>=0.3.3; extra == 'web-tools'
243
244
  Requires-Dist: duckduckgo-search<7,>=6.3.5; extra == 'web-tools'
244
245
  Requires-Dist: fastapi>=0.115.11; extra == 'web-tools'
@@ -1,7 +1,7 @@
1
- camel/__init__.py,sha256=YKaTrUHy95ttm15Tixm09ZAtM9rfYZdrGHowGgC3MTw,912
1
+ camel/__init__.py,sha256=6O1jJXOrxsfBIdPbCn45WbL1VejUHMYfY9JhXmw-uco,912
2
2
  camel/generators.py,sha256=JRqj9_m1PF4qT6UtybzTQ-KBT9MJQt18OAAYvQ_fr2o,13844
3
3
  camel/human.py,sha256=9X09UmxI2JqQnhrFfnZ3B9EzFmVfdSWQcjLWTIXKXe0,4962
4
- camel/logger.py,sha256=j6mPsLJyKOn16o6Um57882mHsURQ8h-jia6Jd_34wRA,4239
4
+ camel/logger.py,sha256=rZVeOVYuQ9RYJ5Tqyv0usqy0g4zaVEq4qSfZ9nd2640,5755
5
5
  camel/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  camel/agents/__init__.py,sha256=LcS4m8s97-yADfznvcaAdUe9W0E9h3m6zrSc9H6m9so,1545
7
7
  camel/agents/_types.py,sha256=GGpZ9FGq_SGla_Vz-YcYW7KMQzwE8lfM4Ga0QaGzKxk,1423
@@ -82,18 +82,22 @@ camel/datahubs/__init__.py,sha256=1a8fRuzgirO2pHtPnuisZ76iF_AN9GxMFq9gwFKWE5I,90
82
82
  camel/datahubs/base.py,sha256=4QKWiJaeL5ReQpyTAbOtzHs-2CzAYbVyoMngYwdpZGU,4357
83
83
  camel/datahubs/huggingface.py,sha256=m1LDBv9ESNQINfiZdBpuVD5Zr1_iZqo-5LBYHXHhXw8,14853
84
84
  camel/datahubs/models.py,sha256=tGb9OP_aomIhnwc0VapJjTg9PmyV_QCp5to9sABXF0Y,978
85
- camel/datasets/__init__.py,sha256=XurV8ZviglsSFH8aUDKYNfSftWr-j2WT8TOxr_iXI-M,859
86
- camel/datasets/base.py,sha256=QwROpodon363eE2h7Zm5DYOOhrRdgM6Rnn7dgIS4bVk,22795
85
+ camel/datasets/__init__.py,sha256=1hzkuN_B3i-VF6NbkyqyJkBbPzy0_qQImJcq-807VR4,945
86
+ camel/datasets/base_generator.py,sha256=rB7f5qPBRZ_BWT12GpJhQd9LuVPXD7NX-8zQeS3d0iE,12236
87
+ camel/datasets/models.py,sha256=H0ksOfkwiPFjVr9xHMYbVoj8YTTWaLI2GYiWqesmiVs,2228
88
+ camel/datasets/static_dataset.py,sha256=3r_WeyzY5WsnP9iHxE-q25TIDlWncS55Qbc-ztHrfUU,12220
87
89
  camel/embeddings/__init__.py,sha256=YKCFO_YVY-x4A4uWmRuoIEtltrilBmC17DkCcK4zSj8,1263
88
90
  camel/embeddings/base.py,sha256=mxqFkWh2AfbxuVKPOqVx16fCznmuSh9QXGjaEeZHvoY,2190
89
91
  camel/embeddings/jina_embedding.py,sha256=6aakojtsJ6KLp3nqYLhEOtoFm2shoXlRzxb1YYN_uwo,6623
90
92
  camel/embeddings/mistral_embedding.py,sha256=JaHjcHrc4U216QfGA4NxOSLrgYB9lM19VR2mIMAkuvk,3287
91
- camel/embeddings/openai_compatible_embedding.py,sha256=48T1fNUkgifoPiVHPJ7HJERekP1sENy3t07S1ENiwWk,3158
93
+ camel/embeddings/openai_compatible_embedding.py,sha256=k38rer_BKvxuvcNbzXlWkeSGn0USaibYULXD886SKEo,3162
92
94
  camel/embeddings/openai_embedding.py,sha256=9kJBKUWkjEyxtn50V4MDjuOT2syIwWEnZeEHkbqIocg,3936
93
95
  camel/embeddings/sentence_transformers_embeddings.py,sha256=E7a8lN50CtDBsFO-NOFQ6qfCnbH41O0_kTTg7dG3sOo,2724
94
96
  camel/embeddings/vlm_embedding.py,sha256=HZFdcz1YzkFPzMj45_jaCVmDQJyccoXN561aLWlrYmo,5497
95
- camel/environments/__init__.py,sha256=c2NsLuRbuqDftBSfw9pHMPQW98E0-py2n5AvTZvS74E,767
96
- camel/environments/base.py,sha256=2JhcUJMJhujsS8Cz2-HUxYEiFMbICtGMYKcqukftTTE,17909
97
+ camel/environments/__init__.py,sha256=nWFEYK-QcRX0WskLVsXn4iP_pK2liL-iHKG7DSO0zTU,969
98
+ camel/environments/models.py,sha256=yrrnJd-e6vYjfXMkYMdh0ABn25SSzLY_7XgSniOWOOE,3839
99
+ camel/environments/multi_step.py,sha256=rEEMMHip5ZVEWpNj7miws5wALlujtUbFZkWDsy7ofHM,8360
100
+ camel/environments/single_step.py,sha256=aKQmqWLaQrxwzZ-VAyByF609XhiNSYFCejFuPOkGo1U,9519
97
101
  camel/extractors/__init__.py,sha256=nrEI35-70NGHk-Y7jvyc4i0f1NlpJArVBqAmcfpaBng,811
98
102
  camel/extractors/base.py,sha256=3jvuZpq27nlADDCX3GfubOpeb_zt-E9rzxF3x4lYm8s,10404
99
103
  camel/extractors/python_strategies.py,sha256=k8q4BIAhPZnCSN2LqPaZVrhF56y3Y4cZ6ddn79jcIXE,7825
@@ -156,7 +160,7 @@ camel/models/nemotron_model.py,sha256=jJrW8tpTlEJDT1FjflB9krhgEQhD5KBeLmyUIcZvWP
156
160
  camel/models/nvidia_model.py,sha256=lqp1iPwVDq6zSQ9B0SyBZ48Z3J5WbXwPshwlhj1ogZ8,6711
157
161
  camel/models/ollama_model.py,sha256=byJ0YbMlilEFRKJZIot-MPUcojwMHLIaBES0a1SURtg,10604
158
162
  camel/models/openai_audio_models.py,sha256=fYpxFvxT8p93KVb5BYODTuI5wdNXV9pu_bvxfARgVYk,13193
159
- camel/models/openai_compatible_model.py,sha256=Nmps04Fo0ILmynE8wbKVzTrQ0VDyOrDR1ICD1nGrjd0,8142
163
+ camel/models/openai_compatible_model.py,sha256=GswUEFqVRJGCUb1IwgkR_SOIKCX7LrA4kfqS2xXP0ro,8166
160
164
  camel/models/openai_model.py,sha256=CbfD9yVtAltyqdFpjnLXncFnmaGPDZq8JhJDaSfG0pc,10186
161
165
  camel/models/qwen_model.py,sha256=_LeeB0yrXRMI-gZOEEOHg0bWNOJpuQHf2G7u40--3r8,7064
162
166
  camel/models/reka_model.py,sha256=15DscZf3lbqsIzm6kzjzDrhblBt1_0xlphT4isuQMu0,10146
@@ -261,7 +265,7 @@ camel/toolkits/arxiv_toolkit.py,sha256=d0Zn8LQGENhtlZ0BHlDr1pUV8xHOc6TOenAaKgbel
261
265
  camel/toolkits/ask_news_toolkit.py,sha256=PAxio8I2eTau9TgOu1jyFC9fsHhvGb-aLIkroWPtwx4,23268
262
266
  camel/toolkits/audio_analysis_toolkit.py,sha256=LC0C6SEIwko8HqkT-C3ub6Ila2PfuIbKLBOEjrrF6BE,8552
263
267
  camel/toolkits/base.py,sha256=7WRovKrz380b25lYdwT-2FCXzS3dkllOjT53hmmCg_I,1999
264
- camel/toolkits/browser_toolkit.py,sha256=Pbw7CoiHPtbFQagmXvCUiVHihCXwaN6uUbwCAfC-jso,51016
268
+ camel/toolkits/browser_toolkit.py,sha256=c0zPhQmyV7I37LiwQSpb4WMN8lMS_aTILgPJS8eJfqc,53078
265
269
  camel/toolkits/code_execution.py,sha256=seqTtjulBZXH4qd5m2YAXQaxyL2_n2ekmqsYB-wBxvw,4547
266
270
  camel/toolkits/dalle_toolkit.py,sha256=Usmw3JiJErLQgWSB1qKq_bOACNwbUTQPFc_EsVzTrGo,5115
267
271
  camel/toolkits/dappier_toolkit.py,sha256=_69IAmXE2QSbwGxnSEycaV2XrrkiM5wKI6heM7-4MfU,8175
@@ -287,7 +291,7 @@ camel/toolkits/page_script.js,sha256=gypbuQ_gn_oa3rQDoCN_q-kJ0jND1eSvY-30PufPZmQ
287
291
  camel/toolkits/pubmed_toolkit.py,sha256=vrd5GIhSYt9Z8EHaWkFb0x9i6_TP7pQZc7jlLHSol04,12180
288
292
  camel/toolkits/reddit_toolkit.py,sha256=cTqEq1CRaLq9XxUHkHCmd09tRzb5Mz_bUs2JV58ewrs,8012
289
293
  camel/toolkits/retrieval_toolkit.py,sha256=y_mQtknrSIDDXSyQb-4FY6ahV_mOxkBhDkA2eMIVnz0,3801
290
- camel/toolkits/search_toolkit.py,sha256=KxJMB8tz37uyqlzHSK9X28hSZZMK793aOwkYT8jBnGc,32131
294
+ camel/toolkits/search_toolkit.py,sha256=U0BD80LZCHXgz-Q92FJa73EslbW6asCulUEI6U0jVfo,34631
291
295
  camel/toolkits/semantic_scholar_toolkit.py,sha256=Kp-5rz99rkeUsUmk5ShQdNKJRGVs78hQvCNg-NQMFDk,11547
292
296
  camel/toolkits/slack_toolkit.py,sha256=n8cn3kZIc27B-2KMTRK6Nsdan37SwMqBiBi1PMtuUvQ,10744
293
297
  camel/toolkits/stripe_toolkit.py,sha256=1sCywkpo8mh4E_KwxFKLhAb-G5uZ47NXXQvcddThjqg,9781
@@ -332,7 +336,7 @@ camel/types/agents/__init__.py,sha256=cbvVkogPoZgcwZrgxLH6EtpGXk0kavF79nOic0Dc1v
332
336
  camel/types/agents/tool_calling_record.py,sha256=qa-vLyKvYzWprRkFFl1928xaw9CnfacIebHaqM-oY3s,1814
333
337
  camel/utils/__init__.py,sha256=tLftKYfEu1QbMgiyT479_5htxlfFcfYxDHhjEYRFups,2628
334
338
  camel/utils/async_func.py,sha256=KqoktGSWjZBuAMQ2CV0X6FRgHGlzCKLfeaWvp-f1Qz8,1568
335
- camel/utils/commons.py,sha256=YahXAWppD6QSlq9Ap08TEh-7vXSQaqlvBAAHLmGrNjU,32890
339
+ camel/utils/commons.py,sha256=DfWCdoW487_FmlTFfdIkDi7wZCEs0jpOWQxfGOHyN28,32891
336
340
  camel/utils/constants.py,sha256=MQD3bgLIq_NATp0D1iFkrwfkCwVX-PAOSXheTkkEdkY,1410
337
341
  camel/utils/deduplication.py,sha256=UHikAtOW1TTDunf2t_wa2kFbmkrXWf7HfOKwLvwCxzo,8958
338
342
  camel/utils/response_format.py,sha256=9KrbwtOM9cA3LSjTgLiK7oKy-53_uMh1cvpyNwwJpng,2419
@@ -341,7 +345,7 @@ camel/verifiers/__init__.py,sha256=p6UEyvaOlwUQaFACGB4C07fL1xSnpTouElt19YRuneQ,9
341
345
  camel/verifiers/base.py,sha256=efWZV9g58IHzJ24U4zr109y34CaAi8tV9WZPMCzP3YI,12017
342
346
  camel/verifiers/models.py,sha256=hC6m_YxEX-mqi_tkCNZHZWLBWf04ZTyv5vfKR-BEyU4,2818
343
347
  camel/verifiers/python_verifier.py,sha256=bj-UGxeJTZzxVVa3a8IEQ1lNOpSaaW3JdGnUEoPeQD0,7519
344
- camel_ai-0.2.29.dist-info/METADATA,sha256=n78BBxySRMo1ZRH_6VfJUDUuyTEMioYbJGOtl7B7tWc,37988
345
- camel_ai-0.2.29.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
346
- camel_ai-0.2.29.dist-info/licenses/LICENSE,sha256=id0nB2my5kG0xXeimIu5zZrbHLS6EQvxvkKkzIHaT2k,11343
347
- camel_ai-0.2.29.dist-info/RECORD,,
348
+ camel_ai-0.2.30.dist-info/METADATA,sha256=j42j5MKgNDUVJxG8ajZ5dZcMe2IufGqWsn6mNTF1ZzM,38046
349
+ camel_ai-0.2.30.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
350
+ camel_ai-0.2.30.dist-info/licenses/LICENSE,sha256=id0nB2my5kG0xXeimIu5zZrbHLS6EQvxvkKkzIHaT2k,11343
351
+ camel_ai-0.2.30.dist-info/RECORD,,