From fdccbb9c6750ee05387b5986e7cbdf4e38fa96b2 Mon Sep 17 00:00:00 2001 From: renzhiyuan <465386466@qq.com> Date: Fri, 14 Nov 2025 09:45:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/biz/llm_service/ollama.go | 18 +++++++++++++++++- internal/entitys/types.go | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/internal/biz/llm_service/ollama.go b/internal/biz/llm_service/ollama.go index 417baa7..25791da 100644 --- a/internal/biz/llm_service/ollama.go +++ b/internal/biz/llm_service/ollama.go @@ -74,7 +74,7 @@ func (r *OllamaService) getPrompt(ctx context.Context, requireData *entitys.Requ Content: "### 聊天记录:" + pkg.JsonStringIgonErr(buildAssistant(requireData.Histories)), }, api.Message{ Role: "user", - Content: requireData.Req.Text, + Content: r.getUserContent(requireData), //Images: requireData.ImgByte, }) @@ -94,6 +94,22 @@ func (r *OllamaService) getPrompt(ctx context.Context, requireData *entitys.Requ 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) { if requireData.ImgByte == nil { return diff --git a/internal/entitys/types.go b/internal/entitys/types.go index 1f97bd4..64de5a2 100644 --- a/internal/entitys/types.go +++ b/internal/entitys/types.go @@ -31,6 +31,7 @@ type FirstSockRequest struct { type ChatSockRequest struct { Text string `json:"text" binding:"required"` Img string `json:"img" binding:"required"` + Tags string `json:"tags" binding:"required"` Caller string `json:"caller" binding:"required"` SessionID string `json:"session_id"` }