-
Notifications
You must be signed in to change notification settings - Fork 967
feat: adds cypher search to retrievers module #648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: adds cypher search to retrievers module #648
Conversation
WalkthroughThis pull request introduces a new cypher search retrieval feature to the Cognee API. A new file with the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant SearchModule as specific_search
participant Retriever as CypherSearchRetriever
participant GraphEngine
Client->>SearchModule: Initiate CYPHER query
SearchModule->>Retriever: Call get_completion(query)
Retriever->>GraphEngine: Retrieve graph engine instance
GraphEngine-->>Retriever: Return graph engine
alt GraphEngine is NetworkXAdapter
Retriever->>Retriever: Raise SearchTypeNotSupported error
else Valid GraphEngine
Retriever->>GraphEngine: Execute cypher query asynchronously
GraphEngine-->>Retriever: Return query result
end
Retriever-->>SearchModule: Return result/context
SearchModule-->>Client: Provide search result
Possibly related PRs
Suggested reviewers
Poem
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧬 Code Definitions (1)cognee/modules/search/methods/search.py (1)
⏰ Context from checks skipped due to timeout of 90000ms (35)
🔇 Additional comments (2)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
cognee/modules/retrieval/exceptions/exceptions.py (1)
1-13: Consider using a more generic error messageThe SearchTypeNotSupported exception looks well-defined, but the default error message is very specific to CYPHER search: "CYPHER search type not supported by the adapter." Since this exception class could potentially be used for other search types, consider using a more generic message.
- message: str = "CYPHER search type not supported by the adapter.", + message: str = "Search type not supported by the adapter.",cognee/modules/retrieval/cypher_search_retriever.py (3)
12-14: Docstring clarity.The docstring for
CypherSearchRetrieveris concise. Consider adding more details on prerequisites and usage context, such as mentioning which graph database adapters are supported or potential use cases.
15-23: Initialization logic is fine.The initializer sets default user and system prompt paths. If these files are intended for dynamic prompt loading, consider adding basic file existence checks or exception handling for advanced usage scenarios.
24-41: Typographical fix in error message and broad exception catch.
- There's a small typo in the error log (“execture” instead of “execute”).
- The broad
except Exception as e:might also catch non-query-related errors, potentially masking deeper issues. Consider refining it to catch more specific exceptions if feasible.-logger.error("Failed to execture cypher search retrieval: %s", str(e)) +logger.error("Failed to execute cypher search retrieval: %s", str(e))
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
cognee/modules/retrieval/cypher_search_retriever.py(1 hunks)cognee/modules/retrieval/exceptions/__init__.py(1 hunks)cognee/modules/retrieval/exceptions/exceptions.py(1 hunks)cognee/modules/search/methods/search.py(2 hunks)cognee/modules/search/types/SearchType.py(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (34)
- GitHub Check: Test on macos-15
- GitHub Check: Test on macos-15
- GitHub Check: run_notebook_test / test
- GitHub Check: Test on macos-13
- GitHub Check: Test on macos-13
- GitHub Check: test
- GitHub Check: Test on ubuntu-22.04
- GitHub Check: Test on ubuntu-22.04
- GitHub Check: run_eval_framework_test / test
- GitHub Check: Test cognee server start
- GitHub Check: run_networkx_metrics_test / test
- GitHub Check: Test on macos-15
- GitHub Check: test
- GitHub Check: test
- GitHub Check: test
- GitHub Check: run_dynamic_steps_example_test / test
- GitHub Check: Test on macos-13
- GitHub Check: Test on ubuntu-22.04
- GitHub Check: run_notebook_test / test
- GitHub Check: Test on ubuntu-22.04
- GitHub Check: run_notebook_test / test
- GitHub Check: test
- GitHub Check: windows-latest
- GitHub Check: test
- GitHub Check: run_multimedia_example_test / test
- GitHub Check: run_notebook_test / test
- GitHub Check: run_simple_example_test / test
- GitHub Check: run_simple_example_test / test
- GitHub Check: test
- GitHub Check: test
- GitHub Check: chromadb test
- GitHub Check: run_simple_example_test
- GitHub Check: docker-compose-test
- GitHub Check: run_simple_example_test
🔇 Additional comments (7)
cognee/modules/retrieval/exceptions/__init__.py (1)
1-7: Module structure looks clean and well-documentedThe exceptions module is well-structured with a clear docstring explaining its purpose. The import statement correctly brings in the specific exceptions from the .exceptions module.
cognee/modules/search/types/SearchType.py (1)
12-12: LGTM: Addition of CYPHER_SEARCH enum valueThe new CYPHER_SEARCH enum value is properly added to the SearchType class, following the same naming pattern as the existing enum values. This aligns with the PR objective to enhance search capabilities for Kuzu and Neo4j.
cognee/modules/search/methods/search.py (2)
15-15: Import statement properly placedThe import for CypherSearchRetriever is correctly placed with the other retriever imports.
69-69: CYPHER_SEARCH properly integratedThe new SearchType.CYPHER_SEARCH is properly mapped to the appropriate retriever method, following the same pattern as existing search types.
cognee/modules/retrieval/exceptions/exceptions.py (1)
15-22: CypherSearchError implementation looks goodThe CypherSearchError exception is well-defined with an appropriate error message and HTTP 500 status code, which is suitable for runtime errors during query execution.
cognee/modules/retrieval/cypher_search_retriever.py (2)
1-10: Imports and logger initialization look good.All required modules are correctly imported, and the logger is properly configured to track retrieval-related logs.
42-47: Evaluate usage of imported completion utility.Although you import
generate_completionat line 6, it’s not used inget_completion. If you intend to transform or augment the retrieved context, consider integratinggenerate_completion. Otherwise, remove the unused import to keep the code clean.
Description
Exposes the query method of the adapter in the search interface for Kuzu and Neo4j (cypher compatible adapters)
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
Summary by CodeRabbit
CYPHERto support the new search type.