feat: LLM provider switcher (Claude/Groq) in settings tab
All checks were successful
Deploy / deploy (push) Successful in 1m27s

This commit is contained in:
Cosmo
2026-05-01 12:42:24 +00:00
parent f8c842b474
commit 6199db2977
4 changed files with 224 additions and 130 deletions

33
app/api/settings/route.ts Normal file
View File

@@ -0,0 +1,33 @@
export const dynamic = 'force-dynamic'
import { NextRequest, NextResponse } from 'next/server'
import { promises as fs } from 'node:fs'
import path from 'node:path'
const SETTINGS_PATH = '/data/settings.json'
const DEFAULTS = {
voiceProvider: 'anthropic',
anthropicModel: 'claude-haiku-4-5-20251001',
groqModel: 'llama-3.3-70b-versatile',
}
async function readSettings() {
try {
const raw = await fs.readFile(SETTINGS_PATH, 'utf-8')
return { ...DEFAULTS, ...JSON.parse(raw) }
} catch {
return { ...DEFAULTS }
}
}
export async function GET() {
return NextResponse.json(await readSettings())
}
export async function POST(req: NextRequest) {
const body = await req.json()
const current = await readSettings()
const updated = { ...current, ...body }
await fs.mkdir(path.dirname(SETTINGS_PATH), { recursive: true })
await fs.writeFile(SETTINGS_PATH, JSON.stringify(updated, null, 2), 'utf-8')
return NextResponse.json(updated)
}