0990f32808
An add and a crossing-off run at the top of actionNote, next to task capture and before the embedding is paid for; the read-back is a query source sitting beside "tasks", so the recall pass cannot answer "что мне купить?" from an old note about the shop. Crossing off one item claims the turn only when the list actually holds that item, which is what keeps "купил новый ноутбук" a note. These read h.dataStore rather than the CoreAPI: a list is local to the core and nothing outside it writes one. The ipc seam is what it grows through when something outside mavend needs to add to a list.
54 lines
2.0 KiB
Go
54 lines
2.0 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"strconv"
|
|
|
|
"github.com/kami/maven/internal/router"
|
|
)
|
|
|
|
// actionNote handles router.IntentNote: embed the note, persist it, and
|
|
// index it for recall.
|
|
func (h *reactiveHandler) actionNote(ctx context.Context, dec router.Decision) string {
|
|
// An utterance that explicitly files a task is work, not recall, and
|
|
// belongs in the task store (Vikunja #130). Checked before the embedding
|
|
// is paid for. Everything else is a note, exactly as before.
|
|
if reply, ok := h.captureTaskFromNote(ctx, dec); ok {
|
|
return reply
|
|
}
|
|
// A standing list is neither work nor recall (Vikunja #453). Checked here
|
|
// for the same reason and at the same cost: before the embedding is paid
|
|
// for, and it passes the turn straight back when no marker matches.
|
|
if reply, ok := h.captureListFromNote(ctx, dec); ok {
|
|
return reply
|
|
}
|
|
// embed the note text with the same model the classifier uses, persist
|
|
// via CoreAPI (source=tap:voice). Semantic recall lives in `notes`, not
|
|
// facts — no predicate reads it (spec's two-memory split).
|
|
vec, err := router.EmbedPassage(ctx, h.embedder, dec.Utterance)
|
|
if err != nil {
|
|
log.Printf("voice: embed note: %v", err)
|
|
return "не получилось сохранить заметку."
|
|
}
|
|
noteTs := h.now()
|
|
noteID, err := h.api.WriteNote(ctx, noteTs, dec.Utterance, vec, "tap:voice")
|
|
if err != nil {
|
|
log.Printf("voice: write note: %v", err)
|
|
return "не получилось сохранить заметку."
|
|
}
|
|
// Insert into long-term memory (best-effort, must not fail the note write).
|
|
// text/ts in the meta make a Search hit self-describing (see bestRecall).
|
|
if h.memStore != nil {
|
|
if err := h.memStore.Insert(ctx, "note:"+strconv.FormatInt(noteID, 10), vec, map[string]string{
|
|
"source": "voice",
|
|
"type": "note",
|
|
"text": dec.Utterance,
|
|
"ts": strconv.FormatInt(noteTs.Unix(), 10),
|
|
}); err != nil {
|
|
log.Printf("voice: memory insert: %v", err)
|
|
}
|
|
}
|
|
return "" // replier phrases the "saved" reply
|
|
}
|