Files
hunli/hunliji-api/spark/blessing.go
2026-08-02 16:11:35 +08:00

55 lines
2.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package spark
import (
"fmt"
"strings"
)
var BlessingStyles = map[string]string{
"classic": "古风典雅",
"modern": "现代文风",
"funny": "搞怪文风",
"roast": "损友文风",
}
func NormalizeStyle(style string) (string, bool) {
s := strings.TrimSpace(style)
_, ok := BlessingStyles[s]
return s, ok
}
func (c *Client) GenerateBlessing(style string) (string, error) {
styleKey, ok := NormalizeStyle(style)
if !ok {
return "", fmt.Errorf("无效的祝福风格")
}
label := BlessingStyles[styleKey]
styleGuide := map[string]string{
"classic": "文言雅致、含蓄温润;可点到意象(花月、琴瑟、白首),忌生僻堆砌与整段文言文。",
"modern": "口语真诚、干净利落;像朋友当面说的话,不鸡汤、不口号堆叠。",
"funny": "俏皮轻松、会心一笑;可玩梗但保持善意,忌低俗与尴尬烂梗。",
"roast": "损友口吻:先轻怼一句再落真心祝福;尺度友好,不人身攻击、不揭隐私。",
}
sys := `你是婚礼短祝福文案助手。
只输出一条可直接填写的中文祝福正文。
禁止:标题、序号、引号包裹、解释说明、表情符号、英文、话题标签。
禁止出现任何真实姓名、网名、称呼占位如某某、X先生/女士)、新郎新娘具体姓氏。
称呼统一用「你们」「新人」等泛称即可。
文案要有意境:有画面感与余韵,可用轻巧意象(光、风、茶、路、灯火、四季等)点染,忌空泛套话与意象堆砌。`
user := fmt.Sprintf(`请写一条送给婚礼新人的短祝福。
风格:%s
写法:%s
意境:先落一两处可感的画面或氛围,再落到真诚祝福,读完有余味。
篇幅2848个汉字一两句说完。
内容:祝福婚姻美满、相守与日常,语气自然,适合弹幕或回执留言。
请直接输出祝福正文。`, label, styleGuide[styleKey])
return c.Chat([]Message{
{Role: "system", Content: sys},
{Role: "user", Content: user},
})
}