Skip to content

Instantly share code, notes, and snippets.

@gary861109
gary861109 / graphrag_monkey_patch.py
Created May 8, 2026 02:51 — forked from MortalHappiness/graphrag_monkey_patch.py
Monkey-patching the https://github.com/microsoft/graphrag package to make it support the locally hosted LLM models on Ollama. See https://chishengliu.com/posts/graphrag-local-ollama/ for details.
# Monkey patch the graphrag package to support local models deployed via Ollama. Only tested for graphrag version 0.3.2.
# See https://chishengliu.com/posts/graphrag-local-ollama/ for details.
#
# Usage:
# * How to patch the `graphrag.index` CLI:
# * Save https://github.com/microsoft/graphrag/blob/v0.3.2/graphrag/index/__main__.py as "index.py"
# * Replace line 8 with:
# ```python
# from graphrag.index.cli import index_cli
# from graphrag_monkey_patch import patch_graphrag