feat: 新增任务管理功能

This commit is contained in:
renzhiyuan 2025-11-14 09:45:45 +08:00
parent ec21193f66
commit fdccbb9c67
2 changed files with 18 additions and 1 deletions

View File

@ -74,7 +74,7 @@ func (r *OllamaService) getPrompt(ctx context.Context, requireData *entitys.Requ
Content: "### 聊天记录:" + pkg.JsonStringIgonErr(buildAssistant(requireData.Histories)), Content: "### 聊天记录:" + pkg.JsonStringIgonErr(buildAssistant(requireData.Histories)),
}, api.Message{ }, api.Message{
Role: "user", Role: "user",
Content: requireData.Req.Text, Content: r.getUserContent(requireData),
//Images: requireData.ImgByte, //Images: requireData.ImgByte,
}) })
@ -94,6 +94,22 @@ func (r *OllamaService) getPrompt(ctx context.Context, requireData *entitys.Requ
return prompt, nil return prompt, nil
} }
func (r *OllamaService) getUserContent(requireData *entitys.RequireData) string {
var content strings.Builder
content.WriteString(requireData.Req.Text)
if len(requireData.ImgByte) > 0 {
content.WriteString("\n")
content.WriteString("### 图片内容已经解析到image_desc里")
}
if len(requireData.Req.Tags) > 0 {
content.WriteString("\n")
content.WriteString("### 工具必须使用:")
content.WriteString(requireData.Req.Tags)
}
return content.String()
}
func (r *OllamaService) RecognizeWithImg(ctx context.Context, requireData *entitys.RequireData) (desc api.GenerateResponse, err error) { func (r *OllamaService) RecognizeWithImg(ctx context.Context, requireData *entitys.RequireData) (desc api.GenerateResponse, err error) {
if requireData.ImgByte == nil { if requireData.ImgByte == nil {
return return

View File

@ -31,6 +31,7 @@ type FirstSockRequest struct {
type ChatSockRequest struct { type ChatSockRequest struct {
Text string `json:"text" binding:"required"` Text string `json:"text" binding:"required"`
Img string `json:"img" binding:"required"` Img string `json:"img" binding:"required"`
Tags string `json:"tags" binding:"required"`
Caller string `json:"caller" binding:"required"` Caller string `json:"caller" binding:"required"`
SessionID string `json:"session_id"` SessionID string `json:"session_id"`
} }