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, auditLog, sites, zones } from '@/lib/db/schema'
|
||||
import { eq, and, gte, sql } from 'drizzle-orm'
|
||||
import { createDeepSeekClient } from '@/lib/claude/client'
|
||||
import { getApiKey } from '@/lib/settings'
|
||||
import { createLocalLLMClient } from '@/lib/claude/client'
|
||||
|
||||
export async function POST(
|
||||
_request: NextRequest,
|
||||
@@ -32,8 +31,7 @@ export async function POST(
|
||||
if (Number(rateRow?.cnt ?? 0) > 0)
|
||||
return NextResponse.json({ error: 'Rate limited — please wait 60 seconds' }, { status: 429 })
|
||||
|
||||
const deepseekKey = await getApiKey('DEEPSEEK_API_KEY')
|
||||
const client = createDeepSeekClient(deepseekKey)
|
||||
const client = createLocalLLMClient()
|
||||
|
||||
const [incident] = await withUser(session.sub, async tx =>
|
||||
tx.select({
|
||||
@@ -59,7 +57,7 @@ export async function POST(
|
||||
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: [
|
||||
{
|
||||
@@ -107,7 +105,7 @@ Provide 3–5 Why steps drilling from immediate cause to root cause. Frame CAPA
|
||||
await withUser(session.sub, async tx => {
|
||||
await writeAuditLog(tx, 'incidents', id, 'ai_rca_draft', {
|
||||
root_cause_summary: draft.root_cause_summary as string,
|
||||
model: 'deepseek-v4-pro',
|
||||
model: 'qwen3:14b',
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user