From 32c0161ff10d356e1bb569cc3c3718e1610c20a8 Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Thu, 29 Jan 2026 14:23:26 +0800 Subject: [PATCH] Refa: Clean the folders. (#12890) ### Type of change - [x] Refactoring --- CLAUDE.md | 4 ++-- Dockerfile | 2 -- {plugin => agent/plugin}/README.md | 2 +- {plugin => agent/plugin}/README_zh.md | 2 +- {plugin => agent/plugin}/__init__.py | 0 {plugin => agent/plugin}/common.py | 0 .../embedded_plugins/llm_tools/bad_calculator.py | 2 +- {plugin => agent/plugin}/llm_tool_plugin.py | 0 {plugin => agent/plugin}/plugin_manager.py | 0 api/apps/plugin_app.py | 2 +- api/db/services/dialog_service.py | 2 +- api/db/services/document_service.py | 2 +- api/ragflow_server.py | 2 +- common/settings.py | 2 +- {chat_demo => example/chat_demo}/index.html | 0 {chat_demo => example/chat_demo}/widget_demo.html | 0 rag/app/tag.py | 2 +- {graphrag => rag/graphrag}/__init__.py | 0 {graphrag => rag/graphrag}/entity_resolution.py | 6 +++--- .../graphrag}/entity_resolution_prompt.py | 0 {graphrag => rag/graphrag}/general/__init__.py | 0 .../graphrag}/general/community_report_prompt.py | 0 .../graphrag}/general/community_reports_extractor.py | 10 +++++----- .../graphrag}/general/entity_embedding.py | 4 ++-- {graphrag => rag/graphrag}/general/extractor.py | 4 ++-- .../graphrag}/general/graph_extractor.py | 6 +++--- {graphrag => rag/graphrag}/general/graph_prompt.py | 0 {graphrag => rag/graphrag}/general/index.py | 12 ++++++------ {graphrag => rag/graphrag}/general/leiden.py | 0 .../graphrag}/general/mind_map_extractor.py | 6 +++--- .../graphrag}/general/mind_map_prompt.py | 0 {graphrag => rag/graphrag}/general/smoke.py | 4 ++-- {graphrag => rag/graphrag}/light/__init__.py | 0 {graphrag => rag/graphrag}/light/graph_extractor.py | 6 +++--- {graphrag => rag/graphrag}/light/graph_prompt.py | 0 {graphrag => rag/graphrag}/light/smoke.py | 4 ++-- {graphrag => rag/graphrag}/query_analyze_prompt.py | 0 {graphrag => rag/graphrag}/search.py | 4 ++-- {graphrag => rag/graphrag}/utils.py | 0 rag/prompts/generator.py | 4 ++-- rag/raptor.py | 2 +- rag/svr/task_executor.py | 6 +++--- 42 files changed, 50 insertions(+), 52 deletions(-) rename {plugin => agent/plugin}/README.md (98%) rename {plugin => agent/plugin}/README_zh.md (98%) rename {plugin => agent/plugin}/__init__.py (100%) rename {plugin => agent/plugin}/common.py (100%) rename {plugin => agent/plugin}/embedded_plugins/llm_tools/bad_calculator.py (94%) rename {plugin => agent/plugin}/llm_tool_plugin.py (100%) rename {plugin => agent/plugin}/plugin_manager.py (100%) rename {chat_demo => example/chat_demo}/index.html (100%) rename {chat_demo => example/chat_demo}/widget_demo.html (100%) rename {graphrag => rag/graphrag}/__init__.py (100%) rename {graphrag => rag/graphrag}/entity_resolution.py (98%) rename {graphrag => rag/graphrag}/entity_resolution_prompt.py (100%) rename {graphrag => rag/graphrag}/general/__init__.py (100%) rename {graphrag => rag/graphrag}/general/community_report_prompt.py (100%) rename {graphrag => rag/graphrag}/general/community_reports_extractor.py (95%) rename {graphrag => rag/graphrag}/general/entity_embedding.py (94%) rename {graphrag => rag/graphrag}/general/extractor.py (99%) rename {graphrag => rag/graphrag}/general/graph_extractor.py (95%) rename {graphrag => rag/graphrag}/general/graph_prompt.py (100%) rename {graphrag => rag/graphrag}/general/index.py (98%) rename {graphrag => rag/graphrag}/general/leiden.py (100%) rename {graphrag => rag/graphrag}/general/mind_map_extractor.py (96%) rename {graphrag => rag/graphrag}/general/mind_map_prompt.py (100%) rename {graphrag => rag/graphrag}/general/smoke.py (95%) rename {graphrag => rag/graphrag}/light/__init__.py (100%) rename {graphrag => rag/graphrag}/light/graph_extractor.py (95%) rename {graphrag => rag/graphrag}/light/graph_prompt.py (100%) rename {graphrag => rag/graphrag}/light/smoke.py (95%) rename {graphrag => rag/graphrag}/query_analyze_prompt.py (100%) rename {graphrag => rag/graphrag}/search.py (98%) rename {graphrag => rag/graphrag}/utils.py (100%) diff --git a/CLAUDE.md b/CLAUDE.md index d774fc376..58d1217af 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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 - **LLM Integration**: `rag/llm/` - Model abstractions for chat, embedding, reranking - **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/`) - **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 - Docker & Docker Compose - uv package manager -- 16GB+ RAM, 50GB+ disk space \ No newline at end of file +- 16GB+ RAM, 50GB+ disk space diff --git a/Dockerfile b/Dockerfile index 1da884343..c1859878e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -192,10 +192,8 @@ COPY conf conf COPY deepdoc deepdoc COPY rag rag COPY agent agent -COPY graphrag graphrag COPY pyproject.toml uv.lock ./ COPY mcp mcp -COPY plugin plugin COPY common common COPY memory memory diff --git a/plugin/README.md b/agent/plugin/README.md similarity index 98% rename from plugin/README.md rename to agent/plugin/README.md index cd11e91db..4f1ac152c 100644 --- a/plugin/README.md +++ b/agent/plugin/README.md @@ -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: ``` -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 ``` diff --git a/plugin/README_zh.md b/agent/plugin/README_zh.md similarity index 98% rename from plugin/README_zh.md rename to agent/plugin/README_zh.md index 17b3dd703..eb9910ba4 100644 --- a/plugin/README_zh.md +++ b/agent/plugin/README_zh.md @@ -23,7 +23,7 @@ RAGFlow将会从`embedded_plugins`子文件夹中递归加载所有的插件。 当你启动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 ``` diff --git a/plugin/__init__.py b/agent/plugin/__init__.py similarity index 100% rename from plugin/__init__.py rename to agent/plugin/__init__.py diff --git a/plugin/common.py b/agent/plugin/common.py similarity index 100% rename from plugin/common.py rename to agent/plugin/common.py diff --git a/plugin/embedded_plugins/llm_tools/bad_calculator.py b/agent/plugin/embedded_plugins/llm_tools/bad_calculator.py similarity index 94% rename from plugin/embedded_plugins/llm_tools/bad_calculator.py rename to agent/plugin/embedded_plugins/llm_tools/bad_calculator.py index 04c3b815a..38376aa98 100644 --- a/plugin/embedded_plugins/llm_tools/bad_calculator.py +++ b/agent/plugin/embedded_plugins/llm_tools/bad_calculator.py @@ -1,5 +1,5 @@ import logging -from plugin.llm_tool_plugin import LLMToolMetadata, LLMToolPlugin +from agent.plugin.llm_tool_plugin import LLMToolMetadata, LLMToolPlugin class BadCalculatorPlugin(LLMToolPlugin): diff --git a/plugin/llm_tool_plugin.py b/agent/plugin/llm_tool_plugin.py similarity index 100% rename from plugin/llm_tool_plugin.py rename to agent/plugin/llm_tool_plugin.py diff --git a/plugin/plugin_manager.py b/agent/plugin/plugin_manager.py similarity index 100% rename from plugin/plugin_manager.py rename to agent/plugin/plugin_manager.py diff --git a/api/apps/plugin_app.py b/api/apps/plugin_app.py index 6e7a87690..fb0a7bb61 100644 --- a/api/apps/plugin_app.py +++ b/api/apps/plugin_app.py @@ -18,7 +18,7 @@ from quart import Response from api.apps import login_required 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 diff --git a/api/db/services/dialog_service.py b/api/db/services/dialog_service.py index 1a25a8308..8a11397e4 100644 --- a/api/db/services/dialog_service.py +++ b/api/db/services/dialog_service.py @@ -35,7 +35,7 @@ from api.db.services.llm_service import LLMBundle from common.metadata_utils import apply_meta_data_filter from api.db.services.tenant_llm_service import TenantLLMService 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.app.tag import label_question from rag.nlp.search import index_name diff --git a/api/db/services/document_service.py b/api/db/services/document_service.py index 99e0f0f8f..4f015ddd5 100644 --- a/api/db/services/document_service.py +++ b/api/db/services/document_service.py @@ -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] 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) try: mind_map = asyncio.run(mindmap([c["content_with_weight"] for c in docs if c["doc_id"] == doc_id])) diff --git a/api/ragflow_server.py b/api/ragflow_server.py index 193efff3b..1beb0cd09 100644 --- a/api/ragflow_server.py +++ b/api/ragflow_server.py @@ -41,7 +41,7 @@ from common.versions import get_ragflow_version from common.config_utils import show_configs from common.mcp_tool_call_conn import shutdown_all_mcp_sessions from common.log_utils import init_root_logger -from plugin import GlobalPluginManager +from agent.plugin import GlobalPluginManager from rag.utils.redis_conn import RedisDistributedLock stop_event = threading.Event() diff --git a/common/settings.py b/common/settings.py index 83415c680..41ac2f5eb 100644 --- a/common/settings.py +++ b/common/settings.py @@ -317,7 +317,7 @@ def init_settings(): global retriever, kg_retriever 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) diff --git a/chat_demo/index.html b/example/chat_demo/index.html similarity index 100% rename from chat_demo/index.html rename to example/chat_demo/index.html diff --git a/chat_demo/widget_demo.html b/example/chat_demo/widget_demo.html similarity index 100% rename from chat_demo/widget_demo.html rename to example/chat_demo/widget_demo.html diff --git a/rag/app/tag.py b/rag/app/tag.py index 8e516a75f..d43692f61 100644 --- a/rag/app/tag.py +++ b/rag/app/tag.py @@ -124,7 +124,7 @@ def chunk(filename, binary=None, lang="Chinese", callback=None, **kwargs): def label_question(question, kbs): 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 tag_kb_ids = [] for kb in kbs: diff --git a/graphrag/__init__.py b/rag/graphrag/__init__.py similarity index 100% rename from graphrag/__init__.py rename to rag/graphrag/__init__.py diff --git a/graphrag/entity_resolution.py b/rag/graphrag/entity_resolution.py similarity index 98% rename from graphrag/entity_resolution.py rename to rag/graphrag/entity_resolution.py index ec65e84b7..5639e2a9c 100644 --- a/graphrag/entity_resolution.py +++ b/rag/graphrag/entity_resolution.py @@ -23,12 +23,12 @@ from typing import Any, Callable import networkx as nx -from graphrag.general.extractor import Extractor +from rag.graphrag.general.extractor import Extractor from rag.nlp import is_english 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 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 common.exceptions import TaskCanceledException diff --git a/graphrag/entity_resolution_prompt.py b/rag/graphrag/entity_resolution_prompt.py similarity index 100% rename from graphrag/entity_resolution_prompt.py rename to rag/graphrag/entity_resolution_prompt.py diff --git a/graphrag/general/__init__.py b/rag/graphrag/general/__init__.py similarity index 100% rename from graphrag/general/__init__.py rename to rag/graphrag/general/__init__.py diff --git a/graphrag/general/community_report_prompt.py b/rag/graphrag/general/community_report_prompt.py similarity index 100% rename from graphrag/general/community_report_prompt.py rename to rag/graphrag/general/community_report_prompt.py diff --git a/graphrag/general/community_reports_extractor.py b/rag/graphrag/general/community_reports_extractor.py similarity index 95% rename from graphrag/general/community_reports_extractor.py rename to rag/graphrag/general/community_reports_extractor.py index 9a01f98c6..4c616ac5a 100644 --- a/graphrag/general/community_reports_extractor.py +++ b/rag/graphrag/general/community_reports_extractor.py @@ -21,12 +21,12 @@ import pandas as pd from api.db.services.task_service import has_canceled from common.exceptions import TaskCanceledException from common.connection_utils import timeout -from graphrag.general import leiden -from graphrag.general.community_report_prompt import COMMUNITY_REPORT_PROMPT -from graphrag.general.extractor import Extractor -from graphrag.general.leiden import add_community_info2graph +from rag.graphrag.general import leiden +from rag.graphrag.general.community_report_prompt import COMMUNITY_REPORT_PROMPT +from rag.graphrag.general.extractor import Extractor +from rag.graphrag.general.leiden import add_community_info2graph 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 @dataclass diff --git a/graphrag/general/entity_embedding.py b/rag/graphrag/general/entity_embedding.py similarity index 94% rename from graphrag/general/entity_embedding.py rename to rag/graphrag/general/entity_embedding.py index 78c7fc31d..993f8474e 100644 --- a/graphrag/general/entity_embedding.py +++ b/rag/graphrag/general/entity_embedding.py @@ -9,7 +9,7 @@ from typing import Any import numpy as np import networkx as nx 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 @@ -63,4 +63,4 @@ def run(graph: nx.Graph, args: dict[str, Any]) -> dict: pairs = zip(embeddings.nodes, embeddings.embeddings.tolist(), strict=True) sorted_pairs = sorted(pairs, key=lambda x: x[0]) - return dict(sorted_pairs) \ No newline at end of file + return dict(sorted_pairs) diff --git a/graphrag/general/extractor.py b/rag/graphrag/general/extractor.py similarity index 99% rename from graphrag/general/extractor.py rename to rag/graphrag/general/extractor.py index 899845a83..ccb0d3ba8 100644 --- a/graphrag/general/extractor.py +++ b/rag/graphrag/general/extractor.py @@ -26,8 +26,8 @@ import networkx as nx from api.db.services.task_service import has_canceled from common.connection_utils import timeout from common.token_utils import truncate -from graphrag.general.graph_prompt import SUMMARIZE_DESCRIPTIONS_PROMPT -from graphrag.utils import ( +from rag.graphrag.general.graph_prompt import SUMMARIZE_DESCRIPTIONS_PROMPT +from rag.graphrag.utils import ( GraphChange, chat_limiter, flat_uniq_list, diff --git a/graphrag/general/graph_extractor.py b/rag/graphrag/general/graph_extractor.py similarity index 95% rename from graphrag/general/graph_extractor.py rename to rag/graphrag/general/graph_extractor.py index c769acd94..26caa93f2 100644 --- a/graphrag/general/graph_extractor.py +++ b/rag/graphrag/general/graph_extractor.py @@ -13,9 +13,9 @@ from typing import Any from dataclasses import dataclass import tiktoken -from graphrag.general.extractor import Extractor, ENTITY_EXTRACTION_MAX_GLEANINGS -from 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.general.extractor import Extractor, ENTITY_EXTRACTION_MAX_GLEANINGS +from rag.graphrag.general.graph_prompt import GRAPH_EXTRACTION_PROMPT, CONTINUE_PROMPT, LOOP_PROMPT +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 import networkx as nx from common.token_utils import num_tokens_from_string diff --git a/graphrag/general/graph_prompt.py b/rag/graphrag/general/graph_prompt.py similarity index 100% rename from graphrag/general/graph_prompt.py rename to rag/graphrag/general/graph_prompt.py diff --git a/graphrag/general/index.py b/rag/graphrag/general/index.py similarity index 98% rename from graphrag/general/index.py rename to rag/graphrag/general/index.py index 632d37494..1a43ebe09 100644 --- a/graphrag/general/index.py +++ b/rag/graphrag/general/index.py @@ -25,12 +25,12 @@ from api.db.services.task_service import has_canceled from common.exceptions import TaskCanceledException from common.misc_utils import get_uuid from common.connection_utils import timeout -from graphrag.entity_resolution import EntityResolution -from graphrag.general.community_reports_extractor import CommunityReportsExtractor -from graphrag.general.extractor import Extractor -from graphrag.general.graph_extractor import GraphExtractor as GeneralKGExt -from graphrag.light.graph_extractor import GraphExtractor as LightKGExt -from graphrag.utils import ( +from rag.graphrag.entity_resolution import EntityResolution +from rag.graphrag.general.community_reports_extractor import CommunityReportsExtractor +from rag.graphrag.general.extractor import Extractor +from rag.graphrag.general.graph_extractor import GraphExtractor as GeneralKGExt +from rag.graphrag.light.graph_extractor import GraphExtractor as LightKGExt +from rag.graphrag.utils import ( GraphChange, chunk_id, does_graph_contains, diff --git a/graphrag/general/leiden.py b/rag/graphrag/general/leiden.py similarity index 100% rename from graphrag/general/leiden.py rename to rag/graphrag/general/leiden.py diff --git a/graphrag/general/mind_map_extractor.py b/rag/graphrag/general/mind_map_extractor.py similarity index 96% rename from graphrag/general/mind_map_extractor.py rename to rag/graphrag/general/mind_map_extractor.py index f221e89f9..3e7c5d9ae 100644 --- a/graphrag/general/mind_map_extractor.py +++ b/rag/graphrag/general/mind_map_extractor.py @@ -21,9 +21,9 @@ import re from typing import Any from dataclasses import dataclass -from graphrag.general.extractor import Extractor -from graphrag.general.mind_map_prompt import MIND_MAP_EXTRACTION_PROMPT -from graphrag.utils import ErrorHandlerFn, perform_variable_replacements, chat_limiter +from rag.graphrag.general.extractor import Extractor +from rag.graphrag.general.mind_map_prompt import MIND_MAP_EXTRACTION_PROMPT +from rag.graphrag.utils import ErrorHandlerFn, perform_variable_replacements, chat_limiter from rag.llm.chat_model import Base as CompletionLLM import markdown_to_json from functools import reduce diff --git a/graphrag/general/mind_map_prompt.py b/rag/graphrag/general/mind_map_prompt.py similarity index 100% rename from graphrag/general/mind_map_prompt.py rename to rag/graphrag/general/mind_map_prompt.py diff --git a/graphrag/general/smoke.py b/rag/graphrag/general/smoke.py similarity index 95% rename from graphrag/general/smoke.py rename to rag/graphrag/general/smoke.py index ba405e193..007027037 100644 --- a/graphrag/general/smoke.py +++ b/rag/graphrag/general/smoke.py @@ -25,8 +25,8 @@ from api.db.services.document_service import DocumentService from api.db.services.knowledgebase_service import KnowledgebaseService from api.db.services.llm_service import LLMBundle from api.db.services.user_service import TenantService -from graphrag.general.graph_extractor import GraphExtractor -from graphrag.general.index import update_graph, with_resolution, with_community +from rag.graphrag.general.graph_extractor import GraphExtractor +from rag.graphrag.general.index import update_graph, with_resolution, with_community from common import settings settings.init_settings() diff --git a/graphrag/light/__init__.py b/rag/graphrag/light/__init__.py similarity index 100% rename from graphrag/light/__init__.py rename to rag/graphrag/light/__init__.py diff --git a/graphrag/light/graph_extractor.py b/rag/graphrag/light/graph_extractor.py similarity index 95% rename from graphrag/light/graph_extractor.py rename to rag/graphrag/light/graph_extractor.py index 027589ca9..b304e6ad8 100644 --- a/graphrag/light/graph_extractor.py +++ b/rag/graphrag/light/graph_extractor.py @@ -15,9 +15,9 @@ from typing import Any import networkx as nx -from graphrag.general.extractor import ENTITY_EXTRACTION_MAX_GLEANINGS, Extractor -from 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.general.extractor import ENTITY_EXTRACTION_MAX_GLEANINGS, Extractor +from rag.graphrag.light.graph_prompt import PROMPTS +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 common.token_utils import num_tokens_from_string diff --git a/graphrag/light/graph_prompt.py b/rag/graphrag/light/graph_prompt.py similarity index 100% rename from graphrag/light/graph_prompt.py rename to rag/graphrag/light/graph_prompt.py diff --git a/graphrag/light/smoke.py b/rag/graphrag/light/smoke.py similarity index 95% rename from graphrag/light/smoke.py rename to rag/graphrag/light/smoke.py index bfa3ca256..2688e0bb6 100644 --- a/graphrag/light/smoke.py +++ b/rag/graphrag/light/smoke.py @@ -25,8 +25,8 @@ from api.db.services.document_service import DocumentService from api.db.services.knowledgebase_service import KnowledgebaseService from api.db.services.llm_service import LLMBundle from api.db.services.user_service import TenantService -from graphrag.general.index import update_graph -from graphrag.light.graph_extractor import GraphExtractor +from rag.graphrag.general.index import update_graph +from rag.graphrag.light.graph_extractor import GraphExtractor from common import settings settings.init_settings() diff --git a/graphrag/query_analyze_prompt.py b/rag/graphrag/query_analyze_prompt.py similarity index 100% rename from graphrag/query_analyze_prompt.py rename to rag/graphrag/query_analyze_prompt.py diff --git a/graphrag/search.py b/rag/graphrag/search.py similarity index 98% rename from graphrag/search.py rename to rag/graphrag/search.py index 64abfd68a..6b6ebb82a 100644 --- a/graphrag/search.py +++ b/rag/graphrag/search.py @@ -22,8 +22,8 @@ import json_repair import pandas as pd from common.misc_utils import get_uuid -from graphrag.query_analyze_prompt import PROMPTS -from graphrag.utils import get_entity_type2samples, get_llm_cache, set_llm_cache, get_relation +from rag.graphrag.query_analyze_prompt import PROMPTS +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 rag.nlp.search import Dealer, index_name diff --git a/graphrag/utils.py b/rag/graphrag/utils.py similarity index 100% rename from graphrag/utils.py rename to rag/graphrag/utils.py diff --git a/rag/prompts/generator.py b/rag/prompts/generator.py index 5f834d85a..d3d7b65a6 100644 --- a/rag/prompts/generator.py +++ b/rag/prompts/generator.py @@ -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): - 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) if 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: logging.exception(e) - return {} \ No newline at end of file + return {} diff --git a/rag/raptor.py b/rag/raptor.py index ce9e5345e..ac2325d64 100644 --- a/rag/raptor.py +++ b/rag/raptor.py @@ -25,7 +25,7 @@ from api.db.services.task_service import has_canceled from common.connection_utils import timeout from common.exceptions import TaskCanceledException from common.token_utils import truncate -from graphrag.utils import ( +from rag.graphrag.utils import ( chat_limiter, get_embed_cache, get_llm_cache, diff --git a/rag/svr/task_executor.py b/rag/svr/task_executor.py index c414f21ee..c5f31cf21 100644 --- a/rag/svr/task_executor.py +++ b/rag/svr/task_executor.py @@ -40,8 +40,8 @@ from rag.utils.base64_image import image2id from rag.utils.raptor_utils import should_skip_raptor, get_skip_reason from common.log_utils import init_root_logger from common.config_utils import show_configs -from 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.general.index import run_graphrag_for_kb +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, \ gen_metadata import logging @@ -73,7 +73,7 @@ from rag.nlp import search, rag_tokenizer, add_positions from rag.raptor import RecursiveAbstractiveProcessing4TreeOrganizedRetrieval as Raptor from common.token_utils import num_tokens_from_string, truncate 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.exceptions import TaskCanceledException from common import settings