maven: general-knowledge phraser routing (task 4)

- Stub.PhraseQuery: empty notes → "не знаю." (was: "no notes")
- LLMPhraser.PhraseQuery: empty notes → general knowledge prompt to LLM
- Voice handler: on notes RAG failure, try phraser before giving up
- New router.KnowledgePrompt() pure function with test

Co-Authored-By: opencode <opencode@anthropic.com>
This commit is contained in:
kami
2026-07-06 04:11:54 +04:00
parent cf066bde97
commit 428af3f3c6
5 changed files with 42 additions and 3 deletions
+8 -1
View File
@@ -171,7 +171,14 @@ func (p *LLMPhraser) PhraseNudge(ctx context.Context, c loop.Candidate) (deliver
// LLM error — better to give the raw data than silence.
func (p *LLMPhraser) PhraseQuery(ctx context.Context, utterance string, notes []string) (string, error) {
if len(notes) == 0 {
return "у меня нет заметок по этому вопросу.", nil
// General knowledge — no notes to ground the answer
sys := "Ты — Мавена, персональный ассистент. Ответь кратко из своих знаний. Если не знаешь — скажи \"не знаю\". Не выдумывай."
prompt := fmt.Sprintf("Пользователь спрашивает: \"%s\".", utterance)
resp, err := p.chatWithSystem(ctx, sys, prompt, 256)
if err != nil || resp == "" {
return "не знаю.", nil
}
return resp, nil
}
if len(notes) == 1 {
notes[0] = strings.TrimSpace(notes[0])
+1 -1
View File
@@ -63,7 +63,7 @@ func NewStub() *Stub { return &Stub{} }
// PhraseQuery returns a deterministic summary of the best matching notes.
func (s *Stub) PhraseQuery(_ context.Context, _ string, notes []string) (string, error) {
if len(notes) == 0 {
return "у меня нет заметок по этому вопросу.", nil
return "не знаю.", nil
}
if len(notes) == 1 {
return "вот что я нашла: " + notes[0], nil