- Dashboard Overview with real-time status display - Live Log Viewer (scrollable, filterable) - Config Editor with JSON syntax highlighting - Model Switcher for provider management - Provider Manager for API key configuration - Quick Actions for common tasks - API Routes: status, logs, config, actions, models, providers Tech Stack: - Next.js 14 (App Router) - TypeScript - Tailwind CSS - shadcn/ui components - CodeMirror for JSON editing - Docker support with docker-compose
40 lines
919 B
TypeScript
40 lines
919 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import { getAvailableModels, getActiveModel, setActiveModel } from '@/lib/openclaw';
|
|
|
|
export async function GET() {
|
|
try {
|
|
const [models, activeModel] = await Promise.all([
|
|
getAvailableModels(),
|
|
getActiveModel(),
|
|
]);
|
|
|
|
return NextResponse.json({ models, activeModel });
|
|
} catch (error) {
|
|
return NextResponse.json(
|
|
{ error: (error as Error).message },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|
|
|
|
export async function POST(request: Request) {
|
|
try {
|
|
const { modelId } = await request.json();
|
|
|
|
if (!modelId) {
|
|
return NextResponse.json(
|
|
{ error: 'modelId is required' },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
const result = await setActiveModel(modelId);
|
|
return NextResponse.json(result);
|
|
} catch (error) {
|
|
return NextResponse.json(
|
|
{ error: (error as Error).message },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|