diff --git a/internal/biz/advice.go b/internal/biz/advice.go index 94ccd71..3f2eb1f 100644 --- a/internal/biz/advice.go +++ b/internal/biz/advice.go @@ -50,11 +50,14 @@ var dataMap = map[string]string{ func (a *AdviceBiz) WordAna(ctx context.Context, wordContent string) error { examples := a.getAllExamples() prompt := a.buildSimplePrompt(wordContent, examples) + os.WriteFile("requset.json", []byte(prompt), 0644) anaContent, err := a.callLlm(ctx, prompt) if err != nil { return err } + os.WriteFile("res.json", []byte(anaContent), 0644) data := a.parseResponse(anaContent) + jsonData, _ := json.MarshalIndent(data, "", " ") os.WriteFile("extracted.json", jsonData, 0644) fmt.Println("✅ 数据已保存到 extracted.json") @@ -88,15 +91,15 @@ func (a *AdviceBiz) buildSimplePrompt(wordContent string, examples map[string]st 对话内容: %s -请按照以下` + fmt.Sprintf("%d", len(examples)) + `个格式生成JSON数据,每个格式用===分隔: +请按照以下` + fmt.Sprintf("%d", len(examples)) + `个格式生成JSON数据,key为格式名称,value为对应值: %s 输出要求: 1. 每个结构体一个JSON对象 -2. 严格按照示例格式 -3. 用空行分隔不同结构体` - +2. 所有内容必须严格基于提供的对话原文,不得编造 +3. 严格按照示例格式 +4. 将上述生成的` + fmt.Sprintf("%d", len(examples)) + `个JSON对象,json不需要有可读性,不要有特殊符号,比如"\n",用map[string]json来包裹所有json对象:{"SupportingFacilities":{...},"SignatureDialogues":[{...},{...}]}` // 构建格式部分 var formats strings.Builder for name, example := range examples {