Files
mindfulness/server/app/features/personalized_reco/content_repository/interface.py
2026-02-02 16:47:37 +08:00

37 lines
957 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from __future__ import annotations
from typing import Protocol
from app.features.personalized_reco.content_repository.types import ContentProfileDTO
class ContentRepository(Protocol):
"""
推荐引擎依赖的内容数据访问抽象接口(用于解耦 ORM/SQL
"""
async def fetch_candidates(
self,
*,
scene: str,
user_profile: object,
fallback_level: int,
limit: int,
locale: str,
exclude_content_ids: list[int] | None = None,
) -> list[ContentProfileDTO]:
"""
按场景与用户画像拉取候选内容画像(用于候选池)。
"""
async def fetch_contents_by_ids(
self,
*,
content_ids: list[int],
locale: str,
) -> list[ContentProfileDTO]:
"""
按 content_id 批量获取内容画像(去重、按输入顺序返回;缺语言/缺记录的 id 跳过)。
"""