l_szy_go/szr/szr.go

89 lines
2.8 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 szr
import (
"context"
"l_szr_go/pkg/doubao"
"github.com/volcengine/volcengine-go-sdk/service/arkruntime/model"
"github.com/volcengine/volcengine-go-sdk/volcengine"
"strings"
)
var modelObj *doubao.DouBao
func Instance(key, model string) *doubao.DouBao {
if modelObj == nil {
modelObj = doubao.NewDouBao(model, key)
}
return modelObj
}
type View struct {
Ques string
CheckSkill []string
QuesType string
Ans string
}
func TextCorrect(ctx context.Context, view *View, key string, modelStr string) (result string, err error) {
Instance(key, modelStr)
var texts = make([]*model.ChatCompletionMessage, 4)
texts[0] = &model.ChatCompletionMessage{
Role: model.ChatMessageRoleSystem,
Content: &model.ChatCompletionMessageContent{
StringValue: volcengine.String("你现在是AI面试评估系统的文本修正模块请根据以下输入完成修正任务"),
},
}
texts[1] = &model.ChatCompletionMessage{
Role: model.ChatMessageRoleUser,
Content: &model.ChatCompletionMessageContent{
StringValue: volcengine.String(Input(view)),
},
}
texts[2] = &model.ChatCompletionMessage{
Role: model.ChatMessageRoleUser,
Content: &model.ChatCompletionMessageContent{
StringValue: volcengine.String(modify()),
},
}
texts[3] = &model.ChatCompletionMessage{
Role: model.ChatMessageRoleUser,
Content: &model.ChatCompletionMessageContent{
StringValue: volcengine.String(output()),
},
}
return modelObj.GetData(ctx, func(input string) (string, error) {
return input, nil
}, texts)
}
func Input(view *View) string {
str := `1. 【输入信息】
- 面试问题: "{ques}"
- 问题类型: "{quesType}"
- 涉及知识点: "{checkSkill}"
- 面试者回答: "{Ans}"`
str = strings.ReplaceAll(str, "{ques}", view.Ques)
str = strings.ReplaceAll(str, "{quesType}", view.QuesType)
str = strings.ReplaceAll(str, "{checkSkill}", strings.Join(view.CheckSkill, ","))
str = strings.ReplaceAll(str, "{Ans}", view.Ans)
return str
}
func modify() string {
return `2. 【修正要求】
- 仅修正语音转文字产生的错误(如谐音词/缺失字/多余字),保持回答原意不变
- 对技术术语、专业名词的错误必须修正(如将"Redis"误写为"瑞迪斯"
- 保留回答中的口语化表达(如"嗯""然后"但需删除重复填充词如连续3个"那个"
- 根据提问对回答的内容进行0-100分的打分
- 如果回答内容不足以满足涉及知识点根据回答进行合理追问分数小于20分就不用追问`
}
func output() string {
return `3. 【输出格式json
"{"text":"<修正后的完整文本>","score":<回答内容评分,数字类型>,"ask":"<追问内容文本>","not_enough_check_skill":"<为满足涉及的知识点(多个','隔开)>"}"`
}