|
|
@@ -68,6 +68,9 @@ public class AIService {
|
|
|
@Resource
|
|
|
private FamilyContextService familyContextService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ProfileReadService profileReadService;
|
|
|
+
|
|
|
@Value("${dify.callback-secret:}")
|
|
|
private String callbackSecret;
|
|
|
|
|
|
@@ -783,12 +786,23 @@ try {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 生成用户画像(通过AiGateway调用LangGraph)
|
|
|
+ * 生成用户画像(通过AiGateway调用LangGraph portrait graph)
|
|
|
+ * 按文档口径组装:behavior_summary = 家庭上下文行为摘要;
|
|
|
+ * profile_snapshot = 五维画像快照(member/dimension_scores/body_metrics/mind_metrics/problem_domains)。
|
|
|
*/
|
|
|
public String generateUserPortrait(Long userId, Long memberId, String previousPortrait) {
|
|
|
try {
|
|
|
Map<String, Object> context = familyContextService.buildContext(userId);
|
|
|
- if (memberId != null) context.put("memberId", memberId);
|
|
|
+ // 行为摘要:家庭上下文本身(成员任务完成率/五维能量/认知测评/已购标签/健康报告等)
|
|
|
+ Map<String, Object> behaviorSummary = new HashMap<>(context);
|
|
|
+ behaviorSummary.remove("profileSnapshot");
|
|
|
+ behaviorSummary.remove("memberId");
|
|
|
+ context.put("behaviorSummary", behaviorSummary);
|
|
|
+ if (memberId != null) {
|
|
|
+ context.put("memberId", memberId);
|
|
|
+ // 五维画像快照:与 Python portrait_generation_graph 期望的结构一致
|
|
|
+ context.put("profileSnapshot", profileReadService.getProfile(memberId));
|
|
|
+ }
|
|
|
return aiGateway.generatePortrait(userId, memberId, previousPortrait, context);
|
|
|
} catch (Exception e) {
|
|
|
log.error("AI 生成画像失败: userId={}, memberId={}", userId, memberId, e);
|