ausername-12345 commited on
Commit
10c67f5
·
1 Parent(s): 692f540

List available conversational models

Browse files
Files changed (1) hide show
  1. server.js +16 -22
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 text = await r.text();
58
- results["api_tasks"] = { status: r.status, body: text.slice(0, 2000) };
59
- } catch (e) {
60
- results["api_tasks_error"] = e.message;
61
- }
62
-
63
- // Check raw /api/tasks/conversational
64
- try {
65
- const r = await fetch("https://huggingface.co/api/tasks/conversational");
66
- const text = await r.text();
67
- results["api_tasks_conversational"] = { status: r.status, body: text.slice(0, 2000) };
68
- } catch (e) {
69
- results["api_tasks_conversational_error"] = e.message;
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["api_tasks_textgen_error"] = e.message;
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);