From 97f90c95ed6371631e598bdb76682b2cd6c2cace Mon Sep 17 00:00:00 2001 From: Daulet Amirkhanov Date: Tue, 7 Oct 2025 16:09:11 +0100 Subject: [PATCH] Remove all references to `SearchType.INSIGHTS` across the codebase, meaningfully replacing it with `SearchType.GRAPH_COMPLETION` where applicable. --- .../src/modules/chat/hooks/useChat.ts | 17 ----------------- cognee-mcp/README.md | 2 +- cognee-mcp/src/server.py | 11 ----------- cognee/api/v1/responses/default_tools.py | 1 - cognee/api/v1/responses/dispatch_function.py | 2 +- .../api/v1/responses/routers/default_tools.py | 1 - cognee/api/v1/search/search.py | 9 --------- cognee/cli/commands/search_command.py | 4 ---- cognee/cli/config.py | 1 - .../llm/prompts/search_type_selector_prompt.txt | 5 ----- .../utils/description_to_codepart_search.py | 2 +- .../cli_tests/cli_unit_tests/test_cli_utils.py | 1 - 12 files changed, 3 insertions(+), 53 deletions(-) diff --git a/cognee-frontend/src/modules/chat/hooks/useChat.ts b/cognee-frontend/src/modules/chat/hooks/useChat.ts index 613f9134f..ed5bc4d79 100644 --- a/cognee-frontend/src/modules/chat/hooks/useChat.ts +++ b/cognee-frontend/src/modules/chat/hooks/useChat.ts @@ -89,15 +89,6 @@ export default function useChat(dataset: Dataset) { } -interface Node { - name: string; -} - -interface Relationship { - relationship_name: string; -} - -type InsightMessage = [Node, Relationship, Node]; // eslint-disable-next-line @typescript-eslint/no-explicit-any function convertToSearchTypeOutput(systemMessage: any[] | any, searchType: string): string { @@ -106,14 +97,6 @@ function convertToSearchTypeOutput(systemMessage: any[] | any, searchType: strin } switch (searchType) { - case "INSIGHTS": - return systemMessage.map((message: InsightMessage) => { - const [node1, relationship, node2] = message; - if (node1.name && node2.name) { - return `${node1.name} ${relationship.relationship_name} ${node2.name}.`; - } - return ""; - }).join("\n"); case "SUMMARIES": return systemMessage.map((message: { text: string }) => message.text).join("\n"); case "CHUNKS": diff --git a/cognee-mcp/README.md b/cognee-mcp/README.md index 8d973725b..aa6442993 100644 --- a/cognee-mcp/README.md +++ b/cognee-mcp/README.md @@ -266,7 +266,7 @@ The MCP server exposes its functionality through tools. Call them from any MCP c - **codify**: Analyse a code repository, build a code graph, stores it in memory -- **search**: Query memory – supports GRAPH_COMPLETION, RAG_COMPLETION, CODE, CHUNKS, INSIGHTS +- **search**: Query memory – supports GRAPH_COMPLETION, RAG_COMPLETION, CODE, CHUNKS - **list_data**: List all datasets and their data items with IDs for deletion operations diff --git a/cognee-mcp/src/server.py b/cognee-mcp/src/server.py index 1eceae07b..e7c82c99b 100755 --- a/cognee-mcp/src/server.py +++ b/cognee-mcp/src/server.py @@ -478,11 +478,6 @@ async def search(search_query: str, search_type: str) -> list: Best for: Direct document retrieval, specific fact-finding. Returns: LLM responses based on relevant text chunks. - **INSIGHTS**: - Structured entity relationships and semantic connections. - Best for: Understanding concept relationships, knowledge mapping. - Returns: Formatted relationship data and entity connections. - **CHUNKS**: Raw text segments that match the query semantically. Best for: Finding specific passages, citations, exact content. @@ -524,7 +519,6 @@ async def search(search_query: str, search_type: str) -> list: - "RAG_COMPLETION": Returns an LLM response based on the search query and standard RAG data - "CODE": Returns code-related knowledge in JSON format - "CHUNKS": Returns raw text chunks from the knowledge graph - - "INSIGHTS": Returns relationships between nodes in readable format - "SUMMARIES": Returns pre-generated hierarchical summaries - "CYPHER": Direct graph database queries - "FEELING_LUCKY": Automatically selects best search type @@ -537,7 +531,6 @@ async def search(search_query: str, search_type: str) -> list: A list containing a single TextContent object with the search results. The format of the result depends on the search_type: - **GRAPH_COMPLETION/RAG_COMPLETION**: Conversational AI response strings - - **INSIGHTS**: Formatted relationship descriptions and entity connections - **CHUNKS**: Relevant text passages with source metadata - **SUMMARIES**: Hierarchical summaries from general to specific - **CODE**: Structured code information with context @@ -547,7 +540,6 @@ async def search(search_query: str, search_type: str) -> list: Performance & Optimization: - **GRAPH_COMPLETION**: Slower but most intelligent, uses LLM + graph context - **RAG_COMPLETION**: Medium speed, uses LLM + document chunks (no graph traversal) - - **INSIGHTS**: Fast, returns structured relationships without LLM processing - **CHUNKS**: Fastest, pure vector similarity search without LLM - **SUMMARIES**: Fast, returns pre-computed summaries - **CODE**: Medium speed, specialized for code understanding @@ -586,9 +578,6 @@ async def search(search_query: str, search_type: str) -> list: return str(search_results[0]) elif search_type.upper() == "CHUNKS": return str(search_results) - elif search_type.upper() == "INSIGHTS": - results = retrieved_edges_to_string(search_results) - return results else: return str(search_results) diff --git a/cognee/api/v1/responses/default_tools.py b/cognee/api/v1/responses/default_tools.py index 295d132f1..f3d643df2 100644 --- a/cognee/api/v1/responses/default_tools.py +++ b/cognee/api/v1/responses/default_tools.py @@ -14,7 +14,6 @@ DEFAULT_TOOLS = [ "type": "string", "description": "Type of search to perform", "enum": [ - "INSIGHTS", "CODE", "GRAPH_COMPLETION", "NATURAL_LANGUAGE", diff --git a/cognee/api/v1/responses/dispatch_function.py b/cognee/api/v1/responses/dispatch_function.py index 85388b564..aea37c350 100644 --- a/cognee/api/v1/responses/dispatch_function.py +++ b/cognee/api/v1/responses/dispatch_function.py @@ -59,7 +59,7 @@ async def handle_search(arguments: Dict[str, Any], user) -> list: valid_search_types = ( search_tool["parameters"]["properties"]["search_type"]["enum"] if search_tool - else ["INSIGHTS", "CODE", "GRAPH_COMPLETION", "NATURAL_LANGUAGE"] + else ["CODE", "GRAPH_COMPLETION", "NATURAL_LANGUAGE"] ) if search_type_str not in valid_search_types: diff --git a/cognee/api/v1/responses/routers/default_tools.py b/cognee/api/v1/responses/routers/default_tools.py index e43620a4b..4194e3376 100644 --- a/cognee/api/v1/responses/routers/default_tools.py +++ b/cognee/api/v1/responses/routers/default_tools.py @@ -14,7 +14,6 @@ DEFAULT_TOOLS = [ "type": "string", "description": "Type of search to perform", "enum": [ - "INSIGHTS", "CODE", "GRAPH_COMPLETION", "NATURAL_LANGUAGE", diff --git a/cognee/api/v1/search/search.py b/cognee/api/v1/search/search.py index 7209c6036..0a9e76e96 100644 --- a/cognee/api/v1/search/search.py +++ b/cognee/api/v1/search/search.py @@ -52,11 +52,6 @@ async def search( Best for: Direct document retrieval, specific fact-finding. Returns: LLM responses based on relevant text chunks. - **INSIGHTS**: - Structured entity relationships and semantic connections. - Best for: Understanding concept relationships, knowledge mapping. - Returns: Formatted relationship data and entity connections. - **CHUNKS**: Raw text segments that match the query semantically. Best for: Finding specific passages, citations, exact content. @@ -124,9 +119,6 @@ async def search( **GRAPH_COMPLETION/RAG_COMPLETION**: [List of conversational AI response strings] - **INSIGHTS**: - [List of formatted relationship descriptions and entity connections] - **CHUNKS**: [List of relevant text passages with source metadata] @@ -146,7 +138,6 @@ async def search( Performance & Optimization: - **GRAPH_COMPLETION**: Slower but most intelligent, uses LLM + graph context - **RAG_COMPLETION**: Medium speed, uses LLM + document chunks (no graph traversal) - - **INSIGHTS**: Fast, returns structured relationships without LLM processing - **CHUNKS**: Fastest, pure vector similarity search without LLM - **SUMMARIES**: Fast, returns pre-computed summaries - **CODE**: Medium speed, specialized for code understanding diff --git a/cognee/cli/commands/search_command.py b/cognee/cli/commands/search_command.py index 3540a833c..4c53cc260 100644 --- a/cognee/cli/commands/search_command.py +++ b/cognee/cli/commands/search_command.py @@ -31,10 +31,6 @@ Search Types & Use Cases: Traditional RAG using document chunks without graph structure. Best for: Direct document retrieval, specific fact-finding. -**INSIGHTS**: - Structured entity relationships and semantic connections. - Best for: Understanding concept relationships, knowledge mapping. - **CHUNKS**: Raw text segments that match the query semantically. Best for: Finding specific passages, citations, exact content. diff --git a/cognee/cli/config.py b/cognee/cli/config.py index 31e8693c7..d016608c1 100644 --- a/cognee/cli/config.py +++ b/cognee/cli/config.py @@ -19,7 +19,6 @@ COMMAND_DESCRIPTIONS = { SEARCH_TYPE_CHOICES = [ "GRAPH_COMPLETION", "RAG_COMPLETION", - "INSIGHTS", "CHUNKS", "SUMMARIES", "CODE", diff --git a/cognee/infrastructure/llm/prompts/search_type_selector_prompt.txt b/cognee/infrastructure/llm/prompts/search_type_selector_prompt.txt index 7ed2e72fc..1a00bce7e 100644 --- a/cognee/infrastructure/llm/prompts/search_type_selector_prompt.txt +++ b/cognee/infrastructure/llm/prompts/search_type_selector_prompt.txt @@ -10,8 +10,6 @@ Here are the available `SearchType` tools and their specific functions: - Summarizing large amounts of information - Quick understanding of complex subjects -* **`INSIGHTS`**: The `INSIGHTS` search type discovers connections and relationships between entities in the knowledge graph. - **Best for:** - Discovering how entities are connected @@ -95,9 +93,6 @@ Here are the available `SearchType` tools and their specific functions: Query: "Summarize the key findings from these research papers" Response: `SUMMARIES` -Query: "What is the relationship between the methodologies used in these papers?" -Response: `INSIGHTS` - Query: "When was Einstein born?" Response: `CHUNKS` diff --git a/cognee/modules/retrieval/utils/description_to_codepart_search.py b/cognee/modules/retrieval/utils/description_to_codepart_search.py index a61feb574..649edb6ed 100644 --- a/cognee/modules/retrieval/utils/description_to_codepart_search.py +++ b/cognee/modules/retrieval/utils/description_to_codepart_search.py @@ -62,7 +62,7 @@ async def code_description_to_code_part( try: if include_docs: - search_results = await search(query_text=query, query_type="INSIGHTS") + search_results = await search(query_text=query, query_type="GRAPH_COMPLETION") concatenated_descriptions = " ".join( obj["description"] diff --git a/cognee/tests/cli_tests/cli_unit_tests/test_cli_utils.py b/cognee/tests/cli_tests/cli_unit_tests/test_cli_utils.py index 00ee5f442..05de0c70b 100644 --- a/cognee/tests/cli_tests/cli_unit_tests/test_cli_utils.py +++ b/cognee/tests/cli_tests/cli_unit_tests/test_cli_utils.py @@ -53,7 +53,6 @@ class TestCliConfig: expected_types = [ "GRAPH_COMPLETION", "RAG_COMPLETION", - "INSIGHTS", "CHUNKS", "SUMMARIES", "CODE",