Improve intro, add preliminaries.

This commit is contained in:
lxobr 2025-09-07 13:45:10 +02:00
parent ef54ef2304
commit 2a2d84c147

View file

@ -4,10 +4,9 @@
"metadata": {}, "metadata": {},
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"# Turn expert developer Python knowhow into an AI Memory that will make your own code better. \n", "# Using Cognee with Python Development Data\n",
"\n", "\n",
"\n", "Unite authoritative Python practice (Guido van Rossum's own contributions!), normative guidance (Zen/PEP8), and your lived context (rules + conversations) into one *AI memory* that produces answers that are relevant, explainable, and consistent."
"### Learning from Guido van Rossum, the creator of Python"
], ],
"id": "6f22c8fe6d92cfcc" "id": "6f22c8fe6d92cfcc"
}, },
@ -32,7 +31,7 @@
"metadata": {}, "metadata": {},
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"## Understanding the Cognee Ecosystem\n", "## Cognee and its core operations\n",
"\n", "\n",
"Before we dive in, let's understand the key components we'll be working with:\n", "Before we dive in, let's understand the key components we'll be working with:\n",
"\n", "\n",
@ -50,14 +49,15 @@
"metadata": {}, "metadata": {},
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"### Why This Approach Works\n", "## Data used in this tutorial\n",
"\n", "\n",
"Traditional coding assistants lack context about your specific projects, rules, and past decisions. By building a knowledge graph of development history from Python's creator, we create an AI that understands:\n", "Cognee can ingest many types of sources. In this tutorial, we use a small, concrete set of files that cover different perspectives:\n",
"\n", "\n",
"- Guido's coding patterns and Python design philosophy\n", "- **`guido_contributions.json` — Authoritative exemplars.** Real PRs and commits from Guido van Rossum (mypy, CPython). These show how Pythons creator solved problems and provide concrete anchors for patterns.\n",
"- How language features evolved and why\n", "- **`pep_style_guide.md` — Norms.** Encodes community style and typing conventions (PEP8 and related). Ensures that search results and inferred rules align with widely accepted standards.\n",
"- Best practices derived from decades of Python development\n", "- **`zen_principles.md` — Philosophy.** The Zen of Python. Grounds design tradeoffs (simplicity, explicitness, readability) beyond syntax or mechanics.\n",
"- Connections between different aspects of Python programming" "- **`my_developer_rules.md` — Local constraints.** Your house rules, conventions, and projectspecific requirements (scope, privacy, Spec.md). Keeps recommendations relevant to your actual workflow.\n",
"- **`copilot_conversations.json` — Personal history.** Transcripts of real assistant conversations, including your questions, code snippets, and discussion topics. Captures “how you code” and connects it to “how Guido codes.”"
], ],
"id": "6a7669fbb6a3e6c7" "id": "6a7669fbb6a3e6c7"
}, },
@ -65,13 +65,34 @@
"metadata": {}, "metadata": {},
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"### Exploring Guido's Python Contributions\n", "# Prelinimiaries\n",
"\n", "\n",
"We'll begin with a pre-loaded dataset containing Guido van Rossum's contributions to the Python ecosystem. This demonstrates how cognee structures and connects development activity from Python's creator.\n", "Cognee relies heavily on async functions.\n",
"\n", "We need `nest_asyncio` so `await` works in this notebook."
"Take a moment to explore the repositories this user contributed to with the Graph Visualizaiton"
], ],
"id": "93c9783037715026" "id": "2a5dac2c6fdc7ca7"
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-09-07T11:43:21.615213Z",
"start_time": "2025-09-07T11:43:21.600122Z"
}
},
"cell_type": "code",
"source": [
"import nest_asyncio\n",
"nest_asyncio.apply()"
],
"id": "20cb02b49e3c53e2",
"outputs": [],
"execution_count": 20
},
{
"metadata": {},
"cell_type": "markdown",
"source": "We will do a quick import check.",
"id": "45e1caaec20c9518"
}, },
{ {
"metadata": { "metadata": {
@ -129,6 +150,12 @@
], ],
"execution_count": 1 "execution_count": 1
}, },
{
"metadata": {},
"cell_type": "markdown",
"source": "And just to be safe, we will make sure that the path contains the root directory, so Python can find everything it needs to run the notebook.",
"id": "76895c6570d1a4dc"
},
{ {
"metadata": { "metadata": {
"ExecuteTime": { "ExecuteTime": {
@ -165,6 +192,35 @@
], ],
"execution_count": 2 "execution_count": 2
}, },
{
"metadata": {},
"cell_type": "markdown",
"source": "Finally, we will begin with a clean slate, by removing any previous Cognee data:",
"id": "af584b935cbdc8d"
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"await cognee.prune.prune_data()\n",
"await cognee.prune.prune_system(metadata=True)"
],
"id": "dd47383aa9519465"
},
{
"metadata": {},
"cell_type": "markdown",
"source": [
"### Exploring Guido's Python Contributions\n",
"\n",
"We'll begin with a document that contains detailed PRs and commits from Guido van Rossum's work on mypy and CPython, showing real-world examples of Python's creator solving type system and language design challenges.\n",
"\n",
"We'll use Cognee's `add()` and `cognify()` functions to ingest this data and build a knowledge graph that connects Guido's development patterns with Python best practices."
],
"id": "93c9783037715026"
},
{ {
"metadata": { "metadata": {
"ExecuteTime": { "ExecuteTime": {