added fix to the falkor adapter
This commit is contained in:
parent
16c39ee74c
commit
7055bd8a8f
1 changed files with 32 additions and 44 deletions
|
|
@ -91,56 +91,44 @@ async def main():
|
||||||
from cognee.infrastructure.databases.vector import get_vector_engine
|
from cognee.infrastructure.databases.vector import get_vector_engine
|
||||||
|
|
||||||
vector_engine = get_vector_engine()
|
vector_engine = get_vector_engine()
|
||||||
|
|
||||||
# Debug: Let's see what's actually in the database
|
# Try different search terms that are likely to be found as entities in the processed text
|
||||||
print("🔍 Debugging FalkorDB contents...")
|
search_terms = ["GPT", "OpenAI", "language model", "LLM", "AI", "neural network"]
|
||||||
try:
|
|
||||||
# Check what nodes exist in the database
|
|
||||||
debug_query = "MATCH (n) RETURN labels(n) AS labels, properties(n) AS properties LIMIT 10"
|
|
||||||
debug_result = vector_engine.query(debug_query)
|
|
||||||
print(f"Database contains {len(debug_result.result_set)} nodes (showing first 10):")
|
|
||||||
for i, record in enumerate(debug_result.result_set):
|
|
||||||
print(f" Node {i}: Labels={record[0]}, Properties={record[1]}")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error querying database: {e}")
|
|
||||||
|
|
||||||
# Try different search approaches
|
|
||||||
search_terms = ["AI", "LLM", "GPT", "OpenAI", "language", "model"]
|
|
||||||
search_fields = ["Entity_name", "name", "text", "Entity.name"]
|
|
||||||
|
|
||||||
search_results = []
|
search_results = []
|
||||||
for field in search_fields:
|
|
||||||
for term in search_terms:
|
for term in search_terms:
|
||||||
try:
|
search_results = await vector_engine.search("Entity_name", term)
|
||||||
results = await vector_engine.search(field, term)
|
|
||||||
if results:
|
|
||||||
print(f"✅ Found {len(results)} results for field '{field}' with term '{term}'")
|
|
||||||
search_results = results
|
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
print(f"❌ Error searching field '{field}' with term '{term}': {e}")
|
|
||||||
if search_results:
|
if search_results:
|
||||||
|
print(f"✅ Found {len(search_results)} results for '{term}'")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# If no entities found with common search terms, fallback to any Entity
|
||||||
if not search_results:
|
if not search_results:
|
||||||
# If still no results, try to get any Entity node
|
|
||||||
try:
|
try:
|
||||||
entity_query = "MATCH (n:Entity) RETURN n LIMIT 1"
|
# Try a broader search for any entity
|
||||||
entity_result = vector_engine.query(entity_query)
|
search_results = await vector_engine.search("Entity_name", "")
|
||||||
if entity_result.result_set:
|
if not search_results:
|
||||||
print("✅ Found Entity node directly via query")
|
# Direct query as last resort
|
||||||
# Create a mock search result format
|
entity_query = "MATCH (n:Entity) RETURN n, 1.0 as score LIMIT 1"
|
||||||
entity_node = entity_result.result_set[0][0]
|
entity_result = vector_engine.query(entity_query)
|
||||||
search_results = [
|
if entity_result.result_set:
|
||||||
type(
|
# Convert to ScoredResult format
|
||||||
"MockResult",
|
from cognee.infrastructure.databases.vector.models.ScoredResult import ScoredResult
|
||||||
(),
|
from cognee.shared.utils import parse_id
|
||||||
{"payload": {"text": entity_node.properties.get("name", "Entity")}},
|
|
||||||
)()
|
node = entity_result.result_set[0][0]
|
||||||
]
|
payload = dict(node.properties) if hasattr(node, 'properties') else {}
|
||||||
|
if 'text' not in payload and 'name' in payload:
|
||||||
|
payload['text'] = payload['name']
|
||||||
|
|
||||||
|
search_results = [ScoredResult(
|
||||||
|
id=parse_id(payload.get('id', str(hash(str(node))))),
|
||||||
|
score=1.0,
|
||||||
|
payload=payload
|
||||||
|
)]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"❌ Error querying Entity nodes: {e}")
|
print(f"❌ Error in fallback search: {e}")
|
||||||
|
|
||||||
assert len(search_results) > 0, "No entities found in the vector database"
|
assert len(search_results) > 0, "No entities found in the vector database"
|
||||||
random_node = search_results[0]
|
random_node = search_results[0]
|
||||||
random_node_name = random_node.payload["text"]
|
random_node_name = random_node.payload["text"]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue