refactor: restructure to core/ + ui/ with multi-threaded backend

This commit is contained in:
root
2026-04-12 18:15:55 +08:00
parent c13d3f671c
commit 83906a6985
64 changed files with 5269 additions and 571 deletions

View File

@ -1,47 +1,45 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2026 jianf
"""
TrulyMEM 独立入口文件
用于打包为可执行文件
"""
import sys
import os
from pathlib import Path
# 确保工作目录正确
if getattr(sys, 'frozen', False):
# 打包后的可执行文件
application_path = Path(sys.executable).parent
else:
# 开发环境
application_path = Path(__file__).parent
# 切换到应用目录
os.chdir(application_path)
# 添加项目路径
if str(application_path) not in sys.path:
sys.path.insert(0, str(application_path))
# 导入并运行应用
from graph_memory_tui.app import GraphMemoryApp
from core import BackendServer
from ui import GraphMemoryApp, AppConfig
def main():
"""主函数"""
backend_server = BackendServer(db_path="graph_memory.db", use_embedded_db=True)
try:
config = AppConfig.from_env()
backend_server.start(api_key=config.api_key, base_url=config.base_url)
except Exception as e:
print(f"后端启动失败: {e}")
app = GraphMemoryApp(backend_server=backend_server)
try:
app = GraphMemoryApp()
app.run()
except KeyboardInterrupt:
print("\n应用已退出")
sys.exit(0)
except Exception as e:
print(f"应用启动失败: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
finally:
backend_server.shutdown()
sys.exit(0)
if __name__ == "__main__":
main()
main()