From dfdd6dfa20cc1d3eaa3a359add00daa7c2dc6379 Mon Sep 17 00:00:00 2001 From: Bowen Liang Date: Wed, 19 Feb 2025 09:13:36 +0800 Subject: [PATCH] fix: change the config name and fix typo in description of the number of retrieval executors (#13856) --- api/configs/middleware/__init__.py | 4 ++-- api/core/rag/datasource/retrieval_service.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/configs/middleware/__init__.py b/api/configs/middleware/__init__.py index af1d5d7497..2aa06c5aac 100644 --- a/api/configs/middleware/__init__.py +++ b/api/configs/middleware/__init__.py @@ -167,8 +167,8 @@ class DatabaseConfig(BaseSettings): default=False, ) - RETRIEVAL_SERVICE_WORKER: NonNegativeInt = Field( - description="If True, enables the retrieval service worker.", + RETRIEVAL_SERVICE_EXECUTORS: NonNegativeInt = Field( + description="Number of processes for the retrieval service, default to CPU cores.", default=os.cpu_count(), ) diff --git a/api/core/rag/datasource/retrieval_service.py b/api/core/rag/datasource/retrieval_service.py index ad41dbeb1d..bd0996c9c6 100644 --- a/api/core/rag/datasource/retrieval_service.py +++ b/api/core/rag/datasource/retrieval_service.py @@ -1,5 +1,6 @@ import concurrent.futures import json +from concurrent.futures import ThreadPoolExecutor from typing import Optional from flask import Flask, current_app @@ -52,7 +53,7 @@ class RetrievalService: exceptions: list[str] = [] # Optimize multithreading with thread pools - with concurrent.futures.ThreadPoolExecutor(max_workers=dify_config.RETRIEVAL_SERVICE_WORKER) as executor: # type: ignore + with ThreadPoolExecutor(max_workers=dify_config.RETRIEVAL_SERVICE_EXECUTORS) as executor: # type: ignore futures = [] if retrieval_method == "keyword_search": futures.append(