Spaces:
Runtime error
Runtime error
Changed to use string instead of json inside the hugging face dataset upload function
Browse files
app.py
CHANGED
|
@@ -56,7 +56,7 @@ def Dataset_Creator_Function(dataset_name: str, conversation_data: str) -> str:
|
|
| 56 |
|
| 57 |
Args:
|
| 58 |
dataset_name: Name for the dataset (will be prefixed with username)
|
| 59 |
-
conversation_data:
|
| 60 |
|
| 61 |
Returns:
|
| 62 |
URL of the created dataset or error message
|
|
@@ -72,25 +72,18 @@ def Dataset_Creator_Function(dataset_name: str, conversation_data: str) -> str:
|
|
| 72 |
# Format the full repo name
|
| 73 |
repo_id = f"{username}/{dataset_name}"
|
| 74 |
|
| 75 |
-
#
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
conversation = {"text": conversation_data}
|
| 82 |
-
else:
|
| 83 |
-
conversation = conversation_data
|
| 84 |
-
|
| 85 |
-
# Add metadata
|
| 86 |
-
conversation["timestamp"] = datetime.datetime.now().isoformat()
|
| 87 |
-
conversation["dataset_id"] = str(uuid.uuid4())
|
| 88 |
|
| 89 |
# Create a Hugging Face dataset
|
| 90 |
dataset = Dataset.from_dict({"conversations": [conversation]})
|
| 91 |
|
| 92 |
# Push to the Hugging Face Hub
|
| 93 |
-
dataset.push_to_hub(repo_id, token=os.getenv("
|
| 94 |
|
| 95 |
return f"Successfully created dataset at https://huggingface.co/datasets/{repo_id}"
|
| 96 |
except Exception as e:
|
|
@@ -102,7 +95,7 @@ def Dataset_Creator_Tool(dataset_name: str, conversation_data: str) -> str:
|
|
| 102 |
|
| 103 |
Args:
|
| 104 |
dataset_name: Name for the dataset (will be prefixed with username)
|
| 105 |
-
conversation_data:
|
| 106 |
"""
|
| 107 |
try:
|
| 108 |
dataset_creator_response = Dataset_Creator_Function(dataset_name, conversation_data)
|
|
|
|
| 56 |
|
| 57 |
Args:
|
| 58 |
dataset_name: Name for the dataset (will be prefixed with username)
|
| 59 |
+
conversation_data: String representation of conversation to save (plain text)
|
| 60 |
|
| 61 |
Returns:
|
| 62 |
URL of the created dataset or error message
|
|
|
|
| 72 |
# Format the full repo name
|
| 73 |
repo_id = f"{username}/{dataset_name}"
|
| 74 |
|
| 75 |
+
# Create a conversation object
|
| 76 |
+
conversation = {
|
| 77 |
+
"text": conversation_data,
|
| 78 |
+
"timestamp": datetime.datetime.now().isoformat(),
|
| 79 |
+
"dataset_id": str(uuid.uuid4())
|
| 80 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
# Create a Hugging Face dataset
|
| 83 |
dataset = Dataset.from_dict({"conversations": [conversation]})
|
| 84 |
|
| 85 |
# Push to the Hugging Face Hub
|
| 86 |
+
dataset.push_to_hub(repo_id, token=os.getenv("HUGGINGFACE_API_KEY", ""))
|
| 87 |
|
| 88 |
return f"Successfully created dataset at https://huggingface.co/datasets/{repo_id}"
|
| 89 |
except Exception as e:
|
|
|
|
| 95 |
|
| 96 |
Args:
|
| 97 |
dataset_name: Name for the dataset (will be prefixed with username)
|
| 98 |
+
conversation_data: String content to save to the dataset (no JSON conversion needed)
|
| 99 |
"""
|
| 100 |
try:
|
| 101 |
dataset_creator_response = Dataset_Creator_Function(dataset_name, conversation_data)
|