Refa: Clean the folders. (#12890)

### Type of change

- [x] Refactoring
This commit is contained in:
Kevin Hu
2026-01-29 14:23:26 +08:00
committed by GitHub
parent d86b7f9721
commit 32c0161ff1
42 changed files with 50 additions and 52 deletions

View File

@ -27,7 +27,7 @@ RAGFlow is an open-source RAG (Retrieval-Augmented Generation) engine based on d
- **Document Processing**: `deepdoc/` - PDF parsing, OCR, layout analysis - **Document Processing**: `deepdoc/` - PDF parsing, OCR, layout analysis
- **LLM Integration**: `rag/llm/` - Model abstractions for chat, embedding, reranking - **LLM Integration**: `rag/llm/` - Model abstractions for chat, embedding, reranking
- **RAG Pipeline**: `rag/flow/` - Chunking, parsing, tokenization - **RAG Pipeline**: `rag/flow/` - Chunking, parsing, tokenization
- **Graph RAG**: `graphrag/` - Knowledge graph construction and querying - **Graph RAG**: `rag/graphrag/` - Knowledge graph construction and querying
### Agent System (`/agent/`) ### Agent System (`/agent/`)
- **Components**: Modular workflow components (LLM, retrieval, categorize, etc.) - **Components**: Modular workflow components (LLM, retrieval, categorize, etc.)
@ -113,4 +113,4 @@ RAGFlow supports switching between Elasticsearch (default) and Infinity:
- Node.js >=18.20.4 - Node.js >=18.20.4
- Docker & Docker Compose - Docker & Docker Compose
- uv package manager - uv package manager
- 16GB+ RAM, 50GB+ disk space - 16GB+ RAM, 50GB+ disk space

View File

@ -192,10 +192,8 @@ COPY conf conf
COPY deepdoc deepdoc COPY deepdoc deepdoc
COPY rag rag COPY rag rag
COPY agent agent COPY agent agent
COPY graphrag graphrag
COPY pyproject.toml uv.lock ./ COPY pyproject.toml uv.lock ./
COPY mcp mcp COPY mcp mcp
COPY plugin plugin
COPY common common COPY common common
COPY memory memory COPY memory memory

View File

@ -23,7 +23,7 @@ All the execution logic of this tool should go into this method.
When you start RAGFlow, you can see your plugin was loaded in the log: When you start RAGFlow, you can see your plugin was loaded in the log:
``` ```
2025-05-15 19:29:08,959 INFO 34670 Recursively importing plugins from path `/some-path/ragflow/plugin/embedded_plugins` 2025-05-15 19:29:08,959 INFO 34670 Recursively importing plugins from path `/some-path/ragflow/agent/plugin/embedded_plugins`
2025-05-15 19:29:08,960 INFO 34670 Loaded llm_tools plugin BadCalculatorPlugin version 1.0.0 2025-05-15 19:29:08,960 INFO 34670 Loaded llm_tools plugin BadCalculatorPlugin version 1.0.0
``` ```

View File

@ -23,7 +23,7 @@ RAGFlow将会从`embedded_plugins`子文件夹中递归加载所有的插件。
当你启动RAGFlow时你会在日志中看见你的插件被加载了 当你启动RAGFlow时你会在日志中看见你的插件被加载了
``` ```
2025-05-15 19:29:08,959 INFO 34670 Recursively importing plugins from path `/some-path/ragflow/plugin/embedded_plugins` 2025-05-15 19:29:08,959 INFO 34670 Recursively importing plugins from path `/some-path/ragflow/agent/plugin/embedded_plugins`
2025-05-15 19:29:08,960 INFO 34670 Loaded llm_tools plugin BadCalculatorPlugin version 1.0.0 2025-05-15 19:29:08,960 INFO 34670 Loaded llm_tools plugin BadCalculatorPlugin version 1.0.0
``` ```

View File

@ -1,5 +1,5 @@
import logging import logging
from plugin.llm_tool_plugin import LLMToolMetadata, LLMToolPlugin from agent.plugin.llm_tool_plugin import LLMToolMetadata, LLMToolPlugin
class BadCalculatorPlugin(LLMToolPlugin): class BadCalculatorPlugin(LLMToolPlugin):

View File

@ -18,7 +18,7 @@
from quart import Response from quart import Response
from api.apps import login_required from api.apps import login_required
from api.utils.api_utils import get_json_result from api.utils.api_utils import get_json_result
from plugin import GlobalPluginManager from agent.plugin import GlobalPluginManager
@manager.route('/llm_tools', methods=['GET']) # noqa: F821 @manager.route('/llm_tools', methods=['GET']) # noqa: F821

View File

@ -35,7 +35,7 @@ from api.db.services.llm_service import LLMBundle
from common.metadata_utils import apply_meta_data_filter from common.metadata_utils import apply_meta_data_filter
from api.db.services.tenant_llm_service import TenantLLMService from api.db.services.tenant_llm_service import TenantLLMService
from common.time_utils import current_timestamp, datetime_format from common.time_utils import current_timestamp, datetime_format
from graphrag.general.mind_map_extractor import MindMapExtractor from rag.graphrag.general.mind_map_extractor import MindMapExtractor
from rag.advanced_rag import DeepResearcher from rag.advanced_rag import DeepResearcher
from rag.app.tag import label_question from rag.app.tag import label_question
from rag.nlp.search import index_name from rag.nlp.search import index_name

View File

@ -1077,7 +1077,7 @@ def doc_upload_and_parse(conversation_id, file_objs, user_id):
cks = [c for c in docs if c["doc_id"] == doc_id] cks = [c for c in docs if c["doc_id"] == doc_id]
if parser_ids[doc_id] != ParserType.PICTURE.value: if parser_ids[doc_id] != ParserType.PICTURE.value:
from graphrag.general.mind_map_extractor import MindMapExtractor from rag.graphrag.general.mind_map_extractor import MindMapExtractor
mindmap = MindMapExtractor(llm_bdl) mindmap = MindMapExtractor(llm_bdl)
try: try:
mind_map = asyncio.run(mindmap([c["content_with_weight"] for c in docs if c["doc_id"] == doc_id])) mind_map = asyncio.run(mindmap([c["content_with_weight"] for c in docs if c["doc_id"] == doc_id]))

View File

@ -41,7 +41,7 @@ from common.versions import get_ragflow_version
from common.config_utils import show_configs from common.config_utils import show_configs
from common.mcp_tool_call_conn import shutdown_all_mcp_sessions from common.mcp_tool_call_conn import shutdown_all_mcp_sessions
from common.log_utils import init_root_logger from common.log_utils import init_root_logger
from plugin import GlobalPluginManager from agent.plugin import GlobalPluginManager
from rag.utils.redis_conn import RedisDistributedLock from rag.utils.redis_conn import RedisDistributedLock
stop_event = threading.Event() stop_event = threading.Event()

View File

@ -317,7 +317,7 @@ def init_settings():
global retriever, kg_retriever global retriever, kg_retriever
retriever = search.Dealer(docStoreConn) retriever = search.Dealer(docStoreConn)
from graphrag import search as kg_search from rag.graphrag import search as kg_search
kg_retriever = kg_search.KGSearch(docStoreConn) kg_retriever = kg_search.KGSearch(docStoreConn)

View File

@ -124,7 +124,7 @@ def chunk(filename, binary=None, lang="Chinese", callback=None, **kwargs):
def label_question(question, kbs): def label_question(question, kbs):
from api.db.services.knowledgebase_service import KnowledgebaseService from api.db.services.knowledgebase_service import KnowledgebaseService
from graphrag.utils import get_tags_from_cache, set_tags_to_cache from rag.graphrag.utils import get_tags_from_cache, set_tags_to_cache
tags = None tags = None
tag_kb_ids = [] tag_kb_ids = []
for kb in kbs: for kb in kbs:

View File

@ -23,12 +23,12 @@ from typing import Any, Callable
import networkx as nx import networkx as nx
from graphrag.general.extractor import Extractor from rag.graphrag.general.extractor import Extractor
from rag.nlp import is_english from rag.nlp import is_english
import editdistance import editdistance
from graphrag.entity_resolution_prompt import ENTITY_RESOLUTION_PROMPT from rag.graphrag.entity_resolution_prompt import ENTITY_RESOLUTION_PROMPT
from rag.llm.chat_model import Base as CompletionLLM from rag.llm.chat_model import Base as CompletionLLM
from graphrag.utils import perform_variable_replacements, chat_limiter, GraphChange from rag.graphrag.utils import perform_variable_replacements, chat_limiter, GraphChange
from api.db.services.task_service import has_canceled from api.db.services.task_service import has_canceled
from common.exceptions import TaskCanceledException from common.exceptions import TaskCanceledException

View File

@ -21,12 +21,12 @@ import pandas as pd
from api.db.services.task_service import has_canceled from api.db.services.task_service import has_canceled
from common.exceptions import TaskCanceledException from common.exceptions import TaskCanceledException
from common.connection_utils import timeout from common.connection_utils import timeout
from graphrag.general import leiden from rag.graphrag.general import leiden
from graphrag.general.community_report_prompt import COMMUNITY_REPORT_PROMPT from rag.graphrag.general.community_report_prompt import COMMUNITY_REPORT_PROMPT
from graphrag.general.extractor import Extractor from rag.graphrag.general.extractor import Extractor
from graphrag.general.leiden import add_community_info2graph from rag.graphrag.general.leiden import add_community_info2graph
from rag.llm.chat_model import Base as CompletionLLM from rag.llm.chat_model import Base as CompletionLLM
from graphrag.utils import perform_variable_replacements, dict_has_keys_with_types, chat_limiter from rag.graphrag.utils import perform_variable_replacements, dict_has_keys_with_types, chat_limiter
from common.token_utils import num_tokens_from_string from common.token_utils import num_tokens_from_string
@dataclass @dataclass

View File

@ -9,7 +9,7 @@ from typing import Any
import numpy as np import numpy as np
import networkx as nx import networkx as nx
from dataclasses import dataclass from dataclasses import dataclass
from graphrag.general.leiden import stable_largest_connected_component from rag.graphrag.general.leiden import stable_largest_connected_component
import graspologic as gc import graspologic as gc
@ -63,4 +63,4 @@ def run(graph: nx.Graph, args: dict[str, Any]) -> dict:
pairs = zip(embeddings.nodes, embeddings.embeddings.tolist(), strict=True) pairs = zip(embeddings.nodes, embeddings.embeddings.tolist(), strict=True)
sorted_pairs = sorted(pairs, key=lambda x: x[0]) sorted_pairs = sorted(pairs, key=lambda x: x[0])
return dict(sorted_pairs) return dict(sorted_pairs)

View File

@ -26,8 +26,8 @@ import networkx as nx
from api.db.services.task_service import has_canceled from api.db.services.task_service import has_canceled
from common.connection_utils import timeout from common.connection_utils import timeout
from common.token_utils import truncate from common.token_utils import truncate
from graphrag.general.graph_prompt import SUMMARIZE_DESCRIPTIONS_PROMPT from rag.graphrag.general.graph_prompt import SUMMARIZE_DESCRIPTIONS_PROMPT
from graphrag.utils import ( from rag.graphrag.utils import (
GraphChange, GraphChange,
chat_limiter, chat_limiter,
flat_uniq_list, flat_uniq_list,

View File

@ -13,9 +13,9 @@ from typing import Any
from dataclasses import dataclass from dataclasses import dataclass
import tiktoken import tiktoken
from graphrag.general.extractor import Extractor, ENTITY_EXTRACTION_MAX_GLEANINGS from rag.graphrag.general.extractor import Extractor, ENTITY_EXTRACTION_MAX_GLEANINGS
from graphrag.general.graph_prompt import GRAPH_EXTRACTION_PROMPT, CONTINUE_PROMPT, LOOP_PROMPT from rag.graphrag.general.graph_prompt import GRAPH_EXTRACTION_PROMPT, CONTINUE_PROMPT, LOOP_PROMPT
from graphrag.utils import ErrorHandlerFn, perform_variable_replacements, chat_limiter, split_string_by_multi_markers from rag.graphrag.utils import ErrorHandlerFn, perform_variable_replacements, chat_limiter, split_string_by_multi_markers
from rag.llm.chat_model import Base as CompletionLLM from rag.llm.chat_model import Base as CompletionLLM
import networkx as nx import networkx as nx
from common.token_utils import num_tokens_from_string from common.token_utils import num_tokens_from_string

View File

@ -25,12 +25,12 @@ from api.db.services.task_service import has_canceled
from common.exceptions import TaskCanceledException from common.exceptions import TaskCanceledException
from common.misc_utils import get_uuid from common.misc_utils import get_uuid
from common.connection_utils import timeout from common.connection_utils import timeout
from graphrag.entity_resolution import EntityResolution from rag.graphrag.entity_resolution import EntityResolution
from graphrag.general.community_reports_extractor import CommunityReportsExtractor from rag.graphrag.general.community_reports_extractor import CommunityReportsExtractor
from graphrag.general.extractor import Extractor from rag.graphrag.general.extractor import Extractor
from graphrag.general.graph_extractor import GraphExtractor as GeneralKGExt from rag.graphrag.general.graph_extractor import GraphExtractor as GeneralKGExt
from graphrag.light.graph_extractor import GraphExtractor as LightKGExt from rag.graphrag.light.graph_extractor import GraphExtractor as LightKGExt
from graphrag.utils import ( from rag.graphrag.utils import (
GraphChange, GraphChange,
chunk_id, chunk_id,
does_graph_contains, does_graph_contains,

View File

@ -21,9 +21,9 @@ import re
from typing import Any from typing import Any
from dataclasses import dataclass from dataclasses import dataclass
from graphrag.general.extractor import Extractor from rag.graphrag.general.extractor import Extractor
from graphrag.general.mind_map_prompt import MIND_MAP_EXTRACTION_PROMPT from rag.graphrag.general.mind_map_prompt import MIND_MAP_EXTRACTION_PROMPT
from graphrag.utils import ErrorHandlerFn, perform_variable_replacements, chat_limiter from rag.graphrag.utils import ErrorHandlerFn, perform_variable_replacements, chat_limiter
from rag.llm.chat_model import Base as CompletionLLM from rag.llm.chat_model import Base as CompletionLLM
import markdown_to_json import markdown_to_json
from functools import reduce from functools import reduce

View File

@ -25,8 +25,8 @@ from api.db.services.document_service import DocumentService
from api.db.services.knowledgebase_service import KnowledgebaseService from api.db.services.knowledgebase_service import KnowledgebaseService
from api.db.services.llm_service import LLMBundle from api.db.services.llm_service import LLMBundle
from api.db.services.user_service import TenantService from api.db.services.user_service import TenantService
from graphrag.general.graph_extractor import GraphExtractor from rag.graphrag.general.graph_extractor import GraphExtractor
from graphrag.general.index import update_graph, with_resolution, with_community from rag.graphrag.general.index import update_graph, with_resolution, with_community
from common import settings from common import settings
settings.init_settings() settings.init_settings()

View File

@ -15,9 +15,9 @@ from typing import Any
import networkx as nx import networkx as nx
from graphrag.general.extractor import ENTITY_EXTRACTION_MAX_GLEANINGS, Extractor from rag.graphrag.general.extractor import ENTITY_EXTRACTION_MAX_GLEANINGS, Extractor
from graphrag.light.graph_prompt import PROMPTS from rag.graphrag.light.graph_prompt import PROMPTS
from graphrag.utils import chat_limiter, pack_user_ass_to_openai_messages, split_string_by_multi_markers from rag.graphrag.utils import chat_limiter, pack_user_ass_to_openai_messages, split_string_by_multi_markers
from rag.llm.chat_model import Base as CompletionLLM from rag.llm.chat_model import Base as CompletionLLM
from common.token_utils import num_tokens_from_string from common.token_utils import num_tokens_from_string

View File

@ -25,8 +25,8 @@ from api.db.services.document_service import DocumentService
from api.db.services.knowledgebase_service import KnowledgebaseService from api.db.services.knowledgebase_service import KnowledgebaseService
from api.db.services.llm_service import LLMBundle from api.db.services.llm_service import LLMBundle
from api.db.services.user_service import TenantService from api.db.services.user_service import TenantService
from graphrag.general.index import update_graph from rag.graphrag.general.index import update_graph
from graphrag.light.graph_extractor import GraphExtractor from rag.graphrag.light.graph_extractor import GraphExtractor
from common import settings from common import settings
settings.init_settings() settings.init_settings()

View File

@ -22,8 +22,8 @@ import json_repair
import pandas as pd import pandas as pd
from common.misc_utils import get_uuid from common.misc_utils import get_uuid
from graphrag.query_analyze_prompt import PROMPTS from rag.graphrag.query_analyze_prompt import PROMPTS
from graphrag.utils import get_entity_type2samples, get_llm_cache, set_llm_cache, get_relation from rag.graphrag.utils import get_entity_type2samples, get_llm_cache, set_llm_cache, get_relation
from common.token_utils import num_tokens_from_string from common.token_utils import num_tokens_from_string
from rag.nlp.search import Dealer, index_name from rag.nlp.search import Dealer, index_name

View File

@ -492,7 +492,7 @@ async def gen_meta_filter(chat_mdl, meta_data: dict, query: str) -> dict:
async def gen_json(system_prompt: str, user_prompt: str, chat_mdl, gen_conf={}, max_retry=2): async def gen_json(system_prompt: str, user_prompt: str, chat_mdl, gen_conf={}, max_retry=2):
from graphrag.utils import get_llm_cache, set_llm_cache from rag.graphrag.utils import get_llm_cache, set_llm_cache
cached = get_llm_cache(chat_mdl.llm_name, system_prompt, user_prompt, gen_conf) cached = get_llm_cache(chat_mdl.llm_name, system_prompt, user_prompt, gen_conf)
if cached: if cached:
return json_repair.loads(cached) return json_repair.loads(cached)
@ -928,4 +928,4 @@ async def multi_queries_gen(chat_mdl, question: str, query:str, missing_infos:li
) )
except Exception as e: except Exception as e:
logging.exception(e) logging.exception(e)
return {} return {}

View File

@ -25,7 +25,7 @@ from api.db.services.task_service import has_canceled
from common.connection_utils import timeout from common.connection_utils import timeout
from common.exceptions import TaskCanceledException from common.exceptions import TaskCanceledException
from common.token_utils import truncate from common.token_utils import truncate
from graphrag.utils import ( from rag.graphrag.utils import (
chat_limiter, chat_limiter,
get_embed_cache, get_embed_cache,
get_llm_cache, get_llm_cache,

View File

@ -40,8 +40,8 @@ from rag.utils.base64_image import image2id
from rag.utils.raptor_utils import should_skip_raptor, get_skip_reason from rag.utils.raptor_utils import should_skip_raptor, get_skip_reason
from common.log_utils import init_root_logger from common.log_utils import init_root_logger
from common.config_utils import show_configs from common.config_utils import show_configs
from graphrag.general.index import run_graphrag_for_kb from rag.graphrag.general.index import run_graphrag_for_kb
from graphrag.utils import get_llm_cache, set_llm_cache, get_tags_from_cache, set_tags_to_cache from rag.graphrag.utils import get_llm_cache, set_llm_cache, get_tags_from_cache, set_tags_to_cache
from rag.prompts.generator import keyword_extraction, question_proposal, content_tagging, run_toc_from_text, \ from rag.prompts.generator import keyword_extraction, question_proposal, content_tagging, run_toc_from_text, \
gen_metadata gen_metadata
import logging import logging
@ -73,7 +73,7 @@ from rag.nlp import search, rag_tokenizer, add_positions
from rag.raptor import RecursiveAbstractiveProcessing4TreeOrganizedRetrieval as Raptor from rag.raptor import RecursiveAbstractiveProcessing4TreeOrganizedRetrieval as Raptor
from common.token_utils import num_tokens_from_string, truncate from common.token_utils import num_tokens_from_string, truncate
from rag.utils.redis_conn import REDIS_CONN, RedisDistributedLock from rag.utils.redis_conn import REDIS_CONN, RedisDistributedLock
from graphrag.utils import chat_limiter from rag.graphrag.utils import chat_limiter
from common.signal_utils import start_tracemalloc_and_snapshot, stop_tracemalloc from common.signal_utils import start_tracemalloc_and_snapshot, stop_tracemalloc
from common.exceptions import TaskCanceledException from common.exceptions import TaskCanceledException
from common import settings from common import settings