add: 新增Word文件分析服务及路由
This commit is contained in:
parent
f79481d2bf
commit
a950a7b025
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue