This notebook demonstrates how to use Memgraph and Obsidian for Knowledge Graphs and RAG (Powered by LangChain). This is a work in progress and highly experimental, so the code you see here is subject to change as I refine (and sometimes on a whim when I want to try something new). The goal is to create a seamless integration between Memgraph and Obsidian for creating and querying knowledge graphs. The integration is powered by LangChain, which will be adding additional functionality with LLMs such as GPT-4o, Llama-3, and others.
Memgraph is a high-performance, in-memory graph database that is designed to be fast, scalable, and easy to use. It is a great tool for creating and querying knowledge graphs. You can learn more about Memgraph at https://memgraph.com/.
Obsidian is a powerful knowledge management tool that allows you to create and organize your notes, ideas, and knowledge in a graph-like structure. It is a great tool for creating and visualizing knowledge graphs. You can learn more about Obsidian at https://obsidian.md/.
LangChain is a framework for developing applications powered by large language models (LLMs).
LangChain simplifies every stage of the LLM application lifecycle:
- Development: Build your applications using LangChain's open-source building blocks and components. Hit the ground running using [third-party integrations(https://python.langchain.com/v0.2/docs/integrations/platforms/)] and Templates.
- Productionization: Use LangSmith to inspect, monitor and evaluate your chains, so that you can continuously optimize and deploy with confidence.
- Deployment: Turn any chain into an API with LangServe.
Much of this is based on Bor which is a backend that powers the ODIN or RUNE front-ends. However, I am looking more than just extending Obsidian, so I will be adjusting and improving on this design for my own purposes. I will be using the Bor backend as a starting point, but I will be making significant changes to it as I go along.
For more information you can view the GitHub repositories at:
First things first, we need to install Memgraph. You can download Memgraph from https://memgraph.com/download, however, for what we are doing, it is easier to run Memgraph Platform and Lab in a Docker compose environment. You can find the instructions for this at https://memgraph.com/docs/memgraph-lab/installation/docker-compose.
For my settings, I just followed the standard instructions for running Memgraph Platform and Lab in a Docker compose environment. and then added some adjustments.
The main thing that I wanted to be sure of is that the Obsidian path would be mounted as a volume in the Memgraph Lab container. This is the line that I added to the memgraph-lab
service:
volumes:
- /path/to/obsidian:/root/.config/obsidian
In order to rebuild this, we need to understand the components that we are working with. The main components are:
- MemgraphManager
- Constants
- CollectionManager
- CollectionManager
- CypherQueryHandler
- VaultManager
- GeneralQueryAgent