refactor: 重构提示词构建逻辑并移除不再使用的文件处理服务
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
server:
|
||||
address: ":3005"
|
||||
address: ":3009"
|
||||
name: "prompts-core"
|
||||
workerId: 1 # 雪花算法 worker ID(用于 common/db/gfdb)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ type prompt struct{}
|
||||
// Prompt 提示词配置控制器
|
||||
var Prompt = new(prompt)
|
||||
|
||||
// ComposeMessages 调用 model-gateway 异步任务并同步等待结果
|
||||
// ComposeMessages 调用 model-gateway 异步任务并同步等待结果,
|
||||
func (c *prompt) ComposeMessages(ctx context.Context, req *dto.ComposeMessagesReq) (res *dto.ComposeMessagesRes, err error) {
|
||||
return service.Prompt.ComposeMessages(ctx, req)
|
||||
}
|
||||
@@ -58,23 +58,7 @@ func (c *prompt) GetPrompt(ctx context.Context, req *dto.GetPromptReq) (res *dto
|
||||
|
||||
// ListPrompt 配置列表
|
||||
func (c *prompt) ListPrompt(ctx context.Context, req *dto.ListPromptReq) (res *dto.ListPromptRes, err error) {
|
||||
pageNum, pageSize := 1, 10
|
||||
if req != nil && req.Page != nil {
|
||||
if req.Page.PageNum > 0 {
|
||||
pageNum = int(req.Page.PageNum)
|
||||
}
|
||||
if req.Page.PageSize > 0 {
|
||||
pageSize = int(req.Page.PageSize)
|
||||
}
|
||||
}
|
||||
var modelTypeID *int
|
||||
modelType := ""
|
||||
if req != nil {
|
||||
modelTypeID = req.ModelTypeId
|
||||
modelType = req.ModelType
|
||||
}
|
||||
|
||||
list, total, err := service.Prompt.List(ctx, pageNum, pageSize, modelTypeID, modelType)
|
||||
list, total, err := service.Prompt.List(ctx, int(req.Page.PageNum), int(req.Page.PageSize), req.ModelTypeId, req.ModelType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ func buildInferenceRequest(ctx context.Context, req *dto.ComposeMessagesReq, cha
|
||||
"role": "system",
|
||||
"content": promptBuild(ctx, req, model),
|
||||
})
|
||||
|
||||
// 2. 构建历史会话提示词
|
||||
for _, msg := range history {
|
||||
role := gconv.String(msg["role"])
|
||||
@@ -114,7 +114,9 @@ func (s *promptService) ComposeMessages(ctx context.Context, req *dto.ComposeMes
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fmt.Println("构建节点前", taskRecord)
|
||||
message = s.parseNodeBuild(taskRecord)
|
||||
fmt.Println("构建节点后", message)
|
||||
default:
|
||||
epicycleId, err = dao.ComposeSession.Insert(ctx, &entity.ComposeSession{
|
||||
SessionId: req.SessionId,
|
||||
|
||||
Reference in New Issue
Block a user