Khoj Documentation

website·Indexed 34 days ago

https://docs.khoj.dev/

An AI-powered personal assistant and 'Second Brain' that allows users to search notes and documents, chat with AI, and generate images. Supports both Khoj Cloud and self-hosting via Docker or pip, with integrations for Obsidian, Emacs, and WhatsApp. Features include AI agents, automation, voice chat, and support for local models via Ollama and LiteLLM.

Tokens
14.4K
Snippets
57
Records
136
Agent score
66%

What's inside Khoj

  1. Overview of Khoj personal AI capabilities

    Khoj is an open-source personal AI designed to act as a 'second brain'. It allows users to chat with an AI that leverages both public internet information and private files shared by the user. Key capabilities include natural language search across documents and support for multiple file formats including PDF, plaintext, Markdown, Org-mode, and Notion pages.
  2. Overview of Khoj search and chat capabilities

    Khoj provides a modular system for searching and chatting with personal data using natural language understanding (Transformer-based ML models). It supports both cloud-hosted and self-hosted deployments, allowing users to keep data local for privacy. Key features include incremental search-as-you-type and an AI chat interface that works both online and offline for iterative discovery and content generation.
  3. Schedule repeated tasks with Khoj Automations

    Khoj Automations allow you to schedule queries to run automatically at a specific time and frequency. The results of these research tasks are delivered to you via email. Common use cases include creating custom newsletters, summarizing news, or receiving notifications about world events. Scheduling is based on your local time zone. Automations can be configured, shared, and deleted via the Automations page in the Khoj app.
  4. Use Khoj Chat in Obsidian

    Khoj Chat allows you to ask questions about your private notes or the internet in a conversational style. You can access it via the Ribbon icon (💬) or by executing the 'Khoj: Chat' command from the Obsidian Command Palette.
  5. Enable Python code execution in Khoj

    Khoj can generate and run Python code for data analysis, plots, and reports. The system automatically infers when to use the code tool, but users can explicitly trigger it by instructing the AI or by using the /code slash command in chat.
  6. Access and use Khoj via Web Browser

    Khoj provides a web-based client accessible via any web browser (e.g., Khoj Cloud at https://app.khoj.dev). No setup is required to start chatting. However, a desktop client is necessary to share and sync data with Khoj. Key capabilities include natural language search using Transformer-based ML models and an iterative chat interface for retrieving answers from private notes or the internet.
  7. Understand how Khoj Chat generates responses

    Khoj uses Retrieval-Augmented Generation (RAG) to provide context-aware answers. The process follows these steps:

    1. The user query is used to retrieve the most relevant notes via Khoj search.
    2. The retrieved notes, the last few messages of the conversation, and associated metadata are passed to the enabled chat model.
    3. The model uses this combined context and the original query to generate a response, citing the reference notes used.
  8. Access the Khoj Admin Panel

    The Khoj admin panel is used to configure server-wide settings. By default, it is available at http://localhost:42110/server/admin/. Access requires admin credentials, specifically the KHOJ_ADMIN_EMAIL and KHOJ_ADMIN_PASSWORD environment variables.
  9. Configure the GitHub plugin in Khoj

    To index GitHub repositories in Khoj, you must provide a GitHub Personal Access Token (PAT) and specify the repositories to be indexed.

    1. Generate a GitHub classic PAT with at least repo and admin:org scopes.
    2. Navigate to the GitHub settings page in the Khoj app.
    3. Enter the PAT and the details for each repository you wish to index.
    4. Save the settings and click 'Configure' on the main settings page to initiate the process.
    Settings URL: https://app.khoj.dev/settings/content/github
  10. Set up Obsidian plugin development

    The Obsidian plugin source is located in src/interface/obsidian. Use yarn to manage dependencies and start a development server that automatically rebuilds the plugin into main.js upon changes.
    cd src/interface/obsidian
    yarn install
    yarn dev
  11. Enable HTTPS for self-hosted Khoj via Tailscale

    While Tailscale encrypts traffic via Wireguard, enabling HTTPS prevents browser security warnings and unlocks features like clipboard access. To set this up, you must first enable MagicDNS and HTTPS in the Tailscale admin console DNS page.

    1. Generate a certificate using the tailscale cert command for your server's tailnet domain.
    2. Start Khoj using the --sslcert, --sslkey, and --host flags, and set the port to 443.
    # 1. Generate the certificate
    # Replace 'server.black-forest.ts.net' with your actual tailnet domain
    tailscale cert server.black-forest.ts.net
    
    # 2. Start Khoj with SSL configuration
    # Note: sudo is required for port 443
    sudo KHOJ_DOMAIN=server.black-forest.ts.net \
    khoj \
    --sslcert /path/to/your/tailscale.crt \
    --sslkey /path/to/your/tailscale.key \
    --host=server.black-forest.ts.net \
    --port 443
  12. Use keyboard shortcuts for Khoj chat in Obsidian

    Khoj provides keyboard shortcuts within the Obsidian chat input to allow users to navigate message history and send messages without using a mouse:

    • Up Arrow Key: Cycle backwards through the list of most recent messages in the chat window.
    • Down Arrow Key: Cycle forwards through the list of most recent messages in the chat window.
    • Enter: Send the current message typed in the chat window.