Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

API refactor: stats_api and plugin_api (#14324)

Wang Qi4458763a93df
diff --git a/api/apps/plugin_app.py b/api/apps/restful_apis/plugin_api.py
similarity index 93%
rename from api/apps/plugin_app.py
rename to api/apps/restful_apis/plugin_api.py
index fb0a7bb610..6d53fbc626 100644
--- a/api/apps/plugin_app.py
+++ b/api/apps/restful_apis/plugin_api.py
@@ -21,7 +21,7 @@ from api.utils.api_utils import get_json_result
from agent.plugin import GlobalPluginManager
[email protected]('/llm_tools', methods=['GET']) # noqa: F821
[email protected]('/plugin/tools', methods=['GET']) # noqa: F821
@login_required
def llm_tools() -> Response:
tools = GlobalPluginManager.get_llm_tools()
diff --git a/api/apps/api_app.py b/api/apps/restful_apis/stats_api.py
similarity index 97%
rename from api/apps/api_app.py
rename to api/apps/restful_apis/stats_api.py
index 0d5d62334e..7185194327 100644
--- a/api/apps/api_app.py
+++ b/api/apps/restful_apis/stats_api.py
@@ -20,7 +20,7 @@ from api.db.services.user_service import UserTenantService
from api.utils.api_utils import get_data_error_result, get_json_result, server_error_response
from api.apps import login_required, current_user
[email protected]('/stats', methods=['GET']) # noqa: F821
[email protected]('/system/stats', methods=['GET']) # noqa: F821
@login_required
def stats():
try:
diff --git a/test/testcases/test_web_api/test_common.py b/test/testcases/test_web_api/test_common.py
index d81d3736e2..aa525c6edb 100644
--- a/test/testcases/test_web_api/test_common.py
+++ b/test/testcases/test_web_api/test_common.py
@@ -38,7 +38,7 @@ API_APP_URL = f"/{VERSION}/api"
SYSTEM_APP_URL = f"/{VERSION}/system"
SYSTEM_API_URL = f"/api/{VERSION}/system"
LLM_APP_URL = f"/{VERSION}/llm"
-PLUGIN_APP_URL = f"/{VERSION}/plugin"
+PLUGIN_APP_URL = f"/api/{VERSION}/plugin"
SEARCHES_URL = f"/api/{VERSION}/searches"
CHATS_URL = f"/api/{VERSION}/chats"
@@ -118,7 +118,7 @@ def llm_list(auth, params=None, *, headers=HEADERS):
# PLUGIN APP
def plugin_llm_tools(auth, params=None, *, headers=HEADERS):
- res = requests.get(url=f"{HOST_ADDRESS}{PLUGIN_APP_URL}/llm_tools", headers=headers, auth=auth, params=params)
+ res = requests.get(url=f"{HOST_ADDRESS}{PLUGIN_APP_URL}/tools", headers=headers, auth=auth, params=params)
return res.json()
diff --git a/test/testcases/test_web_api/test_plugin_app/test_llm_tools.py b/test/testcases/test_web_api/test_plugin_app/test_llm_tools.py
index 2dfe08defe..75a18b20bd 100644
--- a/test/testcases/test_web_api/test_plugin_app/test_llm_tools.py
+++ b/test/testcases/test_web_api/test_plugin_app/test_llm_tools.py
@@ -74,7 +74,7 @@ def _load_plugin_app(monkeypatch):
stub_plugin.GlobalPluginManager = _StubGlobalPluginManager
monkeypatch.setitem(sys.modules, "agent.plugin", stub_plugin)
- module_path = Path(__file__).resolve().parents[4] / "api" / "apps" / "plugin_app.py"
+ module_path = Path(__file__).resolve().parents[4] / "api" / "apps" / "restful_apis" / "plugin_api.py"
spec = importlib.util.spec_from_file_location("test_plugin_app_unit", module_path)
module = importlib.util.module_from_spec(spec)
module.manager = _DummyManager()
diff --git a/web/src/utils/api.ts b/web/src/utils/api.ts
index 462384f2f2..37000decda 100644
--- a/web/src/utils/api.ts
+++ b/web/src/utils/api.ts
@@ -51,7 +51,7 @@ export default {
boxWebAuthResult: () => `${restAPIv1}/connectors/box/oauth/web/result`,
// plugin
- llmTools: `${webAPI}/plugin/llm_tools`,
+ llmTools: `${restAPIv1}/plugin/tools`,
chatsTranscriptions: `${restAPIv1}/chat/audio/transcription`,