docs: add beginner-friendly knowledge graph example#3012
docs: add beginner-friendly knowledge graph example#3012gourangasatapathyvit wants to merge 10 commits into
Conversation
Add a step-by-step example (examples/guides/beginner_knowledge_graph.py) that walks beginners through the full Cognee workflow: 1. REMEMBER -- ingest sample text about Marie Curie 2. EXPLORE -- print every extracted entity and relationship 3. RECALL -- ask natural-language questions against the graph Also add a pointer to this example in the README Examples section. Closes topoteretes#2738 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Gouranga Satapathy <pulusatapathy@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR adds a beginner-friendly knowledge graph example: a README section and callout linking to a new runnable script that resets state, ingests sample text, prints extracted graph nodes/edges, and runs predefined natural-language queries. ChangesBeginner Knowledge Graph Example
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Add inline explanations in the example script so beginners understand what nodes, edges, and relationships mean - Add "Understanding the Knowledge Graph" section to README with sample output showing extracted entities and relationships - Explains what Cognee does under the hood (chunk, extract, store, answer) in plain language for newcomers Addresses topoteretes#2738 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Gouranga Satapathy <pulusatapathy@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
examples/guides/beginner_knowledge_graph.py (1)
40-40: ⚡ Quick winConsider adding a comment about the internal API usage.
The import of
get_graph_engine()fromcognee.infrastructure.databases.graphis an internal API that may change in future versions. While this is intentional for the demonstration (per the PR objectives), consider adding a comment explaining that this is an advanced inspection technique for educational purposes.📝 Suggested comment addition
import asyncio import cognee +# Note: get_graph_engine is an internal API used here for educational purposes +# to show graph internals. For production code, use cognee.recall() instead. from cognee.infrastructure.databases.graph import get_graph_engine🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@examples/guides/beginner_knowledge_graph.py` at line 40, The import of get_graph_engine from cognee.infrastructure.databases.graph uses an internal API that may change; update the file to add a short inline comment above the import (near the get_graph_engine import statement) stating that this is an internal/advanced inspection technique used for demonstration and may break across versions, and recommend using the public API for production code or pinning the library version when relying on it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/guides/beginner_knowledge_graph.py`:
- Line 58: Add a short docstring to the async function main() that briefly
summarizes what the function demonstrates (e.g., initializing the knowledge
graph, creating nodes/edges, and showing query usage); place the docstring
immediately below the async def main(): line so the function is documented per
project guidelines.
---
Nitpick comments:
In `@examples/guides/beginner_knowledge_graph.py`:
- Line 40: The import of get_graph_engine from
cognee.infrastructure.databases.graph uses an internal API that may change;
update the file to add a short inline comment above the import (near the
get_graph_engine import statement) stating that this is an internal/advanced
inspection technique used for demonstration and may break across versions, and
recommend using the public API for production code or pinning the library
version when relying on it.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: baf91219-43ce-482e-ba85-fc815d92677c
📒 Files selected for processing (2)
README.mdexamples/guides/beginner_knowledge_graph.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Line 194: The README contains a fenced code block opened with triple backticks
that lacks a language tag which triggers markdownlint MD040; update the opening
fence to include a language specifier (e.g., change ``` to ```text) so the block
is properly tagged and lint-clean, leaving the block contents unchanged and
retaining the closing triple backticks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 592e777e-43b6-4332-a533-f5737067ad0b
📒 Files selected for processing (2)
README.mdexamples/guides/beginner_knowledge_graph.py
🚧 Files skipped from review as they are similar to previous changes (1)
- examples/guides/beginner_knowledge_graph.py
- Use correct property key 'type' instead of '_type' for node types - Filter out internal nodes (DocumentChunk, TextSummary) to show only meaningful entities - Filter edges to only show relationships between named nodes - Display recall answers using .text attribute for clean output - Add inline explanations of what nodes and edges are for beginners Tested: runs end-to-end with Azure OpenAI, produces clean output Addresses topoteretes#2738 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Gouranga Satapathy <pulusatapathy@gmail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Gouranga Satapathy <pulusatapathy@gmail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Gouranga Satapathy <pulusatapathy@gmail.com>
|
hi @Vasilije1990 , Can you pls review the PR |
Summary
examples/guides/beginner_knowledge_graph.py— a step-by-step example that walks beginners through the full Cognee workflow: remember → explore → recallCloses #2738
What the example covers
get_graph_engine().get_graph_data(), filtering out internal nodes (DocumentChunk, TextSummary) for clarityChanges
examples/guides/beginner_knowledge_graph.py— new beginner-friendly example with inline explanations of what nodes, edges, and relationships areREADME.md— new "Understanding the Knowledge Graph" section with sample output; pointer in Examples sectionTest plan
python examples/guides/beginner_knowledge_graph.pyend-to-end with Azure OpenAI — all 3 stages complete successfullyruff checkandruff format --checkpassI affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin
🤖 Generated with Claude Code
Summary by CodeRabbit