Files
life-echo/api/app/features/memory/enrichment_scheduler.py
Kevin ac436b87a2 feat(api): 收敛对话与记忆流程边界,引入 LLM 网关与专用服务
- MemoryService 异步路径委托 MemoryIngestService / MemoryRetrievalService;富化派发经 MemoryEnrichmentScheduler
- WebSocket pipeline 经 ChatTurnService 与显式 DTO 编排单轮对话;回忆录片段入队由 MemoirIngestScheduler 封装
- 新增 LlmGateway(LlmUseCase),各 agent、任务与适配器对齐 ports
- 补充 memory 提示适配、runtime 类型、memory-retrieval 文档、ai-touchpoints 说明与扫描脚本及配套测试

Made-with: Cursor
2026-04-30 09:17:01 +08:00

51 lines
1.4 KiB
Python

"""Memory enrichment scheduling boundary."""
from __future__ import annotations
from dataclasses import dataclass
@dataclass(frozen=True)
class MemoryEnrichmentRequest:
user_id: str
source_id: str
memoir_correlation_id: str | None = None
class MemoryEnrichmentScheduler:
"""Adapter around the Celery enrichment task name and queue policy."""
def schedule(self, request: MemoryEnrichmentRequest) -> str | None:
from app.tasks.memory_enrichment_tasks import schedule_memory_enrichment
return schedule_memory_enrichment(
request.user_id,
request.source_id,
memoir_correlation_id=request.memoir_correlation_id,
)
def schedule_many(
self,
user_id: str,
source_ids: list[str],
*,
memoir_correlation_id: str | None = None,
) -> list[str]:
task_ids: list[str] = []
for source_id in source_ids:
if not source_id:
continue
task_id = self.schedule(
MemoryEnrichmentRequest(
user_id=user_id,
source_id=source_id,
memoir_correlation_id=memoir_correlation_id,
)
)
if task_id:
task_ids.append(task_id)
return task_ids
__all__ = ["MemoryEnrichmentRequest", "MemoryEnrichmentScheduler"]