export async function is_query_complete(query, model = 'qwen2.5:3b') { const payload = { model, messages: [ { role: 'system', content: ` You are a voice query completeness classifier. Determine if the input is complete enough to act on. Respond only with JSON: {"complete": true} or {"complete": false} Default to {"complete": true}. Only respond with {"complete": false} if the input is clearly mid-sentence, trails off, or is a single ambiguous word with no clear intent. Complete examples: "What time is it", "Turn off the lights", "How do I juggle", "Make a note", "Check the weather" Incomplete examples: "How do I", "The thing is", "Can you" `.replace(/^[\t ]+/gm, ''), }, { role: 'user', content: query }, ], stream: false, format: 'json', options: { num_predict: 10, num_ctx: 2048 }, } const response = await fetch('http://192.168.2.99:11434/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), }) if (response.ok) { try { const data = await response.json() const parsed = JSON.parse(data.message.content) return parsed.complete === true } catch { return true } } else { // Fail open — if classifier errors, let the query through return true } }