chore: fixing logging and empty subgraph case handling

This commit is contained in:
hajdul88 2025-04-29 15:17:00 +02:00
parent 0c1e515c8f
commit cc4fab9e75
2 changed files with 6 additions and 8 deletions

View file

@ -79,11 +79,8 @@ class CogneeGraph(CogneeAbstractGraph):
attribute_filters=memory_fragment_filter
)
if not nodes_data:
#:TODO: quick and dirty solution for sf demo, as the list of nodes can be empty
return None
if not edges_data:
#:TODO: quick and dirty solution for sf demo, as the list of edges can be empty
if not nodes_data or not edges_data:
logger.warning("Empty projected graph.")
return None
for node_id, properties in nodes_data:

View file

@ -9,6 +9,9 @@ from cognee.modules.retrieval.base_retriever import BaseRetriever
from cognee.modules.retrieval.utils.brute_force_triplet_search import brute_force_triplet_search
from cognee.modules.retrieval.utils.completion import generate_completion
from cognee.modules.retrieval.utils.stop_words import DEFAULT_STOP_WORDS
from cognee.shared.logging_utils import get_logger
logger = get_logger()
class GraphCompletionRetriever(BaseRetriever):
@ -80,9 +83,6 @@ class GraphCompletionRetriever(BaseRetriever):
node_name=self.node_name,
)
if len(found_triplets) == 0:
return []
return found_triplets
async def get_context(self, query: str) -> str:
@ -93,6 +93,7 @@ class GraphCompletionRetriever(BaseRetriever):
return ""
if len(triplets) == 0:
logger.warning("Empty context was provided to the completion")
return ""
return await self.resolve_edges_to_text(triplets)