PHASE 3 — relational tier (Mem0g-light)
This commit is contained in:
@@ -366,7 +366,7 @@ async def _apply_candidate(
|
||||
if candidate.target_tier == "relational":
|
||||
# Always upsert relations — decide_action skipped (no neighbour search).
|
||||
if candidate.subject and candidate.predicate and candidate.object:
|
||||
await _upsert_relation_stub(
|
||||
await _upsert_relation(
|
||||
middleware, db, user_id, candidate, trace_id
|
||||
)
|
||||
return
|
||||
@@ -396,35 +396,29 @@ def _content_to_key(content: str) -> str:
|
||||
return slug or "memory"
|
||||
|
||||
|
||||
async def _upsert_relation_stub(
|
||||
async def _upsert_relation(
|
||||
middleware: Any,
|
||||
db: AsyncSession,
|
||||
user_id: str,
|
||||
candidate: MemoryCandidate,
|
||||
trace_id: str | None,
|
||||
) -> None:
|
||||
"""Stub: upsert_relation will be fully wired in Phase 3.
|
||||
|
||||
Called here so Phase 2 extraction pipeline already routes relation candidates
|
||||
correctly. Phase 3 replaces this with MemoryMiddleware.upsert_relation().
|
||||
"""
|
||||
if hasattr(middleware, "upsert_relation"):
|
||||
await middleware.upsert_relation(
|
||||
user_id=user_id,
|
||||
subject=candidate.subject,
|
||||
subject_type="unknown",
|
||||
predicate=candidate.predicate,
|
||||
object_=candidate.object,
|
||||
object_type="unknown",
|
||||
confidence=candidate.confidence,
|
||||
)
|
||||
else:
|
||||
logger.info(
|
||||
"memory_extraction: relation stub (Phase 3 not yet wired) subject=%s predicate=%s object=%s",
|
||||
candidate.subject,
|
||||
candidate.predicate,
|
||||
candidate.object,
|
||||
)
|
||||
"""Upsert a relation row via MemoryMiddleware.upsert_relation (Phase 3)."""
|
||||
await middleware.upsert_relation(
|
||||
user_id=user_id,
|
||||
subject=candidate.subject or "unknown",
|
||||
subject_type="unknown",
|
||||
predicate=candidate.predicate or "related_to",
|
||||
object_=candidate.object or "unknown",
|
||||
object_type="unknown",
|
||||
confidence=candidate.confidence,
|
||||
)
|
||||
logger.info(
|
||||
"memory_extraction: upserted relation subject=%s predicate=%s object=%s",
|
||||
candidate.subject,
|
||||
candidate.predicate,
|
||||
candidate.object,
|
||||
)
|
||||
|
||||
|
||||
async def _store_proactive_stub(
|
||||
|
||||
Reference in New Issue
Block a user