Key Concepts
Notebook LM, Insights LM, RAG (Retrieval-Augmented Generation), Lovable, Bolt, Superbase, N8N, Edge Functions, Vector Store, AI Agent, Prompt Engineering, Database Migration, Open Source, Sustainable Use License, FFmpeg.
Insights LM: A Private, Self-Hosted Notebook LM Clone
The video introduces Insights LM, a self-hosted, customizable clone of Google's Notebook LM, built over three days using Lovable for the front-end and Superbase and N8N for the back-end. The goal is to provide a private, customizable alternative to Notebook LM, particularly for businesses needing AI systems grounded in their own knowledge.
Key Features of Insights LM
- Document Upload and Chat: Users can upload documents (PDFs, MP3s) and website URLs to create notebooks. The system indexes the content, allowing users to chat with the AI agent about the uploaded sources.
- Citation Links: A crucial feature is the in-line citation links, allowing users to verify the AI's responses by jumping directly to the source material used for grounding. This addresses the "hallucination" problem common in AI agents.
- Podcast Generation: Insights LM clones Notebook LM's "deep dive conversation" feature, generating podcast scripts from the uploaded sources for two hosts to discuss.
- Note Saving: Users can save AI-generated responses as notes, retaining the citation links for easy verification. Custom notes can also be created.
Example Use Case: Travel Insurance Company
The video demonstrates Insights LM using a travel insurance company as an example. Policy documents and website FAQs are uploaded, and the AI is queried about claim procedures and other policy-related questions. The responses are grounded in the uploaded materials, with citation links to the specific sections of the documents or web pages.
Architecture of Insights LM
The architecture is broken down into front-end and back-end components:
- Front-end (Lovable): A JavaScript app built using the React framework. Handles user interaction, login (via Superbase authentication), and display of notebooks and sources.
- Back-end (Superbase & N8N):
- Superbase: Provides authentication, database (Postgres), storage (for uploaded files), and edge functions. Policies are set to ensure users can only access their own data.
- N8N: A workflow automation platform used for complex tasks like document chunking, title/description generation, and AI agent interaction.
Data Flow
- User uploads files/sources.
- Files are saved in Superbase storage.
- Superbase edge functions trigger N8N workflows.
- N8N workflows process the sources (chunking, text extraction, etc.).
- Data is saved to the Superbase database (Postgres) and vector store.
- AI agent queries the vector store for grounded responses.
- Responses are displayed in the front-end with citation links.
N8N Workflows
The video details several key N8N workflows:
- Upsert into Vector Store: Chunks documents, generates embeddings, and inserts them into the Superbase vector store.
- Chat Workflow: Implements the AI agent with a detailed system prompt and the ability to fetch data from the vector store. Manages chat history.
- Generate Notebook Details: Creates a title and description for a new notebook based on the uploaded sources.
- Process Additional Sources: Handles the processing of website URLs or pasted text, saving them as sources in the notebook.
- Podcast Generation: Generates a script for a two-host podcast based on the notebook's source documents, then uses the Gemini API to generate the audio.
Citation Logic
The citation logic is implemented through prompt engineering. The AI agent is instructed to output JSON in a specific format, including citation references to the specific chunks of text used to generate each paragraph. This allows the front-end to highlight the relevant sections of the source documents.
Database Architecture
- Users Table: Managed by Superbase authentication.
- Profiles Table: Stores additional user information (linked to the Users table).
- Notebooks Table: Stores notebook metadata (icons, colors, example questions).
- Sources Table: Stores information about each source document (name, description, file path/URL).
- Documents Table: The vector store, containing the chunks of text from the source documents, their embeddings, and metadata (line numbers, IDs).
- Notes Table: Stores user-created notes and AI-generated responses saved as notes.
Storage Buckets
- Sources Bucket: Stores uploaded source files.
- Audio Bucket: Stores generated podcast audio files.
- Public Bucket: For publicly accessible images or assets (alternative to using the public folder in the repo).
Setting Up Insights LM
The video provides a step-by-step guide to setting up Insights LM from the open-source GitHub repository. The process involves:
- Creating a Superbase Account and Project: Generate a database password and note the project ID.
- Creating a GitHub Account and Repository: Fork the Insights LM repository to your own GitHub account.
- Importing the Project into Bolt: Connect Bolt to your Superbase project and apply the Superbase migration to deploy the database schema and edge functions.
- Importing and Configuring N8N Workflows:
- Download the "import insights LM workflows" JSON file from the GitHub repository.
- Import the workflow into your N8N instance.
- Configure the "enter user values" node with the following credentials and IDs:
- Superbase project ID
- N8N Superbase credential ID
- Custom web hook off credential ID (header authentication)
- N8N Postgres credential ID
- N8N Google Gemini credential ID
- N8N OpenAI credential ID
- N8N base URL
- Create the necessary credentials in N8N (Superbase API, header authentication, Postgres, Google Gemini, OpenAI).
- Execute the import workflow to automatically configure the six main N8N workflows.
- Updating the Superbase Secrets: Add the web hook URLs, custom header off key, and OpenAI API key as secrets in your Superbase project's edge functions settings.
- Installing FFmpeg on the N8N Server: Required for podcast audio generation.
- Testing and Customizing the App: Create a user in Superbase authentication, log in to the Bolt-hosted app, and test the various features (document upload, chat, citation links, podcast generation).
Important Notes on Setup
- Web Hook Authentication: The custom header authentication is crucial for securing the N8N workflows.
- Credential IDs: Carefully copy and paste the credential IDs from N8N into the import workflow.
- Workflow Activation: Remember to activate the N8N workflows after importing them.
- FFmpeg: Ensure FFmpeg is installed and configured correctly on your N8N server.
Customization and Commercial Use
- Customization: The app can be customized using Bolt, allowing users to change the logo, add functionality, and modify the codebase.
- Version Control: Be aware of the complexities of version control when maintaining a forked codebase and merging updates from the original repository.
- Commercial Use: The Insights LM repository is open source, allowing users to use and sell the app. However, N8N's sustainable use license may require an enterprise license for SaaS applications. Consider converting N8N workflows to Superbase edge functions to avoid N8N licensing issues.
Conclusion
Insights LM provides a powerful, self-hosted alternative to Notebook LM, offering businesses a private and customizable solution for AI systems grounded in their own knowledge. The open-source nature of the project encourages community contributions and further development. The video provides a detailed guide to setting up and customizing Insights LM, empowering users to leverage this powerful tool for their specific needs.
AI summaries can miss context or contain errors. Check important details against the original video.





