Skip to main content
Everything you know about how an engineer works is scattered: a short profile, months of assistant conversations full of code, and a team document of coding principles nobody cross-references. Answering “does the code I wrote actually follow the principles we agreed on?” means holding all three in your head at once.

What You’ll Build

Three heterogeneous sources — a plain-text developer profile, a JSON export of human/assistant coding conversations, and a Markdown guide to the Zen of Python — go into memory under two node sets, with an OWL ontology grounding the entities that get extracted. A memify() pass then consolidates the graph, and you get two interactive HTML snapshots (before and after) plus answers to two questions: one that has to reach across the conversations and the principles document at once, and one deliberately scoped to the principles alone. The complete runnable script is examples/demos/comprehensive_example/cognee_comprehensive_example.py — this page walks through its key moments rather than reproducing it.

Features in Play

  • NodeSet Grouping — labels the profile and conversations as developer_data and the Zen guide as principles_data, so the second question can be answered from the principles alone
  • Ontology Quickstart — the bundled OWL file grounds extraction in a shared vocabulary instead of letting each source invent its own entity names
  • Memify — the consolidation pass that runs between the two snapshots and enriches the connections across sources
  • Graph Visualization — renders the graph twice, so the effect of consolidation is something you can look at rather than infer
  • Recall — answers both questions with GRAPH_COMPLETION, once across the whole graph and once filtered to one node set

Before You Start

  • Complete Quickstart to understand basic operations
  • Ensure you have LLM Providers and Embedding Providers configured
  • The script sets os.environ["LLM_API_KEY"] = "your_api_key" at the top as a placeholder — replace it with your own key, or delete the line if your .env already carries one
  • Run it from a cognee repo checkout rather than a copy-paste: it reads three bundled files from the sibling data/ folder — copilot_conversations.json, zen_principles.md, and basic_ontology.owl
  • The run starts with cognee.forget(everything=True), which wipes all existing Cognee data — use a setup you can afford to reset

How It Works

Stage 1: Locate the Bundled Sources

The three inputs are resolved relative to the script file, so the demo works from any working directory as long as it runs inside the repo checkout. Two of them are data to ingest; the third is the ontology that shapes how that data is read.

Stage 2: Ground Extraction in the OWL Ontology

The ontology is configured through the environment rather than passed as an argument, and this assignment happens before import cognee — Cognee reads env-backed settings at import time, so setting it afterwards would not take effect. Every source ingested below is extracted against this shared vocabulary.

Stage 3: Ingest Three Sources into Two Node Sets

A clean slate, then three remember() calls that differ in what they take — an inline string, a JSON path, and a Markdown path — but land in the same graph. The node sets do the sorting: the engineer’s profile and their conversations become developer_data, the Zen guide becomes principles_data. self_improvement=False skips the automatic enrichment pass so that the memify() call in the next stage is the only consolidation step, and its effect is visible in isolation.

Stage 4: Snapshot the Graph Before and After Consolidation

The same render runs on either side of memify(). The first file shows what ingestion alone produced — the two node sets and the ontology-grounded entities under them; the second shows the graph after consolidation has enriched the connections between them. Opening both is the point of the stage.

Stage 5: Ask a Question That Spans Sources

AsyncWebScraper appears only in the conversation export; “Python’s design principles” only in the Zen guide. Neither source answers this question alone, and with no node-set filter the recall traverses the whole graph — so the answer has to be assembled from both.

Stage 6: Scope Recall to One Node Set

The same search type, now restricted to principles_data via node_name. This is what the tagging in Stage 3 bought: a question about conventions answered from the principles document, without the engineer’s own past code influencing the answer.

Run It

A successful run prints two lines after the ingestion and consolidation progress: Python Pattern Analysis: followed by an answer that connects the scraper implementation to specific Zen principles, and Filtered search result: followed by a naming-convention answer drawn from the principles document. It also leaves two HTML files in an .artifacts folder next to the script — graph_visualization_nodesets_and_ontology.html and graph_visualization_after_memify.html — which you open in a browser to compare the graph before and after memify().

NodeSet Grouping

Learn the tagging this demo uses to keep two topics apart in one graph.

Ontology Quickstart

Step through grounding extraction in your own OWL vocabulary.

Graph Visualization

Render and bound the graph snapshots this demo compares.

Recall

See the full set of recall parameters behind both questions.