adityaverma977 commited on
Commit
25f6a95
·
1 Parent(s): 8bcd5b0

Frontend: accept legacy available-models response (groq_models / hf_spaces_models) and merge into unified list

Browse files
frontend/components/ModelSelector.tsx CHANGED
@@ -28,8 +28,22 @@ export default function ModelSelector({
28
  const data = await getAvailableModels()
29
 
30
  // Use unified model list (no backend categorization)
31
- const modelList = data.models || data.hf_models || data.groq_models || []
32
- setAllModels(modelList)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  } catch (err) {
34
  console.error("Failed to fetch models:", err)
35
  // Fallback to default models
 
28
  const data = await getAvailableModels()
29
 
30
  // Use unified model list (no backend categorization)
31
+ // Support multiple backend response formats (new unified `models` or legacy grouped keys)
32
+ if (data.models && Array.isArray(data.models)) {
33
+ setAllModels(data.models)
34
+ } else {
35
+ const groq = data.groq_models || data.groqModels || data.groq || []
36
+ const hf = data.hf_spaces_models || data.hf_spaces || data.hf_models || data.hfModels || []
37
+ const merged: Model[] = []
38
+ if (Array.isArray(groq)) {
39
+ for (const g of groq) merged.push({ id: g.id, name: g.name || g.id, description: g.description || g.backend || '' })
40
+ }
41
+ if (Array.isArray(hf)) {
42
+ for (const h of hf) merged.push({ id: h.id, name: h.name || h.id, description: h.description || h.space_url || '' })
43
+ }
44
+ if (merged.length > 0) setAllModels(merged)
45
+ else setAllModels([])
46
+ }
47
  } catch (err) {
48
  console.error("Failed to fetch models:", err)
49
  // Fallback to default models