Komalpreet Kaur commited on
Commit
b8fda7c
·
unverified ·
1 Parent(s): 209f9ba

fix: extract knowledge only from user messages, not Soma's verbose responses

Browse files
Files changed (1) hide show
  1. app/api/endpoints.py +3 -2
app/api/endpoints.py CHANGED
@@ -128,7 +128,8 @@ async def process_consolidation(current_user: str = Depends(get_current_user)):
128
  chunks, msg = consolidate_memory(current_user)
129
  if chunks > 0:
130
  history = get_recent_messages(current_user, exchanges=50)
131
- doc = "\n".join([f"{m['role']}: {m['content']}" for m in history])
 
132
  triples = extract_and_store_knowledge(doc, current_user)
133
  msg += f" Extracted {triples} graph relations."
134
  return IngestResponse(message=msg, chunks=chunks)
@@ -453,7 +454,7 @@ async def process_query_stream(request: QueryRequest, current_user: str = Depend
453
  "phase": "graph",
454
  "message": "Extracting relationships for semantic memory."
455
  })
456
- triples = await asyncio.to_thread(extract_and_store_knowledge, exchange_text, current_user)
457
  yield sse_event("brain_trace", build_brain_event(
458
  "graph",
459
  71,
 
128
  chunks, msg = consolidate_memory(current_user)
129
  if chunks > 0:
130
  history = get_recent_messages(current_user, exchanges=50)
131
+ user_msgs = [m['content'] for m in history if m['role'] == 'user']
132
+ doc = "\n".join(user_msgs)
133
  triples = extract_and_store_knowledge(doc, current_user)
134
  msg += f" Extracted {triples} graph relations."
135
  return IngestResponse(message=msg, chunks=chunks)
 
454
  "phase": "graph",
455
  "message": "Extracting relationships for semantic memory."
456
  })
457
+ triples = await asyncio.to_thread(extract_and_store_knowledge, request.text, current_user)
458
  yield sse_event("brain_trace", build_brain_event(
459
  "graph",
460
  71,