|
|
|
|
|
|
|
|
import concurrent.futures |
|
|
import concurrent.futures |
|
|
import json |
|
|
import json |
|
|
|
|
|
from concurrent.futures import ThreadPoolExecutor |
|
|
from typing import Optional |
|
|
from typing import Optional |
|
|
|
|
|
|
|
|
from flask import Flask, current_app |
|
|
from flask import Flask, current_app |
|
|
|
|
|
|
|
|
exceptions: list[str] = [] |
|
|
exceptions: list[str] = [] |
|
|
|
|
|
|
|
|
# Optimize multithreading with thread pools |
|
|
# 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 = [] |
|
|
futures = [] |
|
|
if retrieval_method == "keyword_search": |
|
|
if retrieval_method == "keyword_search": |
|
|
futures.append( |
|
|
futures.append( |