fix:更新定时任务push
This commit is contained in:
@@ -53,6 +53,45 @@ async def _run_reco_async(
|
||||
)
|
||||
|
||||
|
||||
async def run_reco_payload_async(
|
||||
*,
|
||||
scene: Scene,
|
||||
user_profile: UserProfileV1_2,
|
||||
already_recommended_ids: Optional[list[Any]] = None,
|
||||
touched_or_viewed_ids: Optional[list[Any]] = None,
|
||||
k: Optional[int] = None,
|
||||
now: Optional[datetime] = None,
|
||||
locale: Optional[str] = None,
|
||||
) -> dict[str, Any]:
|
||||
"""
|
||||
在“已有事件循环”内运行推荐并返回 payload。
|
||||
|
||||
用途:
|
||||
- 供 Push 等 async 任务内部调用,避免 `asyncio.run()` 嵌套导致 RuntimeError
|
||||
- 也便于未来在 API/任务间复用
|
||||
"""
|
||||
|
||||
effective_now = _ensure_now(now)
|
||||
effective_locale = _ensure_locale(locale)
|
||||
|
||||
# k 默认按场景(与 generate 保持一致)
|
||||
if k is None:
|
||||
k_i = 30 if scene == "feed" else 1
|
||||
else:
|
||||
k_i = int(k)
|
||||
|
||||
result = await _run_reco_async(
|
||||
scene=scene,
|
||||
user_profile=user_profile,
|
||||
already_recommended_ids=list(already_recommended_ids or []),
|
||||
touched_or_viewed_ids=list(touched_or_viewed_ids or []),
|
||||
k=int(k_i),
|
||||
now=effective_now,
|
||||
locale=effective_locale,
|
||||
)
|
||||
return result.model_dump()
|
||||
|
||||
|
||||
def _run_reco_sync(
|
||||
*,
|
||||
scene: Scene,
|
||||
|
||||
Reference in New Issue
Block a user