Enhance environment configuration and error handling in API server and backend. Implement dynamic loading of .env files for various execution contexts, improve schema file path resolution, and refine vector search error handling in the orchestrator. Update ChromaDB integration to support memory mode and add persistence options for few-shot learning. Include additional logging for better traceability.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
|
||||
from PyInstaller.utils.hooks import collect_data_files, collect_submodules, collect_dynamic_libs
|
||||
|
||||
# 获取项目根目录(spec 文件所在目录)
|
||||
import sys
|
||||
@@ -18,6 +18,24 @@ datas = [
|
||||
# ('data/experiences', 'data/experiences'),
|
||||
]
|
||||
|
||||
# ChromaDB 在 Windows 单文件 exe 下如缺少 native 动态库,可能在持久化访问时直接“硬退出”
|
||||
# 这里显式收集 chromadb 与 hnswlib(向量索引)的动态库/二进制依赖
|
||||
binaries = []
|
||||
try:
|
||||
binaries += collect_dynamic_libs("chromadb")
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
binaries += collect_dynamic_libs("hnswlib")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 某些 chromadb 版本会依赖包内数据文件(如 migrations/默认配置等),一并收集更稳妥
|
||||
try:
|
||||
datas += collect_data_files("chromadb")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 收集所有需要的隐藏导入
|
||||
hiddenimports = [
|
||||
# Web 框架
|
||||
@@ -57,6 +75,7 @@ hiddenimports = [
|
||||
'backend.schema.models',
|
||||
'backend.utils',
|
||||
'backend.utils.dialog_classifier',
|
||||
'backend.utils.dialog_context',
|
||||
'backend.utils.embedding',
|
||||
'backend.utils.fewshot_selector',
|
||||
'backend.utils.question_locale',
|
||||
@@ -118,7 +137,7 @@ excludes = [
|
||||
a = Analysis(
|
||||
['api_server.py'],
|
||||
pathex=[str(_REPO_DIR)],
|
||||
binaries=[],
|
||||
binaries=binaries,
|
||||
datas=datas,
|
||||
hiddenimports=hiddenimports,
|
||||
hookspath=[],
|
||||
|
||||
Reference in New Issue
Block a user