Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

fix: when the user does not use huggingface record preset fields, the preset fields will be ignored. (#1365)

koch30923570c0ea19fd
diff --git a/camel/datahubs/huggingface.py b/camel/datahubs/huggingface.py
index bda252876..3ababc888 100644
--- a/camel/datahubs/huggingface.py
+++ b/camel/datahubs/huggingface.py
@@ -362,7 +362,13 @@ class HuggingFaceDatasetManager(BaseDatasetManager):
with tempfile.NamedTemporaryFile(
delete=False, mode="w", newline="", encoding="utf-8"
) as f:
- json.dump([record.model_dump() for record in records], f)
+ json.dump(
+ [
+ record.model_dump(exclude_defaults=True)
+ for record in records
+ ],
+ f,
+ )
temp_file_path = f.name
try:
diff --git a/camel/datahubs/models.py b/camel/datahubs/models.py
index 44aba278d..8b4cbbe8b 100644
--- a/camel/datahubs/models.py
+++ b/camel/datahubs/models.py
@@ -13,7 +13,7 @@
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
from typing import Any, Dict, Optional
-from pydantic import BaseModel
+from pydantic import BaseModel, ConfigDict
class Record(BaseModel):
@@ -21,5 +21,4 @@ class Record(BaseModel):
metadata: Optional[Dict[str, Any]] = None
content: Optional[Dict[str, Any]] = None
- class Config:
- extra = "allow" # Allow any additional fields
+ model_config = ConfigDict(extra="allow")