Update index.html
Browse files- index.html +17 -7
index.html
CHANGED
|
@@ -1106,17 +1106,24 @@
|
|
| 1106 |
|
| 1107 |
existing.push(generateDataset());
|
| 1108 |
const content = JSON.stringify(existing, null, 2);
|
| 1109 |
-
const fileBlob = new Blob([content], { type: 'application/json' });
|
| 1110 |
|
| 1111 |
showStatus('Uploading…', 'success');
|
| 1112 |
|
| 1113 |
-
|
| 1114 |
-
|
| 1115 |
-
|
| 1116 |
-
const r = await fetch(`https://huggingface.co/api/datasets/${repoId}/upload/main`, {
|
| 1117 |
method: "POST",
|
| 1118 |
-
headers: {
|
| 1119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1120 |
});
|
| 1121 |
|
| 1122 |
if (!r.ok) {
|
|
@@ -1124,6 +1131,9 @@
|
|
| 1124 |
console.error('HF response:', r.status, errText);
|
| 1125 |
throw new Error(`HF API ${r.status}: ${errText}`);
|
| 1126 |
}
|
|
|
|
|
|
|
|
|
|
| 1127 |
showStatus('Pushed successfully!', 'success');
|
| 1128 |
closeHFModal();
|
| 1129 |
} catch (e) {
|
|
|
|
| 1106 |
|
| 1107 |
existing.push(generateDataset());
|
| 1108 |
const content = JSON.stringify(existing, null, 2);
|
|
|
|
| 1109 |
|
| 1110 |
showStatus('Uploading…', 'success');
|
| 1111 |
|
| 1112 |
+
// Correct HF API: commit endpoint with base64 content inline
|
| 1113 |
+
const r = await fetch(`https://huggingface.co/api/datasets/${repoId}/commit/main`, {
|
|
|
|
|
|
|
| 1114 |
method: "POST",
|
| 1115 |
+
headers: {
|
| 1116 |
+
"Authorization": `Bearer ${token}`,
|
| 1117 |
+
"Content-Type": "application/json"
|
| 1118 |
+
},
|
| 1119 |
+
body: JSON.stringify({
|
| 1120 |
+
summary: "Append self-distillation entry",
|
| 1121 |
+
operations: [{
|
| 1122 |
+
operation: "create",
|
| 1123 |
+
path: "data.json",
|
| 1124 |
+
content: content // plain string, NOT base64
|
| 1125 |
+
}]
|
| 1126 |
+
})
|
| 1127 |
});
|
| 1128 |
|
| 1129 |
if (!r.ok) {
|
|
|
|
| 1131 |
console.error('HF response:', r.status, errText);
|
| 1132 |
throw new Error(`HF API ${r.status}: ${errText}`);
|
| 1133 |
}
|
| 1134 |
+
|
| 1135 |
+
const result = await r.json();
|
| 1136 |
+
console.log('HF result:', result);
|
| 1137 |
showStatus('Pushed successfully!', 'success');
|
| 1138 |
closeHFModal();
|
| 1139 |
} catch (e) {
|