voice: локальный агент (fast-path), tool control_light, смелая тема, RUNBOOK
All checks were successful
Deploy / deploy (push) Successful in 3m43s
All checks were successful
Deploy / deploy (push) Successful in 3m43s
- lib/agent-local.ts + route.ts: команды-действия исполняет локальная intent-служба (под AGENT_URL, с fallback на LLM); инфо-запросы остаются у LLM - lib/tools/lights.ts: голосовое управление светом через HA (control_light) - app/globals.css + page.tsx: космическая indigo/aurora тема (токены, kiosk-safe) - agent/: sidecar-служба (Dockerfile, predict.py), веса монтируются томом - RUNBOOK.md: вывод в продакшен на мини-ПК
This commit is contained in:
@@ -9,6 +9,7 @@ import { fetch as undiciFetch, ProxyAgent } from 'undici'
|
||||
import { voiceBus } from '@/lib/voice-bus'
|
||||
import { systemPrompt } from '@/lib/voice-prompts'
|
||||
import { TOOL_SCHEMAS, executeTool } from '@/lib/tools/_registry'
|
||||
import { tryLocalAgent } from '@/lib/agent-local'
|
||||
import { cleanForSpeech, stripFillers, isResetCommand } from '@/lib/voice-text'
|
||||
import { loadHistory, saveHistory, resetHistory, HistoryMessage } from '@/lib/voice-history'
|
||||
import { promises as nodeFs } from 'node:fs'
|
||||
@@ -146,6 +147,23 @@ export async function POST(req: Request) {
|
||||
const newTurns: HistoryMessage[] = [{ role: 'user', content: userText }]
|
||||
let finalText = ''
|
||||
|
||||
// ======== Локальный агент (fast-path) ========
|
||||
// Если задан AGENT_URL — команды-действия исполняет локальная intent-служба
|
||||
// за ~2 мс, минуя облачный LLM. Инфо-запросы и всё неуверенное падают в LLM
|
||||
// ниже. Любая ошибка → тоже fallback. Без AGENT_URL — поведение не меняется.
|
||||
try {
|
||||
const fast = await tryLocalAgent(userText, agent)
|
||||
if (fast) {
|
||||
const assistant: HistoryMessage = { role: 'assistant', content: fast.text }
|
||||
await saveHistory(agent, [...history, ...newTurns, assistant])
|
||||
emitVoice('response', agent, fast.text)
|
||||
console.log(`[voice/chat] local-agent ${agent} intent=${fast.intent}`)
|
||||
return NextResponse.json({ text: fast.text, via: 'local-agent' })
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('[voice/chat] local-agent skip:', (e as Error).message)
|
||||
}
|
||||
|
||||
// ======== GROQ ========
|
||||
if (provider === 'groq') {
|
||||
const groqModel = settings.groqModel || 'llama-3.3-70b-versatile'
|
||||
|
||||
Reference in New Issue
Block a user