Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
Feat/add thread control (#675)
Jyong9eaae770a610
diff --git a/api/core/indexing_runner.py b/api/core/indexing_runner.pyindex 689c53d288e..25cdb69f6d6 100644--- a/api/core/indexing_runner.py+++ b/api/core/indexing_runner.py@@ -1,4 +1,3 @@-import asyncioimport concurrentimport datetimeimport json@@ -8,25 +7,17 @@ import threadingimport timeimport uuidfrom concurrent.futures import ThreadPoolExecutor-from multiprocessing import Processfrom typing import Optional, List, cast-import openai-from billiard.pool import Pool-from flask import current_app, Flaskfrom flask_login import current_user-from langchain.embeddings import OpenAIEmbeddingsfrom langchain.schema import Documentfrom langchain.text_splitter import RecursiveCharacterTextSplitter, TextSplitterfrom core.data_loader.file_extractor import FileExtractorfrom core.data_loader.loader.notion import NotionLoaderfrom core.docstore.dataset_docstore import DatesetDocumentStore-from core.embedding.cached_embedding import CacheEmbeddingfrom core.generator.llm_generator import LLMGeneratorfrom core.index.index import IndexBuilder-from core.index.keyword_table_index.keyword_table_index import KeywordTableIndex, KeywordTableConfig-from core.index.vector_index.vector_index import VectorIndexfrom core.llm.error import ProviderTokenNotInitErrorfrom core.llm.llm_builder import LLMBuilderfrom core.llm.streamable_open_ai import StreamableOpenAI@@ -516,20 +507,23 @@ class IndexingRunner:model_name='gpt-3.5-turbo',max_tokens=2000)- threads = []- for doc in documents:- document_format_thread = threading.Thread(target=self.format_document, kwargs={- 'llm': llm, 'document_node': doc, 'split_documents': split_documents, 'document_form': document_form})- threads.append(document_format_thread)- document_format_thread.start()- for thread in threads:- thread.join()+ for i in range(0, len(documents), 10):+ threads = []+ sub_documents = documents[i:i + 10]+ for doc in sub_documents:+ document_format_thread = threading.Thread(target=self.format_document, kwargs={+ 'llm': llm, 'document_node': doc, 'split_documents': split_documents,+ 'document_form': document_form})+ threads.append(document_format_thread)+ document_format_thread.start()+ for thread in threads:+ thread.join()+all_documents.extend(split_documents)return all_documents- def format_document(self, llm: StreamableOpenAI, document_node, split_documents: List, document_form: str):- print(document_node.page_content)+ def format_document(self, llm: StreamableOpenAI, document_node, split_documents, document_form: str):format_documents = []if document_node.page_content is None or not document_node.page_content.strip():return format_documents