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
This commit is contained in:
JianFeeeee
2026-04-10 15:50:42 +08:00
parent e2ab83874e
commit 46c58bccc5

View File

@ -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()