mirror of
https://gitcode.com/JianFeeeee/TrulyMEM-TrueHumanMEM.git
synced 2026-09-20 08:58:15 +00:00
- 合并 server.py 到 core/__init__.py,使用统一 Packet 协议 - 后端管理配置持久化 (~/.trulymem/config.json) - 前端移除 ConfigService,通过 BackendClient 与后端通信 - 删除 UI 中冗余的 AI 推理逻辑 (chat_service, tool_service, message_handler) - 删除 core/tools 重复文件 (tool_executor, tool_limiter) - 提示词管理器支持用户自定义 (~/.trulyemem/system_prompt.md) - 启动入口优化配置路径逻辑 - 更新测试覆盖 (42 tests) - 更新文档
51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
import sys
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# 用户配置文件始终放在用户目录
|
|
CONFIG_PATH = Path.home() / ".trulymem" / "config.json"
|
|
DB_PATH = Path.home() / ".trulymem" / "graph_memory.db"
|
|
|
|
# 源码运行时使用项目目录,打包后使用用户目录
|
|
if getattr(sys, 'frozen', False):
|
|
# 打包版本:创建用户目录
|
|
CONFIG_PATH.parent.mkdir(parents=True, exist_ok=True)
|
|
else:
|
|
# 源码版本:检查项目目录是否有配置(向后兼容)
|
|
project_dir = Path(__file__).parent
|
|
project_config = project_dir / "config.json"
|
|
project_db = project_dir / "graph_memory.db"
|
|
|
|
if project_config.exists():
|
|
CONFIG_PATH = project_config
|
|
if project_db.exists():
|
|
DB_PATH = project_db
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent))
|
|
os.chdir(Path(__file__).parent)
|
|
|
|
from core import BackendServer
|
|
from ui import GraphMemoryApp
|
|
|
|
|
|
def main():
|
|
backend_server = BackendServer(
|
|
db_path=str(DB_PATH),
|
|
use_embedded_db=True,
|
|
config_file=str(CONFIG_PATH)
|
|
)
|
|
backend_server.start()
|
|
|
|
app = GraphMemoryApp(backend_server=backend_server, config_file=str(CONFIG_PATH))
|
|
|
|
try:
|
|
app.run()
|
|
except KeyboardInterrupt:
|
|
print("\n退出")
|
|
finally:
|
|
backend_server.shutdown()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |