feat: quick fix dynamic collection handling in search (#567) [COG-1369]

<!-- .github/pull_request_template.md -->

## Description
Fixes search dynamic collection mapping in graph completion search

## DCO Affirmation
I affirm that all code in every commit of this pull request conforms to
the terms of the Topoteretes Developer Certificate of Origin


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Refactor**
- Adjusted graph processing to remove extraneous notifications when
expected data elements are absent.
- Updated query processing to ensure a more consistent selection of
related data types.
- Streamlined database error handling by aligning exception management
with standard practices.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
hajdul88 2025-02-21 13:45:42 +01:00 committed by GitHub
parent fd3b15fb58
commit eba1515127
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 4 deletions

View file

@ -11,7 +11,10 @@ class EntityNotFoundError(CogneeApiError):
name: str = "EntityNotFoundError", name: str = "EntityNotFoundError",
status_code=status.HTTP_404_NOT_FOUND, status_code=status.HTTP_404_NOT_FOUND,
): ):
super().__init__(message, name, status_code) self.message = message
self.name = name
self.status_code = status_code
# super().__init__(message, name, status_code) :TODO: This is not an error anymore with the dynamic exception handling therefore we shouldn't log error
class EntityAlreadyExistsError(CogneeApiError): class EntityAlreadyExistsError(CogneeApiError):

View file

@ -126,8 +126,6 @@ class CogneeGraph(CogneeAbstractGraph):
node = self.get_node(node_id) node = self.get_node(node_id)
if node: if node:
node.add_attribute("vector_distance", score) node.add_attribute("vector_distance", score)
else:
print(f"Node with id {node_id} not found in the graph.")
async def map_vector_distances_to_graph_edges(self, vector_engine, query) -> None: async def map_vector_distances_to_graph_edges(self, vector_engine, query) -> None:
try: try:

View file

@ -1,4 +1,5 @@
from cognee.infrastructure.engine import ExtendableDataPoint from cognee.infrastructure.engine import ExtendableDataPoint
from cognee.infrastructure.engine.models.DataPoint import DataPoint
from cognee.modules.graph.utils.convert_node_to_data_point import get_all_subclasses from cognee.modules.graph.utils.convert_node_to_data_point import get_all_subclasses
from cognee.tasks.completion.exceptions import NoRelevantDataFound from cognee.tasks.completion.exceptions import NoRelevantDataFound
from cognee.infrastructure.llm.get_llm_client import get_llm_client from cognee.infrastructure.llm.get_llm_client import get_llm_client
@ -38,7 +39,7 @@ async def graph_query_completion(query: str, context_resolver: Callable = None)
- Ensure that the LLM client and graph database are properly configured and accessible. - Ensure that the LLM client and graph database are properly configured and accessible.
""" """
subclasses = get_all_subclasses(ExtendableDataPoint) subclasses = get_all_subclasses(DataPoint)
vector_index_collections = [] vector_index_collections = []