Skip to content

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

Remove unused code (#3448)

Jin Hai70cd5c1599ad
diff --git a/api/apps/__init__.py b/api/apps/__init__.py
index 5bc8d327f8..e2916f1c87 100644
--- a/api/apps/__init__.py
+++ b/api/apps/__init__.py
@@ -22,6 +22,7 @@ from flask import Blueprint, Flask
from werkzeug.wrappers.request import Request
from flask_cors import CORS
from flasgger import Swagger
+from itsdangerous.url_safe import URLSafeTimedSerializer as Serializer
from api.db import StatusEnum
from api.db.db_models import close_connection
@@ -32,7 +33,7 @@ from flask_session import Session
from flask_login import LoginManager
from api import settings
from api.utils.api_utils import server_error_response
-from itsdangerous.url_safe import URLSafeTimedSerializer as Serializer
+from api.constants import API_VERSION
__all__ = ["app"]
@@ -119,7 +120,7 @@ def register_page(page_path):
spec.loader.exec_module(page)
page_name = getattr(page, "page_name", page_name)
url_prefix = (
- f"/api/{settings.API_VERSION}" if "/sdk/" in path else f"/{settings.API_VERSION}/{page_name}"
+ f"/api/{API_VERSION}" if "/sdk/" in path else f"/{API_VERSION}/{page_name}"
)
app.register_blueprint(page.manager, url_prefix=url_prefix)
diff --git a/api/constants.py b/api/constants.py
index f571d21578..8d72c7e85a 100644
--- a/api/constants.py
+++ b/api/constants.py
@@ -17,4 +17,9 @@ NAME_LENGTH_LIMIT = 2 ** 10
IMG_BASE64_PREFIX = 'data:image/png;base64,'
-SERVICE_CONF = "service_conf.yaml"
\ No newline at end of file
+SERVICE_CONF = "service_conf.yaml"
+
+API_VERSION = "v1"
+RAG_FLOW_SERVICE_NAME = "ragflow"
+REQUEST_WAIT_SEC = 2
+REQUEST_MAX_WAIT_SEC = 300
diff --git a/api/settings.py b/api/settings.py
index 0abf548e8c..b6afba0e84 100644
--- a/api/settings.py
+++ b/api/settings.py
@@ -23,13 +23,10 @@ import rag.utils
from rag.nlp import search
from graphrag import search as kg_search
from api.utils import get_base_config, decrypt_database_config
+from api.constants import RAG_FLOW_SERVICE_NAME
-API_VERSION = "v1"
-RAG_FLOW_SERVICE_NAME = "ragflow"
LIGHTEN = int(os.environ.get('LIGHTEN', "0"))
-REQUEST_WAIT_SEC = 2
-REQUEST_MAX_WAIT_SEC = 300
LLM = None
LLM_FACTORY = None
LLM_BASE_URL = None
@@ -173,15 +170,6 @@ def init_settings():
retrievaler = search.Dealer(docStoreConn)
kg_retrievaler = kg_search.KGSearch(docStoreConn)
-def get_host_ip():
- global HOST_IP
- return HOST_IP
-
-
-def get_host_port():
- global HOST_PORT
- return HOST_PORT
-
class CustomEnum(Enum):
@classmethod
@@ -201,16 +189,6 @@ class CustomEnum(Enum):
return [member.name for member in cls.__members__.values()]
-class PythonDependenceName(CustomEnum):
- Rag_Source_Code = "python"
- Python_Env = "miniconda"
-
-
-class ModelStorage(CustomEnum):
- REDIS = "redis"
- MYSQL = "mysql"
-
-
class RetCode(IntEnum, CustomEnum):
SUCCESS = 0
NOT_EFFECTIVE = 10
diff --git a/api/utils/api_utils.py b/api/utils/api_utils.py
index 7d1fc7725c..895df97dda 100644
--- a/api/utils/api_utils.py
+++ b/api/utils/api_utils.py
@@ -39,6 +39,7 @@ from api import settings
from api import settings
from api.utils import CustomJSONEncoder, get_uuid
from api.utils import json_dumps
+from api.constants import REQUEST_WAIT_SEC, REQUEST_MAX_WAIT_SEC
requests.models.complexjson.dumps = functools.partial(
json.dumps, cls=CustomJSONEncoder)
@@ -87,7 +88,7 @@ def request(**kwargs):
def get_exponential_backoff_interval(retries, full_jitter=False):
"""Calculate the exponential backoff wait time."""
# Will be zero if factor equals 0
- countdown = min(settings.REQUEST_MAX_WAIT_SEC, settings.REQUEST_WAIT_SEC * (2 ** retries))
+ countdown = min(REQUEST_MAX_WAIT_SEC, REQUEST_WAIT_SEC * (2 ** retries))
# Full jitter according to
# https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
if full_jitter: