mirror of
https://gitcode.com/JianFeeeee/TrulyMEM-TrueHumanMEM.git
synced 2026-10-15 12:15:32 +00:00
refactor: packet-based IPC with core/ui separation
- All logic in core layer (BackendServer runs independently)
- Packet protocol: {id, type, body} for all communications
- UI simplified: just input→backend→display
- Config, history, tools all handled by core
- BackendServer can run standalone without UI
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
if getattr(sys, 'frozen', False):
|
||||
@ -8,37 +7,26 @@ if getattr(sys, 'frozen', False):
|
||||
else:
|
||||
application_path = Path(__file__).parent
|
||||
|
||||
sys.path.insert(0, str(application_path))
|
||||
import os
|
||||
os.chdir(application_path)
|
||||
|
||||
if str(application_path) not in sys.path:
|
||||
sys.path.insert(0, str(application_path))
|
||||
|
||||
from core import BackendServer
|
||||
from ui import GraphMemoryApp, AppConfig
|
||||
from ui import GraphMemoryApp
|
||||
|
||||
|
||||
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}")
|
||||
backend_server.start(api_key="", base_url="https://api.deepseek.com")
|
||||
|
||||
app = GraphMemoryApp(backend_server=backend_server)
|
||||
|
||||
try:
|
||||
app.run()
|
||||
except KeyboardInterrupt:
|
||||
print("\n应用已退出")
|
||||
except Exception as e:
|
||||
print(f"应用启动失败: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
print("\n退出")
|
||||
finally:
|
||||
backend_server.shutdown()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user