feat: add natural elder story companion flow
This commit is contained in:
@@ -57,17 +57,19 @@ func (DeterministicGenerator) Generate(_ context.Context, input GenerationInput)
|
||||
}, nil
|
||||
}
|
||||
storyTitle, storyContent, factContent := "", "", ""
|
||||
openTopic := ""
|
||||
if storyWorthy {
|
||||
storyTitle = "关于“" + truncateRunes(content, 24) + "”的回忆"
|
||||
storyContent = content
|
||||
factContent = content
|
||||
openTopic = "如果长者愿意,下次可以从刚才经历里一个尚未讲清的具体细节自然接着聊。"
|
||||
}
|
||||
return GenerationResult{
|
||||
Meaningful: true,
|
||||
StoryWorthy: storyWorthy,
|
||||
DecisionReason: reason,
|
||||
Summary: "长者在本次通话中谈到:" + content,
|
||||
OpenTopic: "下次可以继续询问长者刚才提到的经历,并让长者自行补充人物、时间和地点。",
|
||||
OpenTopic: openTopic,
|
||||
StoryTitle: storyTitle,
|
||||
StoryContent: storyContent,
|
||||
FactContent: factContent,
|
||||
@@ -90,7 +92,7 @@ func sensitiveGeneration(decision contentpolicy.Decision) GenerationResult {
|
||||
StoryWorthy: false,
|
||||
DecisionReason: "safety_policy_blocked_story",
|
||||
Summary: "本次通话包含需要人工谨慎处理的敏感信息,系统未生成普通故事卡片。",
|
||||
OpenTopic: "如确有必要处理本次敏感内容,应由有权限人员在受控流程中单独核对。",
|
||||
OpenTopic: "",
|
||||
Confidence: 1,
|
||||
ModelRef: modelRef,
|
||||
PromptVersion: "summary-sensitive-filter-v1:" + reason,
|
||||
@@ -291,7 +293,7 @@ func validGeneratedContent(result GenerationResult) bool {
|
||||
return !result.StoryWorthy && result.Summary == "" && result.OpenTopic == "" && result.StoryTitle == "" && result.StoryContent == "" && result.FactContent == "" && len(result.Keywords) == 0
|
||||
}
|
||||
if result.Summary == "" || len([]rune(result.Summary)) > 2000 ||
|
||||
result.OpenTopic == "" || len([]rune(result.OpenTopic)) > 1000 ||
|
||||
len([]rune(result.OpenTopic)) > 1000 ||
|
||||
len(result.Keywords) < 1 || len(result.Keywords) > 8 {
|
||||
return false
|
||||
}
|
||||
@@ -313,7 +315,7 @@ const contentValuePrompt = `你是长者聊天内容筛选与整理助手。只
|
||||
必须只返回JSON对象,字段为meaningful、story_worthy、decision_reason、summary、keywords、open_topic、story_title、story_content、fact_content、confidence。
|
||||
- decision_reason用一句简短中文说明判断依据。
|
||||
- meaningful=false时,除decision_reason和confidence外,其余文本必须为空字符串,keywords必须为空数组,story_worthy必须为false。
|
||||
- meaningful=true时,summary概括有意义内容,keywords为1至8个简短关键词,open_topic给出一个温和且不重复追问的后续话题。
|
||||
- meaningful=true时,summary概括有意义内容,keywords为1至8个简短关键词。只有存在明确、自然且尚未聊完的线索时,open_topic才给出一个温和的后续方向;没有合适线索时必须为空字符串,不要为了填字段编造问题。
|
||||
- story_worthy=false时,story_title、story_content、fact_content必须为空字符串。
|
||||
- story_worthy=true时,story_title和story_content忠实整理原话,fact_content只写对话中可核对的事实。
|
||||
- confidence取0到1。`
|
||||
|
||||
Reference in New Issue
Block a user