feat(新功能):

fix(修复bug):  推荐接口 请求参数打印
docs(文档变更):
refactor(重构):
test(增加测试):
This commit is contained in:
zhh
2025-11-24 15:32:25 +08:00
parent 8a9f160cfa
commit 448af4ab6b

View File

@@ -34,12 +34,14 @@ async def startup_event():
scheduler.start()
logger.info("定时任务已启动")
def softmax(scores):
max_score = max(scores)
exp_scores = [math.exp(s - max_score) for s in scores]
sum_exp = sum(exp_scores)
return [s / sum_exp for s in exp_scores]
# def get_random_recommendations(category: str, num: int) -> List[str]:
# """根据预加载热度向量推荐(冷启动)"""
# try:
@@ -92,7 +94,7 @@ async def get_recommendations(user_id: int, category: str, brand_id: int, brand_
]
"""
try:
logger.info(f"user_id:{user_id}, category:{category}, num_recommendations:{num_recommendations}")
logger.info(f"user_id:{user_id}-----category:{category}-----brand_id:{brand_id}-----brand_scale:{brand_scale}-----num_recommendations:{num_recommendations}")
start_time = time.time()
cache_key = (user_id, category)
# === 新增:用户存在性检查 ===