Spaces:
Sleeping
Sleeping
ausername-12345 commited on
Commit ·
10c67f5
1
Parent(s): 692f540
List available conversational models
Browse files
server.js
CHANGED
|
@@ -51,31 +51,25 @@ app.post("/api/hf", async (req, res) => {
|
|
| 51 |
app.get("/api/test-lib", async (_, res) => {
|
| 52 |
const results = {};
|
| 53 |
|
| 54 |
-
// Check raw /api/tasks
|
| 55 |
try {
|
| 56 |
const r = await fetch("https://huggingface.co/api/tasks");
|
| 57 |
-
const
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
// Check the /api/tasks endpoint with text-generation
|
| 73 |
-
try {
|
| 74 |
-
const r = await fetch("https://huggingface.co/api/tasks/text-generation");
|
| 75 |
-
const text = await r.text();
|
| 76 |
-
results["api_tasks_textgen"] = { status: r.status, body: text.slice(0, 2000) };
|
| 77 |
} catch (e) {
|
| 78 |
-
results["
|
| 79 |
}
|
| 80 |
|
| 81 |
res.json(results);
|
|
|
|
| 51 |
app.get("/api/test-lib", async (_, res) => {
|
| 52 |
const results = {};
|
| 53 |
|
|
|
|
| 54 |
try {
|
| 55 |
const r = await fetch("https://huggingface.co/api/tasks");
|
| 56 |
+
const data = await r.json();
|
| 57 |
+
const keys = Object.keys(data);
|
| 58 |
+
results["available_tasks"] = keys;
|
| 59 |
+
|
| 60 |
+
// Find conversational/text-generation models
|
| 61 |
+
for (const task of ["conversational", "text-generation", "text2text-generation"]) {
|
| 62 |
+
const taskData = data[task];
|
| 63 |
+
if (taskData) {
|
| 64 |
+
results[task] = {
|
| 65 |
+
models: (taskData.models || []).slice(0, 15).map(m => ({ id: m.id, provider: m.provider })),
|
| 66 |
+
};
|
| 67 |
+
} else {
|
| 68 |
+
results[task] = null;
|
| 69 |
+
}
|
| 70 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
} catch (e) {
|
| 72 |
+
results["error"] = e.message;
|
| 73 |
}
|
| 74 |
|
| 75 |
res.json(results);
|