Files
TrulyMEM-TrueHumanMEM/trulymem_entry.py
JianFeeeee 759168cab5 fix: 配置持久化 - 启动时加载并保存到本地文件
- 修复配置无法持久化的问题,之前配置只保存在内存中

- 启动时从应用根目录加载 config.json

- 配置变更时自动保存到本地文件

- 配置文件位置:源码运行时在项目根目录,打包后exe同级目录

- 修复 model 字段在保存时丢失的问题
2026-04-13 08:13:22 +08:00

41 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
import sys
from pathlib import Path
if getattr(sys, 'frozen', False):
application_path = Path(sys.executable).parent
else:
application_path = Path(__file__).parent
sys.path.insert(0, str(application_path))
import os
os.chdir(application_path)
from core import BackendServer
from ui import GraphMemoryApp
from ui.services.config_service import ConfigService
def main():
# 配置文件保存在应用根目录exe同级目录或源码根目录
config_file = application_path / "config.json"
# 加载配置
config_service = ConfigService(config_file=config_file)
config = config_service.get_config()
backend_server = BackendServer(db_path="graph_memory.db", use_embedded_db=True)
backend_server.start(api_key=config.api_key, base_url=config.base_url)
app = GraphMemoryApp(backend_server=backend_server, config_service=config_service)
try:
app.run()
except KeyboardInterrupt:
print("\n退出")
finally:
backend_server.shutdown()
if __name__ == "__main__":
main()