DEV Community

Shanelle
Shanelle

Posted on

Creating a Second Brain with Lightrail

Ever since OpenAI emerged, ChatGPT has been my go-to for various tasks like drafting emails, planning trips, and generating and debugging code. However, its memory is confined to each session in the chat window. I'm personally interested in creating a long-term memory system where I can add notes, papers, websites, etc., and then seamlessly search across them — a concept often referred to online as a second brain. There are intriguing products like Mem.ai and Dot (which caught my eye on HN this week), but I steer clear of tools that host my data due to privacy concerns and the potential for losing access if they change prices or product direction.

Lightrail

I've been actively contributing to an open-source tool called Lightrail. It combines an always-on GPT-4 instance with seamless integration across various apps like Google Chrome and VSCode. However, my favorite new feature is the ability to create a personal knowledge base. I can add any text content, and Lightrail indexes and stores the information in an on-device vectorDB for use in future queries. It's open-source and local-first, making it a personal second brain that’s searchable with GPT-4. While I primarily use it for dev-focused tasks rather than miscellaneous notes, I thought it might be worth sharing a couple of my favorite hacks.

Indexing Dev Documentation

Like many on here, I use ChatGPT for coding-related tasks. However, I've found that Lightrail is particularly helpful whenI want to implement an obscure library or leverage documentation updated post the GPT-4 cutoff date (January 2022). I can crawl through the latest docs and use them to generate code. For instance, by providing Lightrail with the base URL to the Supabase docs, it not only indexes the intro page but also all the backlinks to ingest the entire documentation.

Add Docs to KB

Then, I can reference this knowledge base to implement Supabase authentication in my VSCode project.

Use in Coding

Simple Code Search

I've also crafted a simple semantic code search. By feeding all the files in a local project into my knowledge base, I can use the [Send to AI] command to ask questions like where payments are implemented or explain how a specific code snippet works in the context of the overall project—eliminating the need for continuous copy-pasting of files into ChatGPT.

Add Codebase

Simple Codebase

Saving & Summarizing

In line with the second brain concept, I've started using Lightrail to save web pages, articles, and papers. Any long-form content becomes part of my knowledge base. I can then use Lightrail to summarize or ask questions. The token kb.relevant-content dynamically pulls in the pertinent information from the knowledge base to answer my queries.

While it's early days for Lightrail, I'm excited about the promise of on-device personal AI companions. In an industry that is evolving day by day, I hold out hope for a more local-first and open-source approach to prevail. If you're interested in giving Lightrail a try, you can download it here!

Top comments (0)