InsightsLM Local

repository·main·Indexed 42 days ago

https://github.com/theaiautomators/insights-lm-local-package

A local-first, private AI research assistant that allows users to run a full stack of AI services—including LLMs, transcription, TTS, and automation—on their own hardware. Built using Docker, N8N, and Supabase, it integrates Ollama (recommended model qwen3:8b-q4_K_M), Whisper ASR, and Coqui TTS to enable offline document chatting, audio transcription, and podcast generation.

Tokens
7.1K
Snippets
14
Records
28
Agent score
51%

What's inside InsightsLM

  1. Overview of InsightsLM Local

    main
    InsightsLM is a fully local, private, and self-hosted AI research assistant. Unlike the cloud-connected version, this package is re-architected to run entirely on your local machine using Docker containers. It allows you to chat with documents (PDFs, text, audio), generate local podcasts via text-to-speech, and transcribe audio using local Whisper models, ensuring all data remains offline and private.
  2. Understand InsightsLM Feature Limitations

    main

    Be aware of the following current limitations in the local version of InsightsLM:

    • Audio Deep Dive: The audio deep dive feature with 2 hosts is not supported in the local version. This requires the cloud version with Google TTS integration.
    • Document OCR: The system does not currently perform OCR. It only extracts text from machine-readable PDFs. To support scanned documents, you must manually integrate a tool like Docling.
  3. Architecture and Technology Stack

    main

    InsightsLM runs a suite of services locally via Docker. The stack consists of:

    • Frontend: React, Vite, and TypeScript.
    • Backend & Automation: N8N.
    • Database & Storage: Local Supabase instance.
    • AI/ML Services:
      • LLM Inference & Embeddings: Ollama (recommended model: qwen3:8b-q4_K_M).
      • Audio Transcription: Whisper ASR.
      • Text-to-Speech: Coqui TTS.
  4. Install InsightsLM Local via Step-by-Step Guide

    main

    The installation requires setting up a base local AI infrastructure and then layering the InsightsLM configuration on top.

    1. Clone Repositories

    First, clone the foundation repository, then clone the InsightsLM package inside it:

    # Clone the base infrastructure
    git clone https://github.com/coleam00/local-ai-packaged.git
    cd local-ai-packaged
    
    # Clone the InsightsLM local package inside the base directory
    git clone https://github.com/theaiautomators/insights-lm-local-package.git

    2. Configure Environment Variables

    1. In the local-ai-packaged root, copy .env.example to .env.
    2. Populate secrets (n8n secrets, postgres password, etc.).
    3. Generate Supabase JWT_SECRET, ANON_KEY, and SERVICE_ROLE_KEY.
    4. Open insights-lm-local-package/.env.copy, copy all variables, and paste them at the end of your main .env file.

    3. Update Docker Compose

    1. Open the main docker-compose.yml in the root.
    2. Open insights-lm-local-package/docker-compose.yml.copy.
    3. Copy the whisper-cache volume and the three services (insights-lm, coqui-tts, whisper-asr) from the .copy file and paste them into the main docker-compose.yml under their respective volumes and services sections.
    4. Update the Ollama model to qwen3:8b-q4_K_M on line 55 of the main docker-compose.yml.

    4. Start Services

    Run the start script using the profile appropriate for your hardware (e.g., Nvidia GPU):

    python start_services.py --profile gpu-nvidia

    5. Database and Function Setup

    1. Import SQL: Log in to Supabase (http://localhost:8000), go to the SQL Editor, and run the contents of insights-lm-local-package/supabase-migration.sql.
    2. Move Functions: Copy all folders from insights-lm-local-package/supabase/functions/ to supabase/volumes/functions/.
    3. Update Supabase Docker Config: Open supabase/docker/docker-compose.yml. Copy the environment variables from insights-lm-local-package/supabase/docker-compose.yml.copy and paste them under the functions service in the main file.
    4. Restart: Shut down services and restart using the start_services.py script.
    # Shutdown command
    docker compose -p localai -f docker-compose.yml --profile gpu-nvidia down

    6. Configure N8N Workflows

    1. Access N8N at http://localhost:5678.
    2. Import insights-lm-local-package/n8n/Import_Insights_LM_Workflows.json.
    3. Configure the following credentials in N8N:
      • N8N API Key: URL http://localhost:5678/api/v1.
      • Webhook Header Auth: Name Authorization, value set in your .env file.
      • Supabase API: Host http://kong:8000, use SERVICE_ROLE_KEY from .env.
      • Ollama: Base URL http://ollama:11434.
    4. Run the importer workflow and activate all imported workflows (except "Extract Text").

    7. Access the App

    Access the frontend at http://localhost:3010. Create a user in the local Supabase dashboard under Authentication to log in.

  5. Refresh audio URL requirements and constraints

    main

    To successfully use the refresh-audio-url function, the following conditions must be met:

    1. Input: A valid notebookId must be provided in the request body.
    2. Database State: A record must exist in the notebooks table with the matching id.
    3. URL Format: The audio_overview_url field in the notebooks table must follow a format where the segment /audio/ is present, allowing the function to identify the storage bucket and file path.
    4. Storage: The file must reside in the audio bucket within Supabase Storage.
    5. Environment Variables: The function requires SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY to be configured in the Supabase environment to perform administrative updates and storage operations.
  6. Fix 'Invalid Authentication Credentials' Login Error

    main

    If you receive an invalid authentication credentials error during login, check the following:

    1. Check for quotes in .env

    Ensure SUPABASE_ANON_KEY and SUPABASE_SERVICE_ROLE_KEY are not wrapped in quotes.

    Incorrect: SUPABASE_ANON_KEY="your-key-here"

    Correct: SUPABASE_ANON_KEY=your-key-here

    2. Rebuild containers after ENV changes

    If you updated the Supabase keys in your .env file after the initial setup, you must rebuild the containers to load the new environment variables.

    1. Open start_services.py.
    2. Locate line 77.
    3. Change cmd.extend(["up", "-d"]) to cmd.extend(["up", "-d", "--build"]).
    4. Run the start command: python start_services.py --profile <your-profile>
    # In start_services.py, change line 77:
    cmd.extend(["up", "-d", "--build"])
  7. Reset Docker containers after volume changes

    main

    After modifying docker-compose.yml to use named volumes (to fix macOS upload errors), you must clear the old bind-mount data and orphans before restarting the services.

    docker compose -p localai -f docker-compose.yml --profile none down -v --remove-orphans
    
    # Then restart
    python3 start_services.py --profile none
  8. Fix Upload Errors on macOS with Docker Desktop

    main

    If you encounter the error Upload Error. Failed to upload document X. Please try again. on macOS, it is likely due to Docker volume mounting issues. The solution is to switch from a bind-mount to a named volume in your docker-compose.yml.

    1. Update storage service: Change the volume from a path to supabase_storage_data:/var/lib/storage.
    2. Update imgproxy service: Change the volume to supabase_storage_data:/var/lib/storage.
    3. Declare the volume: Add supabase_storage_data: to the top-level volumes section at the bottom of the file.
    4. Reset containers: You must remove the old bind-mount data before restarting.

    Note: This solution is based on community feedback and has not been independently verified by the maintainers.

    # 1. Update storage service
    services:
      storage:
        image: supabase/storage-api:v1.25.7
        volumes:
          - supabase_storage_data:/var/lib/storage
    
      # 2. Update imgproxy service
      imgproxy:
        image: darthsim/imgproxy:v3.8.0
        volumes:
          - supabase_storage_data:/var/lib/storage
    
    # 3. Declare the volume at the bottom
    volumes:
      supabase_storage_data:
  9. Configure environment variables for generate-audio-overview

    main

    To function correctly, the generate-audio-overview Edge function requires the following environment variables to be set in your Supabase project:

    VariableDescription
    SUPABASE_URLThe base URL of your Supabase project.
    SUPABASE_SERVICE_ROLE_KEYThe service role key used to bypass Row Level Security (RLS) when updating notebook status.
    AUDIO_GENERATION_WEBHOOK_URLThe endpoint URL of the external service responsible for audio generation.
    NOTEBOOK_GENERATION_AUTHThe authorization header value required by the external audio generation webhook.