feat: 新增模型扩展映射与查询配置字段
This commit is contained in:
@@ -12,9 +12,21 @@ import (
|
||||
"prompts-core/model/dto"
|
||||
"prompts-core/model/entity"
|
||||
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
// UserPromptPayload 用户提示词请求体
|
||||
type UserPromptPayload struct {
|
||||
Model string `json:"model"`
|
||||
PromptInfo string `json:"promptInfo"`
|
||||
Form map[string]any `json:"form"`
|
||||
UserForm any `json:"userForm"`
|
||||
Consult []dto.ConsultItem `json:"consult"`
|
||||
UserFilesText map[string]string `json:"userFilesText"`
|
||||
Skills string `json:"skills"`
|
||||
}
|
||||
|
||||
// buildInferenceRequest 构建推理请求
|
||||
func buildInferenceRequest(ctx context.Context, req *dto.ComposeMessagesReq, chatModel *entity.AsynchModel, aiModel *entity.AsynchModel, history []map[string]any) (map[string]any, error) {
|
||||
processedReq, totalBatches, err := ProcessUserFormBatches(ctx, req, aiModel)
|
||||
@@ -117,7 +129,7 @@ func promptBuildWithRounds(ctx context.Context, req *dto.ComposeMessagesReq, mod
|
||||
%s
|
||||
技能名称: %s
|
||||
用户文件: %v
|
||||
`, req.ModelName, formInfo, req.SkillName, req.UserFiles)
|
||||
`, req.ModelName, formInfo, req.SkillName, req.Consult)
|
||||
|
||||
return fmt.Sprintf(providerProtocol.SystemPromptTemplate,
|
||||
req.ModelName, // %s 目标模型名称
|
||||
@@ -148,19 +160,16 @@ func checkOverallContent(ir *PromptIR, model *entity.AsynchModel) bool {
|
||||
|
||||
// buildUserPrompt 构建用户提示词
|
||||
func buildUserPrompt(ctx context.Context, req *dto.ComposeMessagesReq, prompt string) string {
|
||||
userFormForPayload := prepareUserFormPayload(req.UserForm)
|
||||
|
||||
payload := map[string]any{
|
||||
"model": req.ModelName,
|
||||
"promptInfo": prompt,
|
||||
"form": req.Form,
|
||||
"userForm": userFormForPayload,
|
||||
"userFiles": req.UserFiles,
|
||||
"userFilesText": FetchFileTexts(ctx, req.UserFiles),
|
||||
"skills": SkillMdContent(ctx, req.SkillName),
|
||||
payload := UserPromptPayload{
|
||||
Model: req.ModelName,
|
||||
PromptInfo: prompt,
|
||||
Form: req.Form,
|
||||
UserForm: prepareUserFormPayload(req.UserForm),
|
||||
Consult: req.Consult,
|
||||
UserFilesText: ExtractFileTexts(ctx, req.Consult),
|
||||
Skills: SkillMdContent(ctx, req.SkillName),
|
||||
}
|
||||
|
||||
return util.MustMarshal(payload)
|
||||
return gjson.New(payload).String()
|
||||
}
|
||||
|
||||
// prepareUserFormPayload 准备用户表单载荷
|
||||
|
||||
Reference in New Issue
Block a user