fix: Resolve database connection and episode processing errors
Fixed two critical runtime errors: 1. Database connection check for KuzuDB - KuzuDB session.run() returns None, causing async iteration error - Added special handling for KuzuDB (in-memory, no query needed) - Other databases (Neo4j, FalkorDB) still perform connection test 2. Episode processing parameter error - Changed 'episode_type' parameter to 'source' to match Graphiti API - Added required 'reference_time' parameter with current timestamp - Added datetime imports (UTC, datetime) Errors fixed: - 'async for' requires an object with __aiter__ method, got NoneType - Graphiti.add_episode() got an unexpected keyword argument 'episode_type'
This commit is contained in:
parent
aa16d4a9ac
commit
12eb564eda
2 changed files with 13 additions and 5 deletions
|
|
@ -657,12 +657,19 @@ async def get_status() -> StatusResponse:
|
|||
try:
|
||||
client = await graphiti_service.get_client()
|
||||
|
||||
# Test database connection with a simple query
|
||||
# This works for all supported databases (Neo4j, FalkorDB, KuzuDB)
|
||||
# For KuzuDB, just check if the client exists (it's in-memory)
|
||||
if config.database.provider.lower() == 'kuzu':
|
||||
provider_info = f'{config.database.provider} database (in-memory)'
|
||||
return StatusResponse(
|
||||
status='ok', message=f'Graphiti MCP server is running and connected to {provider_info}'
|
||||
)
|
||||
|
||||
# For Neo4j and FalkorDB, test connection with a simple query
|
||||
async with client.driver.session() as session:
|
||||
result = await session.run('MATCH (n) RETURN count(n) as count')
|
||||
# Consume the result to verify query execution
|
||||
_ = [record async for record in result]
|
||||
if result:
|
||||
_ = [record async for record in result]
|
||||
|
||||
provider_info = f'{config.database.provider} database'
|
||||
return StatusResponse(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import asyncio
|
||||
import logging
|
||||
from collections.abc import Awaitable, Callable
|
||||
from datetime import UTC, datetime
|
||||
from typing import Any
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -134,9 +135,9 @@ class QueueService:
|
|||
name=name,
|
||||
episode_body=content,
|
||||
source_description=source_description,
|
||||
episode_type=episode_type,
|
||||
source=episode_type,
|
||||
group_id=group_id,
|
||||
reference_time=None, # Let graphiti handle timing
|
||||
reference_time=datetime.now(UTC),
|
||||
entity_types=entity_types,
|
||||
uuid=uuid,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue