From 46c58bccc58618e0090df8c176738627a78db2eb Mon Sep 17 00:00:00 2001 From: JianFeeeee <109188060+JianFeeeee@users.noreply.github.com> Date: Fri, 10 Apr 2026 15:50:42 +0800 Subject: [PATCH] fix: Use embedded SQLite database instead of Neo4j - Remove Neo4j connection retry logic - Use EmbeddedGraphDB with SQLite backend - Update welcome message to show SQLite database - No more Neo4j connection errors --- graph_memory_tui/app.py | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/graph_memory_tui/app.py b/graph_memory_tui/app.py index 005383a..31eba19 100644 --- a/graph_memory_tui/app.py +++ b/graph_memory_tui/app.py @@ -65,33 +65,9 @@ class GraphMemoryApp(App[None]): history = self.query_one(MessageHistory) try: - # 初始化图数据库连接(添加重试) - max_retries = 3 - retry_delay = 2 + # 初始化内嵌图数据库 + self._graph = Neo4jGraph(db_path="graph_memory.db") - for attempt in range(max_retries): - try: - self._graph = Neo4jGraph( - uri=NEO4J_URI, - user=NEO4J_USER, - password=NEO4J_PASSWORD - ) - # 测试连接 - self._graph.ensure_constraints() - break - except Exception as e: - if attempt < max_retries - 1: - msg = Message( - role="assistant", - content=f"⚠️ Neo4j连接失败,正在重试... ({attempt + 1}/{max_retries})", - timestamp=datetime.now() - ) - history.add_message(msg) - import asyncio - asyncio.sleep(retry_delay) - else: - raise e - # 初始化 API 客户端 self._init_client() @@ -99,7 +75,7 @@ class GraphMemoryApp(App[None]): welcome = Message( role="assistant", content="✅ 系统初始化成功!\n\n" - f"• Neo4j 已连接: {NEO4J_URI}\n" + f"• 数据库: 内嵌SQLite (graph_memory.db)\n" f"• API Key: {'已配置' if self._config.api_key else '未配置'}\n\n" "现在可以开始对话了!", timestamp=datetime.now()