muthuk1 commited on
Commit
71f60e2
·
verified ·
1 Parent(s): 5177641

Add providers listing API endpoint

Browse files
Files changed (1) hide show
  1. web/src/app/api/providers/route.ts +30 -0
web/src/app/api/providers/route.ts ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { NextResponse } from "next/server";
2
+ import { getProviderDisplayInfo, checkOllamaHealth } from "@/lib/llm-providers";
3
+
4
+ export const runtime = "nodejs";
5
+ export const dynamic = "force-dynamic";
6
+
7
+ export async function GET() {
8
+ const providers = getProviderDisplayInfo();
9
+ const ollamaStatus = await checkOllamaHealth();
10
+
11
+ // Update Ollama entry with live status
12
+ const updated = providers.map((p) => {
13
+ if (p.id === "ollama") {
14
+ return {
15
+ ...p,
16
+ hasApiKey: ollamaStatus.ok,
17
+ ollamaRunning: ollamaStatus.ok,
18
+ ollamaModels: ollamaStatus.models,
19
+ };
20
+ }
21
+ return p;
22
+ });
23
+
24
+ return NextResponse.json({
25
+ providers: updated,
26
+ totalProviders: providers.length,
27
+ availableProviders: updated.filter((p) => p.hasApiKey).length,
28
+ ollamaStatus,
29
+ });
30
+ }