2026-03-18 17:18:23 +08:00
|
|
|
|
"""
|
|
|
|
|
|
MemoryService — conversation / memoir 的统一门面。
|
|
|
|
|
|
一期先实现基础接口签名,具体逻辑后续补充。
|
|
|
|
|
|
"""
|
2026-03-19 14:36:14 +08:00
|
|
|
|
|
2026-03-18 17:18:23 +08:00
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MemoryService:
|
|
|
|
|
|
def __init__(self, db: AsyncSession):
|
|
|
|
|
|
self._db = db
|
|
|
|
|
|
|
2026-03-19 14:36:14 +08:00
|
|
|
|
async def ingest_transcript(
|
|
|
|
|
|
self, user_id: str, conversation_id: str, transcript: str
|
|
|
|
|
|
) -> str:
|
2026-03-18 17:18:23 +08:00
|
|
|
|
"""Ingest conversation transcript into memory. Returns source_id."""
|
|
|
|
|
|
raise NotImplementedError("Phase 2+ implementation")
|
|
|
|
|
|
|
|
|
|
|
|
async def retrieve(self, user_id: str, query: str, *, top_k: int = 10) -> dict:
|
|
|
|
|
|
"""Retrieve relevant evidence for a query. 一期返回空结构,二期接入混合检索。"""
|
|
|
|
|
|
return {
|
|
|
|
|
|
"relevant_chunks": [],
|
|
|
|
|
|
"relevant_summaries": [],
|
|
|
|
|
|
"relevant_facts": [],
|
|
|
|
|
|
"timeline_hints": [],
|
|
|
|
|
|
}
|