ausername-12345 commited on
Commit
692f540
·
1 Parent(s): 244f310

Check raw API tasks endpoints

Browse files
Files changed (1) hide show
  1. server.js +19 -21
server.js CHANGED
@@ -50,34 +50,32 @@ app.post("/api/hf", async (req, res) => {
50
 
51
  app.get("/api/test-lib", async (_, res) => {
52
  const results = {};
53
- const token = process.env.HF_TOKEN;
54
 
55
- // Check what models are available for conversational task
56
  try {
57
- const r = await fetch("https://huggingface.co/api/tasks?task=conversational", {
58
- headers: { Authorization: `Bearer ${token}` },
59
- });
60
- const data = await r.json();
61
- results["conversational_models"] = {
62
- count: data.models?.length || 0,
63
- models: (data.models || []).slice(0, 10).map(m => ({ id: m.id, provider: m.provider })),
64
- };
65
  } catch (e) {
66
- results["conversational_models_error"] = e.message;
67
  }
68
 
69
- // Also check text-generation task
70
  try {
71
- const r = await fetch("https://huggingface.co/api/tasks?task=text-generation", {
72
- headers: { Authorization: `Bearer ${token}` },
73
- });
74
- const data = await r.json();
75
- results["textgen_models"] = {
76
- count: data.models?.length || 0,
77
- models: (data.models || []).slice(0, 10).map(m => ({ id: m.id, provider: m.provider })),
78
- };
 
 
 
 
79
  } catch (e) {
80
- results["textgen_models_error"] = e.message;
81
  }
82
 
83
  res.json(results);
 
50
 
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);