mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 23:41:12 +08:00
Refact: system apis (#14298)
### What problem does this PR solve? Refact: system apis ### Type of change - [x] Refactoring
This commit is contained in:
@@ -90,7 +90,7 @@ def system_delete_token(auth, token, *, headers=HEADERS):
|
||||
|
||||
|
||||
def system_status(auth, params=None, *, headers=HEADERS):
|
||||
res = requests.get(url=f"{HOST_ADDRESS}{SYSTEM_APP_URL}/status", headers=headers, auth=auth, params=params)
|
||||
res = requests.get(url=f"{HOST_ADDRESS}{SYSTEM_API_URL}/status", headers=headers, auth=auth, params=params)
|
||||
return res.json()
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ def system_version(auth, params=None, *, headers=HEADERS):
|
||||
|
||||
|
||||
def system_config(auth=None, params=None, *, headers=HEADERS):
|
||||
res = requests.get(url=f"{HOST_ADDRESS}{SYSTEM_APP_URL}/config", headers=headers, auth=auth, params=params)
|
||||
res = requests.get(url=f"{HOST_ADDRESS}{SYSTEM_API_URL}/config", headers=headers, auth=auth, params=params)
|
||||
return res.json()
|
||||
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ def _load_system_module(monkeypatch):
|
||||
quart_mod.jsonify = lambda payload: payload
|
||||
monkeypatch.setitem(sys.modules, "quart", quart_mod)
|
||||
|
||||
module_path = repo_root / "api" / "apps" / "system_app.py"
|
||||
module_path = repo_root / "api" / "apps" / "restful_apis" / "system_api.py"
|
||||
spec = importlib.util.spec_from_file_location("test_system_routes_unit_module", module_path)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
module.manager = _DummyManager()
|
||||
|
||||
@@ -20,7 +20,7 @@ _DOC_ENGINE_CACHE = None
|
||||
|
||||
|
||||
def get_doc_engine(rag=None) -> str:
|
||||
"""Return lower-cased doc_engine from env, or from /system/status if env is unset."""
|
||||
"""Return lower-cased doc_engine from env, or from /api/v1/system/status if env is unset."""
|
||||
global _DOC_ENGINE_CACHE
|
||||
env = (os.getenv("DOC_ENGINE") or "").strip().lower()
|
||||
if env:
|
||||
@@ -34,9 +34,9 @@ def get_doc_engine(rag=None) -> str:
|
||||
api_url = getattr(rag, "api_url", "")
|
||||
if "/api/" in api_url:
|
||||
base_url, version = api_url.rsplit("/api/", 1)
|
||||
status_url = f"{base_url}/{version}/system/status"
|
||||
status_url = f"{base_url}/api/{version}/system/status"
|
||||
else:
|
||||
status_url = f"{api_url}/system/status"
|
||||
status_url = f"{api_url}/api/v1/system/status"
|
||||
headers = getattr(rag, "authorization_header", {})
|
||||
res = requests.get(status_url, headers=headers).json()
|
||||
engine = str(res.get("data", {}).get("doc_engine", {}).get("type", "")).lower()
|
||||
|
||||
Reference in New Issue
Block a user