chore: fixing logging and empty subgraph case handling
This commit is contained in:
parent
0c1e515c8f
commit
cc4fab9e75
2 changed files with 6 additions and 8 deletions
|
|
@ -79,11 +79,8 @@ class CogneeGraph(CogneeAbstractGraph):
|
||||||
attribute_filters=memory_fragment_filter
|
attribute_filters=memory_fragment_filter
|
||||||
)
|
)
|
||||||
|
|
||||||
if not nodes_data:
|
if not nodes_data or not edges_data:
|
||||||
#:TODO: quick and dirty solution for sf demo, as the list of nodes can be empty
|
logger.warning("Empty projected graph.")
|
||||||
return None
|
|
||||||
if not edges_data:
|
|
||||||
#:TODO: quick and dirty solution for sf demo, as the list of edges can be empty
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
for node_id, properties in nodes_data:
|
for node_id, properties in nodes_data:
|
||||||
|
|
|
||||||
|
|
@ -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.brute_force_triplet_search import brute_force_triplet_search
|
||||||
from cognee.modules.retrieval.utils.completion import generate_completion
|
from cognee.modules.retrieval.utils.completion import generate_completion
|
||||||
from cognee.modules.retrieval.utils.stop_words import DEFAULT_STOP_WORDS
|
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):
|
class GraphCompletionRetriever(BaseRetriever):
|
||||||
|
|
@ -80,9 +83,6 @@ class GraphCompletionRetriever(BaseRetriever):
|
||||||
node_name=self.node_name,
|
node_name=self.node_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(found_triplets) == 0:
|
|
||||||
return []
|
|
||||||
|
|
||||||
return found_triplets
|
return found_triplets
|
||||||
|
|
||||||
async def get_context(self, query: str) -> str:
|
async def get_context(self, query: str) -> str:
|
||||||
|
|
@ -93,6 +93,7 @@ class GraphCompletionRetriever(BaseRetriever):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
if len(triplets) == 0:
|
if len(triplets) == 0:
|
||||||
|
logger.warning("Empty context was provided to the completion")
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
return await self.resolve_edges_to_text(triplets)
|
return await self.resolve_edges_to_text(triplets)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue