camel-ai 0.2.73a8__py3-none-any.whl → 0.2.73a9__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
@@ -14,7 +14,7 @@
14
14
 
15
15
  from camel.logger import disable_logging, enable_logging, set_log_level
16
16
 
17
- __version__ = '0.2.73a8'
17
+ __version__ = '0.2.73a9'
18
18
 
19
19
  __all__ = [
20
20
  '__version__',
@@ -103,34 +103,6 @@ class Mem0Storage(BaseKeyValueStorage):
103
103
  }
104
104
  return {k: v for k, v in options.items() if v is not None}
105
105
 
106
- def _prepare_filters(
107
- self,
108
- agent_id: Optional[str] = None,
109
- user_id: Optional[str] = None,
110
- filters: Optional[Dict[str, Any]] = None,
111
- ) -> Dict[str, Any]:
112
- r"""Helper method to prepare filters for Mem0 API calls.
113
-
114
- Args:
115
- agent_id (Optional[str], optional): Agent ID to filter by
116
- (default: :obj:`None`).
117
- user_id (Optional[str], optional): User ID to filter by (default:
118
- :obj:`None`).
119
- filters (Optional[Dict[str, Any]], optional): Additional filters
120
- (default: :obj:`None`).
121
-
122
- Returns:
123
- Dict[str, Any]: Prepared filters dictionary for API calls.
124
- """
125
- base_filters: Dict[str, Any] = {"AND": []}
126
- if filters:
127
- base_filters["AND"].append(filters)
128
- if agent_id or self.agent_id:
129
- base_filters["AND"].append({"agent_id": agent_id or self.agent_id})
130
- if user_id or self.user_id:
131
- base_filters["AND"].append({"user_id": user_id or self.user_id})
132
- return base_filters if base_filters["AND"] else {}
133
-
134
106
  def _prepare_messages(
135
107
  self,
136
108
  records: List[Dict[str, Any]],
@@ -168,7 +140,6 @@ class Mem0Storage(BaseKeyValueStorage):
168
140
  self.client.add(messages, **options)
169
141
  except Exception as e:
170
142
  logger.error(f"Error adding memory: {e}")
171
- logger.error(f"Error: {e}")
172
143
 
173
144
  def load(self) -> List[Dict[str, Any]]:
174
145
  r"""Loads all stored records from the Mem0 storage system.
@@ -178,11 +149,18 @@ class Mem0Storage(BaseKeyValueStorage):
178
149
  represents a stored record.
179
150
  """
180
151
  try:
181
- filters = self._prepare_filters(
182
- agent_id=self.agent_id,
183
- user_id=self.user_id,
184
- )
185
- results = self.client.get_all(version="v2", **filters)
152
+ # Build kwargs for get_all
153
+ kwargs = {}
154
+ if self.agent_id:
155
+ kwargs['agent_id'] = self.agent_id
156
+ if self.user_id:
157
+ kwargs['user_id'] = self.user_id
158
+
159
+ # If no filters available, return empty list
160
+ if not kwargs:
161
+ return []
162
+
163
+ results = self.client.get_all(**kwargs)
186
164
 
187
165
  # Transform results into MemoryRecord objects
188
166
  transformed_results = []
@@ -190,35 +168,58 @@ class Mem0Storage(BaseKeyValueStorage):
190
168
  memory_record = MemoryRecord(
191
169
  uuid=UUID(result["id"]),
192
170
  message=BaseMessage(
193
- role_name="user",
171
+ role_name="memory",
194
172
  role_type=RoleType.USER,
195
- meta_dict={},
173
+ meta_dict=result.get("metadata", {}),
196
174
  content=result["memory"],
197
175
  ),
198
176
  role_at_backend=OpenAIBackendRole.USER,
199
177
  extra_info=result.get("metadata", {}),
200
178
  timestamp=datetime.fromisoformat(
201
- result["created_at"]
179
+ result["created_at"].replace('Z', '+00:00')
202
180
  ).timestamp(),
203
- agent_id=result.get("agent_id", ""),
181
+ agent_id=result.get("agent_id", self.agent_id or ""),
204
182
  )
205
183
  transformed_results.append(memory_record.to_dict())
206
184
 
207
185
  return transformed_results
208
186
  except Exception as e:
209
- logger.error(f"Error searching memories: {e}")
187
+ logger.error(f"Error loading memories: {e}")
210
188
  return []
211
189
 
212
190
  def clear(
213
191
  self,
192
+ agent_id: Optional[str] = None,
193
+ user_id: Optional[str] = None,
214
194
  ) -> None:
215
- r"""Removes all records from the Mem0 storage system."""
195
+ r"""Removes all records from the Mem0 storage system.
196
+
197
+ Args:
198
+ agent_id (Optional[str]): Specific agent ID to clear memories for.
199
+ user_id (Optional[str]): Specific user ID to clear memories for.
200
+ """
216
201
  try:
217
- filters = self._prepare_filters(
218
- agent_id=self.agent_id,
219
- user_id=self.user_id,
220
- )
221
- self.client.delete_users(**filters)
202
+ # Use provided IDs or fall back to instance defaults
203
+ target_user_id = user_id or self.user_id
204
+ target_agent_id = agent_id or self.agent_id
205
+
206
+ # Build kwargs for delete_users method
207
+ kwargs = {}
208
+ if target_user_id:
209
+ kwargs['user_id'] = target_user_id
210
+ if target_agent_id:
211
+ kwargs['agent_id'] = target_agent_id
212
+
213
+ if kwargs:
214
+ # Use delete_users (plural) - this is the correct method name
215
+ self.client.delete_users(**kwargs)
216
+ logger.info(
217
+ f"Successfully cleared memories with filters: {kwargs}"
218
+ )
219
+ else:
220
+ logger.warning(
221
+ "No user_id or agent_id available for clearing memories"
222
+ )
223
+
222
224
  except Exception as e:
223
225
  logger.error(f"Error deleting memories: {e}")
224
- logger.error(f"Error: {e}")
@@ -840,6 +840,69 @@ class FileWriteToolkit(BaseToolkit):
840
840
 
841
841
  return text
842
842
 
843
+ def _ensure_html_utf8_meta(self, content: str) -> str:
844
+ r"""Ensure HTML content has UTF-8 meta tag.
845
+
846
+ Args:
847
+ content (str): The HTML content.
848
+
849
+ Returns:
850
+ str: HTML content with UTF-8 meta tag.
851
+ """
852
+ # Check if content already has a charset meta tag
853
+ has_charset = re.search(
854
+ r'<meta[^>]*charset[^>]*>', content, re.IGNORECASE
855
+ )
856
+
857
+ # UTF-8 meta tag
858
+ utf8_meta = '<meta charset="utf-8">'
859
+
860
+ if has_charset:
861
+ # Replace existing charset with UTF-8
862
+ content = re.sub(
863
+ r'<meta[^>]*charset[^>]*>',
864
+ utf8_meta,
865
+ content,
866
+ flags=re.IGNORECASE,
867
+ )
868
+ else:
869
+ # Add UTF-8 meta tag
870
+ # Try to find <head> tag
871
+ head_match = re.search(r'<head[^>]*>', content, re.IGNORECASE)
872
+ if head_match:
873
+ # Insert after <head> tag
874
+ insert_pos = head_match.end()
875
+ content = (
876
+ content[:insert_pos]
877
+ + '\n '
878
+ + utf8_meta
879
+ + content[insert_pos:]
880
+ )
881
+ else:
882
+ # No <head> tag found, check if there's <html> tag
883
+ html_match = re.search(r'<html[^>]*>', content, re.IGNORECASE)
884
+ if html_match:
885
+ # Insert <head> with meta tag after <html>
886
+ insert_pos = html_match.end()
887
+ content = (
888
+ content[:insert_pos]
889
+ + '\n<head>\n '
890
+ + utf8_meta
891
+ + '\n</head>'
892
+ + content[insert_pos:]
893
+ )
894
+ else:
895
+ # No proper HTML structure, wrap content
896
+ content = (
897
+ '<!DOCTYPE html>\n<html>\n<head>\n '
898
+ + utf8_meta
899
+ + '\n</head>\n<body>\n'
900
+ + content
901
+ + '\n</body>\n</html>'
902
+ )
903
+
904
+ return content
905
+
843
906
  def _write_csv_file(
844
907
  self,
845
908
  file_path: Path,
@@ -901,6 +964,10 @@ class FileWriteToolkit(BaseToolkit):
901
964
  content (str): The content to write.
902
965
  encoding (str): Character encoding to use. (default: :obj:`utf-8`)
903
966
  """
967
+ # For HTML files, ensure UTF-8 meta tag is present
968
+ if file_path.suffix.lower() in ['.html', '.htm']:
969
+ content = self._ensure_html_utf8_meta(content)
970
+
904
971
  with file_path.open("w", encoding=encoding) as f:
905
972
  f.write(content)
906
973
 
camel/types/enums.py CHANGED
@@ -245,6 +245,7 @@ class ModelType(UnifiedModelType, Enum):
245
245
  QWEN_QWQ_32B = "qwq-32b-preview"
246
246
  QWEN_QVQ_72B = "qvq-72b-preview"
247
247
  QWEN_QWQ_PLUS = "qwq-plus"
248
+ QWEN_3_CODER_PLUS = "qwen3-coder-plus"
248
249
 
249
250
  # Yi models (01-ai)
250
251
  YI_LIGHTNING = "yi-lightning"
@@ -763,6 +764,7 @@ class ModelType(UnifiedModelType, Enum):
763
764
  ModelType.QWEN_PLUS_2025_04_28,
764
765
  ModelType.QWEN_TURBO_LATEST,
765
766
  ModelType.QWEN_TURBO_2025_04_28,
767
+ ModelType.QWEN_3_CODER_PLUS,
766
768
  }
767
769
 
768
770
  @property
@@ -1306,6 +1308,10 @@ class ModelType(UnifiedModelType, Enum):
1306
1308
  ModelType.NOVITA_LLAMA_4_MAVERICK_17B,
1307
1309
  }:
1308
1310
  return 1_048_576
1311
+ elif self in {
1312
+ ModelType.QWEN_3_CODER_PLUS,
1313
+ }:
1314
+ return 1_000_000
1309
1315
  elif self in {
1310
1316
  ModelType.QWEN_LONG,
1311
1317
  ModelType.TOGETHER_LLAMA_4_SCOUT,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: camel-ai
3
- Version: 0.2.73a8
3
+ Version: 0.2.73a9
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
@@ -1,4 +1,4 @@
1
- camel/__init__.py,sha256=_AfDG2a7ery9GuUo4kqCeCo3IdXz3d2V-0ziFUoXkgc,901
1
+ camel/__init__.py,sha256=5x8F3f70sOTYS-YwvaLAyGdigu-jW_3Tncrt3bj-R-s,901
2
2
  camel/generators.py,sha256=JRqj9_m1PF4qT6UtybzTQ-KBT9MJQt18OAAYvQ_fr2o,13844
3
3
  camel/human.py,sha256=Xg8x1cS5KK4bQ1SDByiHZnzsRpvRP-KZViNvmu38xo4,5475
4
4
  camel/logger.py,sha256=WgEwael_eT6D-lVAKHpKIpwXSTjvLbny5jbV1Ab8lnA,5760
@@ -292,7 +292,7 @@ camel/storages/key_value_storages/__init__.py,sha256=qBNx5QwKGa2wydavFYpM5MLVPkq
292
292
  camel/storages/key_value_storages/base.py,sha256=FSfxeLuG7SPvn-Mg-OQxtRKPtQBnRkB7lYeDaFOefpk,2177
293
293
  camel/storages/key_value_storages/in_memory.py,sha256=k04Nx53lYxD5MoqDtBEgZrQYkAQ-zIuU6tqnoNqiHws,1949
294
294
  camel/storages/key_value_storages/json.py,sha256=Jn7-fh2MjSMaVSCCMF_Hu-mAIj6JJ86iwKaSgI-5Uf0,3483
295
- camel/storages/key_value_storages/mem0_cloud.py,sha256=py8-n3in65K9cFnUJTxXKhzE4J0H1BSUWFDD4DT3rPg,8254
295
+ camel/storages/key_value_storages/mem0_cloud.py,sha256=kO6HL__8AwosPY0APv_JaiiOv1jf_Xa2VyZfDlzmOdo,8213
296
296
  camel/storages/key_value_storages/redis.py,sha256=Suo7wxxBXFc0fkJ8qSX2xQ26Ik_YhoKWfTOVQKUl5vA,5720
297
297
  camel/storages/object_storages/__init__.py,sha256=26yATVTD9yVH-p9KueD30JakstTGiDh89GcFtUNNe4U,915
298
298
  camel/storages/object_storages/amazon_s3.py,sha256=9Yvyyyb1LGHxr8REEza7oGopbVtLEfOyXWJc18ZwgqA,7418
@@ -333,7 +333,7 @@ camel/toolkits/dappier_toolkit.py,sha256=OEHOYXX_oXhgbVtWYAy13nO9uXf9i5qEXSwY4Pe
333
333
  camel/toolkits/data_commons_toolkit.py,sha256=aHZUSL1ACpnYGaf1rE2csVKTmXTmN8lMGRUBYhZ_YEk,14168
334
334
  camel/toolkits/edgeone_pages_mcp_toolkit.py,sha256=1TFpAGHUNLggFQeN1OEw7P5laijwnlrCkfxBtgxFuUY,2331
335
335
  camel/toolkits/excel_toolkit.py,sha256=tQaonygk0yDTPZHWWQKG5osTN-R_EawR0bJIKLsLg08,35768
336
- camel/toolkits/file_write_toolkit.py,sha256=d8N8FfmK1fS13sY58PPhJh6M0vq6yh-s1-ltCZQJObg,37044
336
+ camel/toolkits/file_write_toolkit.py,sha256=BIN4c_Tw_24iBu7vDFxVV401UTNqKZkP5p_eOOL_Hmk,39389
337
337
  camel/toolkits/function_tool.py,sha256=3_hE-Khqf556CeebchsPpjIDCynC6vKmUJLdh1EO_js,34295
338
338
  camel/toolkits/github_toolkit.py,sha256=iUyRrjWGAW_iljZVfNyfkm1Vi55wJxK6PsDAQs9pOag,13099
339
339
  camel/toolkits/google_calendar_toolkit.py,sha256=E-sdgdbtNBs_CXbhht9t1dsVr4DsTr5NguHkx4fvSmc,15410
@@ -438,7 +438,7 @@ camel/toolkits/open_api_specs/web_scraper/openapi.yaml,sha256=u_WalQ01e8W1D27VnZ
438
438
  camel/toolkits/open_api_specs/web_scraper/paths/__init__.py,sha256=OKCZrQCDwaWtXIN_2rA9FSqEvgpQRieRoHh7Ek6N16A,702
439
439
  camel/toolkits/open_api_specs/web_scraper/paths/scraper.py,sha256=aWy1_ppV4NVVEZfnbN3tu9XA9yAPAC9bRStJ5JuXMRU,1117
440
440
  camel/types/__init__.py,sha256=pFTg3CWGSCfwFdoxPDTf4dKV8DdJS1x-bBPuEOmtdf0,2549
441
- camel/types/enums.py,sha256=Zf37-MvLlbZt6WLNRMDi5UWiVDN1Q2CeZvLPSbFcg_Q,63051
441
+ camel/types/enums.py,sha256=JolxBxgOfAGXAD-Z6DzMLiQ51I8H-6GrAO__1dEB_MQ,63239
442
442
  camel/types/mcp_registries.py,sha256=dl4LgYtSaUhsqAKpz28k_SA9La11qxqBvDLaEuyzrFE,4971
443
443
  camel/types/openai_types.py,sha256=8ZFzLe-zGmKNPfuVZFzxlxAX98lGf18gtrPhOgMmzus,2104
444
444
  camel/types/unified_model_type.py,sha256=U3NUZux7QuMIxPW2H0qDp9BOyDJFHAx6jUmDNw5_9KM,5912
@@ -467,7 +467,7 @@ camel/verifiers/math_verifier.py,sha256=tA1D4S0sm8nsWISevxSN0hvSVtIUpqmJhzqfbuMo
467
467
  camel/verifiers/models.py,sha256=GdxYPr7UxNrR1577yW4kyroRcLGfd-H1GXgv8potDWU,2471
468
468
  camel/verifiers/physics_verifier.py,sha256=c1grrRddcrVN7szkxhv2QirwY9viIRSITWeWFF5HmLs,30187
469
469
  camel/verifiers/python_verifier.py,sha256=ogTz77wODfEcDN4tMVtiSkRQyoiZbHPY2fKybn59lHw,20558
470
- camel_ai-0.2.73a8.dist-info/METADATA,sha256=JMMFteW3ZHW4JreEL0nbvm9ll-rUoSab_ILr3csAPkE,50434
471
- camel_ai-0.2.73a8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
472
- camel_ai-0.2.73a8.dist-info/licenses/LICENSE,sha256=id0nB2my5kG0xXeimIu5zZrbHLS6EQvxvkKkzIHaT2k,11343
473
- camel_ai-0.2.73a8.dist-info/RECORD,,
470
+ camel_ai-0.2.73a9.dist-info/METADATA,sha256=DX7cvC3menqY-BKlqULVDdurx20QNDEuUDiMQtrxhM0,50434
471
+ camel_ai-0.2.73a9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
472
+ camel_ai-0.2.73a9.dist-info/licenses/LICENSE,sha256=id0nB2my5kG0xXeimIu5zZrbHLS6EQvxvkKkzIHaT2k,11343
473
+ camel_ai-0.2.73a9.dist-info/RECORD,,