File size: 807 Bytes
71f60e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { NextResponse } from "next/server";
import { getProviderDisplayInfo, checkOllamaHealth } from "@/lib/llm-providers";

export const runtime = "nodejs";
export const dynamic = "force-dynamic";

export async function GET() {
  const providers = getProviderDisplayInfo();
  const ollamaStatus = await checkOllamaHealth();

  // Update Ollama entry with live status
  const updated = providers.map((p) => {
    if (p.id === "ollama") {
      return {
        ...p,
        hasApiKey: ollamaStatus.ok,
        ollamaRunning: ollamaStatus.ok,
        ollamaModels: ollamaStatus.models,
      };
    }
    return p;
  });

  return NextResponse.json({
    providers: updated,
    totalProviders: providers.length,
    availableProviders: updated.filter((p) => p.hasApiKey).length,
    ollamaStatus,
  });
}