MDChat

Building a Markdown reading, AI powered, chatbot

Table of contents

AI and LLMs have been the hot-topic this year. While I don’t think AI systems are wholly good, I do tend to think that it’s impossible to put tech like this “back in the bag”. You can either learn what’s out there and know when it may be an appropriate tool to reach for (this can also be never: crypto had no real use-case, for example), or you can operate without that knowledge and operate as normal with a possible disadvantage.

That being said, I had some time off for the holidays this year and wanted to do some learning! What better way than to build a project centered around AI. One of my first ideas was to use an LLM to summarize my notes. I take notes in Obsidian for my work and personal life everyday so I have literally hundreds of documents outlining my daily work, current projects, personal research, interests, etc that I can feed into an LLM for context.

What I built

Enter MDChat: a CLI app that enables you to chat with your markdown notes. MDChat uses a large language model (LLM) and a method called “Retrieval Augmented Generation” to allow you to have conversations with an artificially intelligent “expert” on your markdown notes. While initially I built out MDChat for use with my personal notes, I’ve started using it to “chat with” large manuals and library documentation as well.

My general approach

I built MDChat out as an CLI app. I spend a good amount of my work day in a terminal and I figured it’d be nice to be able to spin-up a chat there. I also wanted to keep the UI/UX work minimal as I wanted to focus on learning about and implementing the LLM pieces.

I did a bunch of reading on GitHub (made a list of useful AI repos), The OpenAI website, Mastodon, etc. I learned a lot about how LLM-powered systems work at a surface level, and I got familiar with how people are building with them.

I learned that finding and feeding relevant information into an LLM in your prompt so it can generate answers based on that specialized knowledge is generally known as “Retrieval Augmented Generation” or RAG for short1. I also learned that there are a lot of projects out there that already do this. They can range from pretty minimal2 to massive undertakings in collecting, formatting, normalizing, ingesting, and indexing data for a specific use-case3.

With that in mind, I decided to start simple and build up as needed.

Tools & libraries

Here’s a brief overview of the tools I used to build MDChat, and some thoughts on how they all tie together.

My results

I’ve been using MDChat for a few weeks and have some notes on what I’ve found it useful for and where it still needs more work

The good

The not-so-good

Overall

I’m happy with where MDChat is at right now!

I spent around a week really digging in on LLMs: Reading, watching videos, just generally sucking up information. During that week I started work on the CLI, got a good bit done, and then in my second week I was able to get a fully working, relatively well tested, and published CLI package out into the world.

Future work

While I am happy with what I have so far, there are a few more things I’d like to do with MDChat. I think a few changes could make it more useful and more adaptable to people’s specific needs:

I’m sure more will come up as I use the tool and continue to learn as well.

Try it for yourself

If you have python v3.10+ installed, at least one markdown file, and an OpenAI API key, you can try mdchat out right now!

Open up your terminal, install the app, do some config, and get chatting:

# install the CLI app from PyPi
pip install mdchat

# asks for your API key, LLM of choice, and notes folder location
mdchat config

# to chat the notes folder you just set
mdchat chat 

# to chat with a specific file
mdchat chat --file "./your/file/here.md"

If you run into issues or have any feedback at all I’d love to hear from you!

Footnotes

  1. a short video on RAG from IBM ↩

  2. a simple RAG setup outlined by the people over at LangChain ↩

  3. a good overview of RAG systems and how to scale them from a talk at the OpenAI DevDay conference in 2023 ↩

Loading search…

Search posts, pages, and social links. Press Esc to close.