feat: 换一批注入用户画像,生成更贴合用户自身的示例问题
CI / 后端测试 (push) Has been cancelled
CI / 前端构建 (push) Has been cancelled

This commit is contained in:
selfrelease
2026-08-31 17:11:41 +08:00
parent a7ef530841
commit 9e8291e8bd
3 changed files with 16 additions and 4 deletions
+10
View File
@@ -312,6 +312,7 @@ class SampleRequest(BaseModel):
scene: str = "legal"
topic: str | None = None
existing: list[str] | None = None # 已展示的示例,避免重复
phone: str | None = None # 用户手机号,用于读取画像个性化推荐
class TopicsRequest(BaseModel):
@@ -461,6 +462,15 @@ def generate_samples(req: SampleRequest):
)
if req.topic:
prompt += f"具体话题:{req.topic}\n\n"
# 注入用户画像,个性化推荐
if req.phone:
try:
profile = profile_store.get(req.phone)
profile_ctx = build_profile_context(profile)
if profile_ctx:
prompt += f"用户画像(请结合画像生成更贴合用户自身情况的问题):\n{profile_ctx}\n\n"
except Exception:
pass
if existing:
prompt += "已展示过的问题(不要重复):\n"
for s in existing: