From ed8d7b007596948ddd117bcd136d39711a99363f Mon Sep 17 00:00:00 2001 From: zstar <65890619+zstar1003@users.noreply.github.com> Date: Sun, 8 Jun 2025 20:44:14 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E8=BF=9E=E6=8E=A5=E9=85=8D=E7=BD=AE=E5=92=8Cminio?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=AE=BF=E9=97=AE=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在数据库服务中添加 MINIO_VISIT_HOST 配置,用于指定 MinIO 访问主机 - 修改对话服务和写入服务中生成 MinIO URL 的逻辑,使用新的 visit_point 配置 --- api/db/services/database.py | 3 +++ api/db/services/dialog_service.py | 4 ++-- api/db/services/write_service.py | 2 +- docker/.env | 7 +++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/api/db/services/database.py b/api/db/services/database.py index 938fcd9..44218e2 100644 --- a/api/db/services/database.py +++ b/api/db/services/database.py @@ -28,6 +28,7 @@ if is_running_in_docker(): MYSQL_HOST = "mysql" MYSQL_PORT = 3306 MINIO_HOST = "minio" + MINIO_VISIT_HOST = "localhost" MINIO_PORT = 9000 ES_HOST = "es01" ES_PORT = 9200 @@ -37,6 +38,7 @@ else: MYSQL_HOST = "localhost" MYSQL_PORT = int(os.getenv("MYSQL_PORT", "5455")) MINIO_HOST = "localhost" + MINIO_VISIT_HOST = "localhost" MINIO_PORT = int(os.getenv("MINIO_PORT", "9000")) ES_HOST = "localhost" ES_PORT = int(os.getenv("ES_PORT", "9200")) @@ -59,6 +61,7 @@ MINIO_CONFIG = { "access_key": os.getenv("MINIO_USER", "rag_flow"), "secret_key": os.getenv("MINIO_PASSWORD", "infini_rag_flow"), "secure": False, + "visit_point": f"{MINIO_VISIT_HOST}:{MINIO_PORT}", } # Elasticsearch连接配置 diff --git a/api/db/services/dialog_service.py b/api/db/services/dialog_service.py index 50d0ddc..e56b131 100644 --- a/api/db/services/dialog_service.py +++ b/api/db/services/dialog_service.py @@ -262,7 +262,7 @@ def chat(dialog, messages, stream=True, **kwargs): return match.group(0) protocol = "https" if MINIO_CONFIG.get("secure", False) else "http" - img_url = f"{protocol}://{MINIO_CONFIG['endpoint']}/{img_path}" + img_url = f"{protocol}://{MINIO_CONFIG['visit_point']}/{img_path}" if img_url in processed_image_urls: return match.group(0) @@ -271,7 +271,7 @@ def chat(dialog, messages, stream=True, **kwargs): inserted_images[idx] = img_url # 插入图片,不加任何括号包裹引用标记 - return f"{match.group(0)}\n\n![image]({img_url})" + return f"{match.group(0)}\n\n![img_url]({img_url})" # 用正则替换插图 answer = re.sub(r"##(\d+)\$\$", insert_image_markdown, answer) diff --git a/api/db/services/write_service.py b/api/db/services/write_service.py index 37814d7..241f65d 100644 --- a/api/db/services/write_service.py +++ b/api/db/services/write_service.py @@ -78,7 +78,7 @@ def write_dialog(question, kb_ids, tenant_id, similarity_threshold, keyword_simi # 流式返回完毕后,追加图片 image_markdowns = [] image_urls = set() - minio_endpoint = MINIO_CONFIG["endpoint"] + minio_endpoint = MINIO_CONFIG["visit_point"] use_ssl = MINIO_CONFIG.get("secure", False) protocol = "https" if use_ssl else "http" diff --git a/docker/.env b/docker/.env index 3b97fe4..50dbed8 100644 --- a/docker/.env +++ b/docker/.env @@ -84,11 +84,10 @@ RAGFLOWPLUS_MANAGEMENT_SERVER_IMAGE=zstar1003/ragflowplus-management-server:v0.4 TIMEZONE='Asia/Shanghai' # Uncomment the following line if you have limited access to huggingface.co: -# HF_ENDPOINT=https://hf-mirror.com +HF_ENDPOINT=https://hf-mirror.com -# Optimizations for MacOS -# Uncomment the following line if your operating system is MacOS: -# MACOS=1 +# 如果是MacOS,改成MACOS="" +MACOS="" # 后端允许上传的最大文件大小 MAX_CONTENT_LENGTH=10737418240 # 10GB