fix: 修复UI层导入问题和历史加载逻辑

This commit is contained in:
root
2026-04-15 11:15:51 +08:00
parent a282ec1a58
commit a8dc24e7f3
2 changed files with 50 additions and 6 deletions

45
TrulyMEM.spec Normal file
View File

@ -0,0 +1,45 @@
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_all
datas = [('ui/styles', 'ui/styles'), ('core/prompts/templates', 'core/prompts/templates')]
binaries = []
hiddenimports = ['textual', 'textual.app', 'textual.widgets', 'textual.css', 'openai', 'openai._client', 'neo4j', 'sqlite3', 'core', 'core.embedded_db', 'core.graph_client', 'core.tool_executor', 'core.tool_limiter', 'core.tools', 'core.tools.memory_tools', 'core.prompts', 'core.prompts.prompt_manager', 'ui', 'ui.app', 'ui.models', 'ui.models.message', 'ui.models.config', 'ui.models.log_entry', 'ui.widgets', 'ui.handlers', 'ui.services', 'ui.services.config_manager', 'ui.services.config_service']
tmp_ret = collect_all('textual')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
a = Analysis(
['trulymem_entry.py'],
pathex=[],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='TrulyMEM',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)

View File

@ -59,6 +59,7 @@ class GraphMemoryApp(App):
def on_mount(self) -> None:
from .widgets.status_bar import StatusBar
from .widgets.message_history import MessageHistory
status_bar = self.query_one(StatusBar)
if not self._backend_server:
@ -74,17 +75,15 @@ class GraphMemoryApp(App):
self._api_configured = data.get("config", {}).get("api_key", "") != ""
status_bar.set_api_status(self._api_configured)
history = self.query_one(MessageHistory)
if self._api_configured:
result = self._backend_client.get_history()
if result.get("success"):
history_data = result.get("data", {})
chat_history = history_data.get("history", [])
history = self.query_one(MessageHistory)
chat_history = self._backend_client.get_history()
if chat_history:
for msg in chat_history:
message = Message(role=msg["role"], content=msg["content"])
history.add_message(message)
history = self.query_one(MessageHistory)
welcome = Message(
role="assistant",
content=f"系统就绪\nAPI Key: {'已配置' if self._api_configured else '未配置'}\n\n输入消息开始对话"