add nocmem: auto memory recall + ingest via NuoNuo hippocampal network
- nocmem Python service (mem/): FastAPI wrapper around NuoNuo's Hopfield-Hebbian memory, with /recall, /ingest, /store, /stats endpoints - NOC integration: auto recall after user message (injected as system msg), async ingest after LLM response (fire-and-forget) - Recall: cosine pre-filter (threshold 0.35) + Hopfield attention (β=32), top_k=3, KV-cache friendly (appended after user msg, not in system prompt) - Ingest: LLM extraction + paraphrase augmentation, heuristic fallback - Wired into main.rs, life.rs (agent done), http.rs (api chat) - Config: optional `nocmem.endpoint` in config.yaml - Includes benchmarks: LongMemEval (R@5=94.0%), efficiency, noise vs scale - Design doc: doc/nocmem.md
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -3,6 +3,7 @@ mod display;
|
||||
mod gitea;
|
||||
mod http;
|
||||
mod life;
|
||||
mod nocmem;
|
||||
mod output;
|
||||
mod state;
|
||||
mod stream;
|
||||
@@ -388,6 +389,14 @@ async fn handle_inner(
|
||||
let user_content = build_user_content(&prompt, &scratch, &uploaded);
|
||||
api_messages.push(serde_json::json!({"role": "user", "content": user_content}));
|
||||
|
||||
// auto recall from nocmem
|
||||
if let Some(ref nocmem) = config.nocmem {
|
||||
let recalled = nocmem::recall(&nocmem.endpoint, &prompt).await;
|
||||
if !recalled.is_empty() {
|
||||
api_messages.push(serde_json::json!({"role": "system", "content": recalled}));
|
||||
}
|
||||
}
|
||||
|
||||
let mut tg_output = TelegramOutput::new(bot.clone(), chat_id, is_private);
|
||||
|
||||
match run_openai_with_tools(
|
||||
@@ -399,6 +408,15 @@ async fn handle_inner(
|
||||
state.push_message(&sid, "user", &prompt).await;
|
||||
if !response.is_empty() {
|
||||
state.push_message(&sid, "assistant", &response).await;
|
||||
|
||||
// async ingest to nocmem (fire-and-forget)
|
||||
if let Some(ref nocmem) = config.nocmem {
|
||||
nocmem::ingest_spawn(
|
||||
nocmem.endpoint.clone(),
|
||||
prompt.clone(),
|
||||
response.clone(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// sliding window
|
||||
|
||||
Reference in New Issue
Block a user