fix: 优化提示词

This commit is contained in:
cjy 2026-03-03 09:17:50 +08:00
parent ece9a964f9
commit 7cc03c02fa

View File

@ -100,21 +100,21 @@ type DataPerformanceData struct {
// CompetitorReportResponse 竞品报告响应数据
type CompetitorReportResponse struct {
ImageURL string `json:"image_url,omitempty"` // 生成的图片URL1024*1024非必须返回
Text string `json:"text,omitempty"` // 竞品报告文本内容,非必须返回
JsonData *CompetitorReportData `json:"json_data,omitempty"` // 竞品报告JSON数据
ImageURL string `json:"image_url,omitempty"` // 生成的图片URL1024*1024非必须返回
Text string `json:"text,omitempty"` // 竞品报告文本内容,非必须返回
JsonData *CompetitorReportData `json:"json_data,omitempty"` // 竞品报告JSON数据
}
// CompetitorReportJSON AI返回的JSON结构
type CompetitorReportJSON struct {
HighlightAnalysis HighlightAnalysis `json:"highlight_analysis"`
DataPerformance DataPerformance `json:"data_performance_analysis"`
OverallSummary string `json:"overall_summary_and_optimization"`
DataPerformance DataPerformance `json:"data_performance_analysis"`
OverallSummary string `json:"overall_summary_and_optimization"`
}
type HighlightAnalysis struct {
Summary string `json:"summary"`
Points Points `json:"points"`
Summary string `json:"summary"`
Points Points `json:"points"`
}
type Points struct {
@ -127,9 +127,9 @@ type Points struct {
}
type DataPerformance struct {
Views string `json:"views"`
Completion string `json:"completion_rate,omitempty"`
Engagement string `json:"engagement"`
Views string `json:"views"`
Completion string `json:"completion_rate,omitempty"`
Engagement string `json:"engagement"`
}
// convertJSONToText 将 JSON 转换为纯文本格式
@ -321,9 +321,14 @@ func AICompetitorReport(ctx *gin.Context) {
isVideo := len(req.Videos) > 0
// 构建文本生成提示词:理解内容 + 用户要求JSON格式
// 重要必须明确要求使用英文标点符号确保返回的JSON符合规范
// 重要:必须基于内容给出分析性回复,即使没有提供具体数据
var textPrompt string
if isVideo {
textPrompt = fmt.Sprintf(`你必须严格输出以下JSON格式不要输出任何其他内容输出必须以 { 开头并以 } 结束
重要提示
1. 所有字符串值必须使用英文标点符号包括英文逗号, 英文句号. 英文冒号: 英文引号" 禁止使用中文标点符号
2. 即使没有提供具体数据也要基于视频和图片内容给出分析性回复禁止回复"未提供数据""暂无数据"等类似内容而应该根据内容分析数据表现如根据时长分析完播率潜力根据内容质量分析互动潜力等
基于以下视频和图片的内容描述
%s
@ -334,7 +339,10 @@ func AICompetitorReport(ctx *gin.Context) {
JSON结构是固定的请将内容填充到对应的value中禁止修改key禁止添加额外字段禁止输出任何说明文字
{"highlight_analysis":{"summary":"[78字以内的概述]","points":{"theme":"[标题亮点最多60字]","narrative":"[题材亮点最多60字]","content":"[内容亮点最多60字]","copywriting":"[文案亮点最多60字]","data":"[数据亮点最多60字]","music":"[配乐亮点仅视频最多60字]"}},"data_performance_analysis":{"views":"[浏览量表现最多60字]","completion_rate":"[完播率表现仅视频最多60字]","engagement":"[点赞/分享/评论表现最多60字]"},"overall_summary_and_optimization":"[整体总结及可优化建议最多300字]"}`, vlContent, req.TextPrompt)
} else {
textPrompt = fmt.Sprintf(`你必须严格输出以下JSON格式不要输出任何其他内容输出必须以 { 开头并以 } 结束
textPrompt = fmt.Sprintf(`你必须严格输出以下JSON格式不要输出任何其他内容输出开头并以 }必须以 { 结束
重要提示
1. 所有字符串值必须使用英文标点符号包括英文逗号, 英文句号. 英文冒号: 英文引号" 禁止使用中文标点符号
2. 即使没有提供具体数据也要基于视频和图片内容给出分析性回复禁止回复"未提供数据""暂无数据"等类似内容而应该根据内容分析数据表现如根据内容质量分析互动潜力等
基于以下视频和图片的内容描述
%s