Source code for course project to build a Graph RAG with Kuzu, DSPy and marimo (open source, reactive notebooks for Python).
We recommend using the uv package manager
to manage dependencies.
# Uses the local pyproject.toml to add dependencies
uv sync
# Or, add them manually
uv add marimo dspy kuzu polars pyarrow
# Don't forget to source virtual env
source .venv/bin/activatedocker compose upGo to localhost:8000 you can check the UI of the database
marimo simultaneously serves three functions. You can run Python code as a script, a notebook, or as an app!
You can manually activate the local uv virtual environment and run marimo as follows:
# Open a marimo notebook in edit mode
marimo edit eda.pyOr, you can simply use uv to run marimo:
uv run marimo edit eda.pyTo run marimo in app mode, use the run command.
uv run marimo run eda.pyEach cell block in a marimo notebook is encapsulated into functions, so you can reuse them in other
parts of your codebase. You can also run the marimo file (which is a *.py Python file) as you
would any other script:
uv run eda.pyReturns:
726 laureate nodes ingested
399 prize nodes ingested
739 laureate prize awards ingested
Depending on the stage of your project and who is consuming your code and data, each mode can be useful in its own right. Have fun using marimo and Kuzu!
Create the required graph in Kuzu using the following script:
uv run create_nobel_api_graph.pyAlternatively, you can open/edit the script as a marimo notebook and run each cell individually to go through the entire workflow step by step.
uv run marimo edit create_nobel_api_graph.pyTo iterate on your ideas and experiment with your approach, you can work through the Graph RAG notebook in the following marimo file:
uv run marimo run demo_workflow.pyThe purpose of this file is to demonstrate the workflow in distinct stages, making it easier to understand and modify each part of the process in marimo.
A demo app is provided in graph_rag.py for reference. It's very basic (just question-answering), but the
idea is general and this can be extended to include advanced retrieval workflows (vector + graph),
interactive graph visualizations via anywidget, and more. More on this in future tutorials!
uv run marimo run graph_rag.py