feat(ai): switch from DeepSeek to local Ollama (qwen3:14b)
- Point AI client to localhost:11434/v1 (Ollama) - Remove DeepSeek API key dependency - Update model name to qwen3:14b across all routes - Update test mocks to use createLocalLLMClient - Removes need for DEEPSEEK_API_KEY setting Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,8 +6,7 @@ import { withUser, asAdmin } from '@/lib/db/with-user'
|
||||
import { writeAuditLog } from '@/lib/db/audit'
|
||||
import { incidents, sites, zones, auditLog } from '@/lib/db/schema'
|
||||
import { eq, and, gte, desc } from 'drizzle-orm'
|
||||
import { createDeepSeekClient } from '@/lib/claude/client'
|
||||
import { getApiKey } from '@/lib/settings'
|
||||
import { createLocalLLMClient } from '@/lib/claude/client'
|
||||
|
||||
type ZoneAggregate = {
|
||||
zone: string
|
||||
@@ -103,13 +102,12 @@ export async function POST() {
|
||||
return NextResponse.json({ error: 'Rate limit: wait 60 seconds between AI requests' }, { status: 429 })
|
||||
}
|
||||
|
||||
const deepseekKey = await getApiKey('DEEPSEEK_API_KEY')
|
||||
const client = createDeepSeekClient(deepseekKey)
|
||||
const client = createLocalLLMClient()
|
||||
|
||||
let res: Awaited<ReturnType<typeof client.chat.completions.create>>
|
||||
try {
|
||||
res = await client.chat.completions.create({
|
||||
model: 'deepseek-v4-pro',
|
||||
model: 'qwen3:14b',
|
||||
max_tokens: 2048,
|
||||
messages: [
|
||||
{
|
||||
@@ -168,7 +166,7 @@ Flag only zones with rising or elevated risk (at most 5 flags; do not flag healt
|
||||
|
||||
await withUser(session.sub, async tx =>
|
||||
writeAuditLog(tx, 'incidents', session.sub, 'ai_risk_flags',
|
||||
{ flags, summary: input.summary, model: 'deepseek-v4-pro' })
|
||||
{ flags, summary: input.summary, model: 'qwen3:14b' })
|
||||
)
|
||||
|
||||
return NextResponse.json({ flags, summary: input.summary })
|
||||
|
||||
Reference in New Issue
Block a user