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:
@@ -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])
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user