diff --git a/api/__init__.py b/api/__init__.py index 643f797..4cb49d4 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -14,5 +14,15 @@ # limitations under the License. # +from pathlib import Path + from beartype.claw import beartype_this_package +from dotenv import load_dotenv + +from api.root_path import get_root_folder + beartype_this_package() + +# 初始化加载环境变量 +env_path = Path(get_root_folder()) / "docker" / ".env" +load_dotenv(env_path) diff --git a/api/db/services/dialog_service.py b/api/db/services/dialog_service.py index 12d41c4..7c23bc8 100644 --- a/api/db/services/dialog_service.py +++ b/api/db/services/dialog_service.py @@ -13,23 +13,25 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import logging import binascii -import time +import logging import re +import time from copy import deepcopy from timeit import default_timer as timer + +from api import settings from api.db import LLMType, ParserType, StatusEnum -from api.db.db_models import Dialog, DB +from api.db.db_models import DB, Dialog from api.db.services.common_service import CommonService from api.db.services.knowledgebase_service import KnowledgebaseService -from api.db.services.llm_service import TenantLLMService, LLMBundle -from api import settings +from api.db.services.llm_service import LLMBundle, TenantLLMService from rag.app.resume import forbidden_select_fields4resume from rag.app.tag import label_question from rag.nlp.search import index_name -from rag.prompts import kb_prompt, message_fit_in, llm_id2llm_type, keyword_extraction, chunks_format, citation_prompt -from rag.utils import rmSpace, num_tokens_from_string +from rag.prompts import chunks_format, citation_prompt, kb_prompt, keyword_extraction, llm_id2llm_type, message_fit_in +from rag.utils import num_tokens_from_string, rmSpace + from .database import MINIO_CONFIG diff --git a/api/ragflow_server.py b/api/ragflow_server.py index e8598a7..6cb2d7e 100644 --- a/api/ragflow_server.py +++ b/api/ragflow_server.py @@ -6,9 +6,7 @@ import threading import time import traceback from concurrent.futures import ThreadPoolExecutor -from pathlib import Path -from dotenv import load_dotenv from werkzeug.serving import run_simple from api import settings, utils @@ -17,17 +15,12 @@ from api.db.db_models import init_database_tables as init_web_db from api.db.init_data import init_llm_factory from api.db.runtime_config import RuntimeConfig from api.db.services.document_service import DocumentService -from api.root_path import get_root_folder from api.utils import show_configs from api.utils.log_utils import initRootLogger from api.versions import get_ragflow_version from rag.settings import print_rag_settings from rag.utils.redis_conn import RedisDistributedLock -# 加载环境变量 -env_path = Path(get_root_folder()) / "docker" / ".env" -load_dotenv(env_path) - initRootLogger("ragflow_server") stop_event = threading.Event()