From e3e68f10063ec97b1ff8b00353e5e6dab9b094aa Mon Sep 17 00:00:00 2001 From: zstar <65890619+zstar1003@users.noreply.github.com> Date: Sat, 7 Jun 2025 15:41:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor(write):=20=E6=96=87=E6=A1=A3=E6=92=B0?= =?UTF-8?q?=E5=86=99=E6=A8=A1=E5=BC=8F=E4=BF=AE=E6=94=B9=E7=94=9F=E5=9B=BE?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E9=80=82=E9=85=8D=20PR#154=20?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- README_EN.md | 2 +- api/db/services/write_service.py | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9377db6..e2d69af 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ ollama pull bge-m3:latest 访问地址:`服务器ip:8888`,进入到后台管理界面 -#### 2. 源码运行(mysql、minio、es等组件仍需docker启动) +#### 2. 源码运行(mysql、minio、es、redis等组件仍需docker启动) 1. 启动后台管理系统: diff --git a/README_EN.md b/README_EN.md index 7c27890..c2b8ed0 100644 --- a/README_EN.md +++ b/README_EN.md @@ -58,7 +58,7 @@ Access the admin dashboard at: `your-server-ip:8888` 📘 Step-by-step tutorial: [https://blog.csdn.net/qq1198768105/article/details/147475488](https://blog.csdn.net/qq1198768105/article/details/147475488) -#### 2. Run from Source Code (Docker is still required for MySQL, MinIO, Elasticsearch, etc.) +#### 2. Run from Source Code (Docker is still required for MySQL, MinIO, Elasticsearch, Redis, etc.) 1. Start the Admin System: diff --git a/api/db/services/write_service.py b/api/db/services/write_service.py index b6243b6..37814d7 100644 --- a/api/db/services/write_service.py +++ b/api/db/services/write_service.py @@ -5,6 +5,7 @@ from api.db.services.llm_service import LLMBundle from api import settings from rag.app.tag import label_question from rag.prompts import kb_prompt +from .database import MINIO_CONFIG def write_dialog(question, kb_ids, tenant_id, similarity_threshold, keyword_similarity_weight, temperature): @@ -77,9 +78,19 @@ def write_dialog(question, kb_ids, tenant_id, similarity_threshold, keyword_simi # 流式返回完毕后,追加图片 image_markdowns = [] image_urls = set() + minio_endpoint = MINIO_CONFIG["endpoint"] + use_ssl = MINIO_CONFIG.get("secure", False) + protocol = "https" if use_ssl else "http" + for chunk in kbinfos["chunks"]: - img_url = chunk.get("image_id") - if img_url and img_url not in image_urls: + img_path = chunk.get("image_id") + if not img_path: + continue + + img_path = img_path.strip() # 清理前后空格 + img_url = f"{protocol}://{minio_endpoint}/{img_path}" + + if img_url not in image_urls: image_urls.add(img_url) image_markdowns.append(f"\n![{img_url}]({img_url})")