From e24707c8da4b898c141536f9ad9def52442b5911 Mon Sep 17 00:00:00 2001 From: Igor Ilic Date: Fri, 16 Jan 2026 13:43:01 +0100 Subject: [PATCH] fix: Resolve issue with parameter caching for engine creation --- .../databases/graph/get_graph_engine.py | 30 ++++++++++++++++++- .../databases/vector/create_vector_engine.py | 24 ++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/cognee/infrastructure/databases/graph/get_graph_engine.py b/cognee/infrastructure/databases/graph/get_graph_engine.py index c37af2102..bd2a6f68d 100644 --- a/cognee/infrastructure/databases/graph/get_graph_engine.py +++ b/cognee/infrastructure/databases/graph/get_graph_engine.py @@ -24,7 +24,6 @@ async def get_graph_engine() -> GraphDBInterface: return graph_client -@lru_cache def create_graph_engine( graph_database_provider, graph_file_path, @@ -35,6 +34,35 @@ def create_graph_engine( graph_database_port="", graph_database_key="", graph_dataset_database_handler="", +): + """ + Wrapper function to call create graph engine with caching. + For a detailed description, see _create_graph_engine. + """ + return _create_graph_engine( + graph_database_provider, + graph_file_path, + graph_database_url, + graph_database_name, + graph_database_username, + graph_database_password, + graph_database_port, + graph_database_key, + graph_dataset_database_handler, + ) + + +@lru_cache +def _create_graph_engine( + graph_database_provider, + graph_file_path, + graph_database_url="", + graph_database_name="", + graph_database_username="", + graph_database_password="", + graph_database_port="", + graph_database_key="", + graph_dataset_database_handler="", ): """ Create a graph engine based on the specified provider type. diff --git a/cognee/infrastructure/databases/vector/create_vector_engine.py b/cognee/infrastructure/databases/vector/create_vector_engine.py index 8a87f0339..cdf65514f 100644 --- a/cognee/infrastructure/databases/vector/create_vector_engine.py +++ b/cognee/infrastructure/databases/vector/create_vector_engine.py @@ -7,7 +7,6 @@ from cognee.infrastructure.databases.graph.config import get_graph_context_confi from functools import lru_cache -@lru_cache def create_vector_engine( vector_db_provider: str, vector_db_url: str, @@ -15,6 +14,29 @@ def create_vector_engine( vector_db_port: str = "", vector_db_key: str = "", vector_dataset_database_handler: str = "", +): + """ + Wrapper function to call create vector engine with caching. + For a detailed description, see _create_vector_engine. + """ + return _create_vector_engine( + vector_db_provider, + vector_db_url, + vector_db_name, + vector_db_port, + vector_db_key, + vector_dataset_database_handler, + ) + + +@lru_cache +def _create_vector_engine( + vector_db_provider: str, + vector_db_url: str, + vector_db_name: str, + vector_db_port: str = "", + vector_db_key: str = "", + vector_dataset_database_handler: str = "", ): """ Create a vector database engine based on the specified provider.