import { NextResponse } from "next/server"; export const dynamic = "force-dynamic"; export const runtime = "nodejs"; /** * GET /api/props * * Proxies llama.cpp's /props endpoint. Returns: * - default_generation_settings: { n_predict, temperature, top_k, top_p, * min_p, repeat_penalty, ... } — the sampling defaults the server * started with * - total_slots: number of parallel slots * - model_path: path to the loaded model * - chat_template: chat template string (if --jinja) * - n_context: total context size (ctx_size * parallel) * - n_vocab, n_embd, n_params: model metadata * - has_multimodal: bool (mmproj loaded) * - timings: cumulative across all slots since server start * * Unlike /slots (per-slot state), /props gives server-wide info that's * useful even when no chat is running. */ export async function GET() { try { const res = await fetch("http://llama:8080/props", { cache: "no-store", signal: AbortSignal.timeout(5000), }); if (!res.ok) { return NextResponse.json( { ok: false, error: `llama returned ${res.status}`, }, { status: res.status } ); } const data = await res.json(); return NextResponse.json({ ok: true, props: data }); } catch (err) { return NextResponse.json( { ok: false, error: (err as Error).message, }, { status: 503 } ); } }