diff --git a/.env.template b/.env.template index e9e9fb571..916a1ef76 100644 --- a/.env.template +++ b/.env.template @@ -121,6 +121,9 @@ ACCEPT_LOCAL_FILE_PATH=True # This protects against Server Side Request Forgery when proper infrastructure is not in place. ALLOW_HTTP_REQUESTS=True +# When set to false don't allow cypher search to be used in Cognee. +ALLOW_CYPHER_QUERY=True + # When set to False errors during data processing will be returned as info but not raised to allow handling of faulty documents RAISE_INCREMENTAL_LOADING_ERRORS=True diff --git a/cognee/modules/search/methods/get_search_type_tools.py b/cognee/modules/search/methods/get_search_type_tools.py index e671a7db3..551f77a16 100644 --- a/cognee/modules/search/methods/get_search_type_tools.py +++ b/cognee/modules/search/methods/get_search_type_tools.py @@ -1,3 +1,4 @@ +import os from typing import Callable, List, Optional, Type from cognee.modules.engine.models.node_set import NodeSet @@ -160,6 +161,12 @@ async def get_search_type_tools( if query_type is SearchType.FEELING_LUCKY: query_type = await select_search_type(query_text) + if ( + query_type in [SearchType.CYPHER, SearchType.NATURAL_LANGUAGE] + and os.getenv("ALLOW_CYPHER_QUERY", "true").lower() == "false" + ): + raise UnsupportedSearchTypeError("Cypher query search types are disabled.") + search_type_tools = search_tasks.get(query_type) if not search_type_tools: