DocChat AI

Chat with your documents using AI

Sign In

Initial Setup

Create the admin account for this system.

DocChat AI
Conversations

New Conversation

Documents

Chat Logs

Export CSV

Admin Settings

System Statistics

AI Configuration

System Prompt

Controls how the AI responds. Keep it focused on answering only from document context.

User Management

Help & Documentation

Overview

DocChat AI is a document-based AI chatbot for internal use. Admins upload knowledge documents (SOPs, processing guidelines, lender updates) and team members ask questions via chat. The AI answers only from uploaded document content — never from outside knowledge.

There are two roles:

  • Admin — Full access: Chat, Documents, Chat Logs, Admin settings, Help. Can manage users, upload/delete documents, configure AI, view all chat history.
  • User — Chat only. Can ask questions, pin conversations, clear their own chat history. Cannot see documents, settings, or other users' chats.

Initial Setup

  1. On first launch, the system shows a one-time setup screen to create the admin account (username + display name + password).
  2. After the admin account is created, the setup screen is permanently disabled. No one can self-register.
  3. Log in → go to Admin tab → set your LLM provider and API key (e.g., OpenAI).
  4. Go to Documents tab → upload your knowledge documents.
  5. Wait for documents to show "ready" status (processing takes a few seconds depending on file size).
  6. Go to Chat tab → ask a question. The AI will answer from your documents with citations.
  7. Create user accounts for team members in Admin → User Management.

How the AI Works (RAG Pipeline)

This system uses Retrieval-Augmented Generation (RAG) — the same approach used by Chatbase, CustomGPT, and similar products:

  1. Document Upload: Text is extracted from the file (PDF, DOCX, TXT, Markdown, or Excel).
  2. Chunking: Text is split into overlapping semantic chunks (~512 tokens each). Paragraph and heading boundaries are preserved. Chunks overlap by ~50 tokens to avoid losing context at boundaries.
  3. Embedding: Each chunk is converted into a 1536-dimension numerical vector using the embedding model (default: OpenAI text-embedding-3-small).
  4. Storage: Vectors are stored in the database alongside metadata (document name, page number, heading).
  5. Query: When a user asks a question, it's also converted into a vector.
  6. Vector Search: The system computes cosine similarity between the query vector and all stored vectors, finding the most relevant chunks.
  7. Filtering: Only chunks above the similarity threshold are kept. The top N chunks (configurable) are selected.
  8. LLM Generation: Selected chunks are sent to the LLM along with the system prompt. The LLM generates an answer grounded in those chunks.
  9. Citations: The response includes document name and page number for every source used.

If no chunks match well enough, the bot says it couldn't find the information and suggests rephrasing or uploading the relevant document.

Documents Tab

  • Upload: Click "Upload Document" → drag-and-drop or select files. Supports multiple files at once.
  • Supported formats: PDF (text-based), DOCX, TXT, Markdown (.md), Excel (.xlsx, .xls).
  • Status badges:
    • "new" — uploaded in current session
    • "processing" — being indexed (auto-refreshes every 3 seconds)
    • "ready" — available for chat queries
    • "error" — processing failed (error message shown, Retry button available)
  • Search: Type in the search box to filter documents by name in real-time.
  • Delete: Click "Delete" → confirmation dialog → document and all its embeddings are immediately removed from the knowledge base.
  • Re-upload: If you upload a document with the same filename as an existing one, the old version is automatically replaced (old embeddings deleted, new ones generated).
  • Retry: If processing failed (e.g., VPN blocking API), click Retry to re-process without re-uploading.
  • No retraining needed: Adding or removing documents takes effect immediately.
  • File size limit: 50 MB per file.
  • Excel files: All sheets are extracted and indexed. Sheet names are preserved in the text.

Chat Tab

  • New Conversation: Click "+ New" in the sidebar (desktop) or hamburger menu (mobile).
  • Ask Questions: Type your question and press Enter or click Send.
  • Streaming: Answers appear word-by-word as generated (if enabled in Admin settings).
  • Citations: Every answer shows which documents and pages it came from.
  • Pin Conversations: Click the pin icon to keep important chats at the top. Click again to unpin.
  • Delete Conversation: Click the trash icon to remove a conversation.
  • Clear All: Click "Clear" to remove all conversations at once.
  • Auto-limit: Maximum 20 conversations are kept. Oldest unpinned conversations are automatically removed when the limit is exceeded.
  • Regenerate: Hover over an AI response → click "Regenerate" to get a fresh answer.
  • Copy: Hover over a response → click "Copy" to copy the text to clipboard.
  • Mobile: Use the hamburger menu (≡) on the top-right to access conversations, navigation, and account options.

Chat Logs Tab (Admin only)

  • Purpose: View every chat message from every user — even after users clear their own conversations.
  • Persistence: Chat logs are permanent. Clearing conversations from the Chat tab only removes them from the user's view, not from the logs.
  • Search: Filter logs by message content.
  • Expand: Click a conversation to see all messages in that thread.
  • Export CSV: Download all chat logs as a CSV file for analysis (FAQ identification, training needs, usage patterns).
  • Clear All Logs: Permanently delete all chat history (with confirmation).
  • Use cases: Identify frequently asked questions, spot knowledge gaps, assess team training needs, audit AI accuracy.

Admin Tab — AI Configuration

  • LLM Provider: OpenAI, Google Gemini, Anthropic Claude, OpenRouter, or local Ollama.
  • API Key: Stored securely on the server. Masked in the UI (only last 4 characters shown).
  • Model: e.g., gpt-4o-mini, gpt-4o, claude-3-haiku-20240307, gemini-1.5-flash.
  • Embedding Model: Default: text-embedding-3-small. Changing this after documents are uploaded requires deleting and re-uploading all documents.
  • Temperature (0.0–1.0): Lower = more focused/deterministic. Recommended: 0.1 for factual Q&A.
  • Max Chunks (1–20): How many document segments to include as context per query. More = broader context but higher cost. Recommended: 5–8.
  • Similarity Threshold (0.1–0.5): Minimum relevance score for a chunk to be included. Higher = stricter. Recommended: 0.3.
  • Streaming: Toggle real-time word-by-word response display.

Admin Tab — System Prompt

The system prompt controls how the AI behaves. It is sent before every conversation. Key aspects it controls:

  • Grounding — forcing the AI to answer only from provided document context
  • Citation format — requiring document name and page numbers
  • Conflict resolution — preferring the latest document/update when information conflicts
  • Conversational behavior — how it handles greetings and off-topic questions
  • Restrictions — what the AI should refuse to do (e.g., drafting emails)

Caution: Modifying the system prompt significantly affects answer quality. Always keep the "answer only from context" rules intact.

Admin Tab — User Management

  • Create User: Provide username, display name, password, and role. There is no self-registration — admins create all accounts.
  • Login: Users log in with username + password.
  • Roles: "Admin" sees all tabs. "User" sees only the Chat tab.
  • Change Role: Click "Make Admin" or "Make User" to promote/demote.
  • Remove User: Permanently deletes the account. You cannot delete your own account.

Best Practices for Document Uploads

  • Be specific with filenames: e.g., "Lender_ABC_Processing_Guidelines_2026.pdf" — the filename appears in citations.
  • Use text-based PDFs: Scanned image PDFs won't extract text. Convert to searchable PDF first.
  • Keep documents focused: A 10-page SOP per lender works better than a 500-page omnibus document.
  • Upload updates separately: When a processing update arrives, upload it as a new document. The AI prioritizes the most recent content when conflicts exist.
  • Delete obsolete documents: If a guideline is fully superseded, delete the old version to avoid contradictory answers.
  • Test after uploading: Ask a question you know the answer to and verify correctness.
  • Multiple files at once: Drag-and-drop multiple files into the upload area to batch upload.

Conflict Resolution

The system prompt instructs the AI to handle conflicting information as follows:

  • If multiple documents conflict → the most recently uploaded document takes priority.
  • If a single document contains chronological updates that conflict → the latest dated entry takes priority.
  • The AI will explicitly mention the conflict in its response — stating which documents disagree, on which pages, and which version it's using.

Troubleshooting

"I couldn't find that information"The relevant document may not be uploaded, or the question doesn't match how the document phrases it. Try rephrasing. Check if the document shows "ready" status.
Wrong/outdated answerAn old version of the document may still be uploaded. Delete the old version.
Document stuck on "processing"The embedding API call likely failed (VPN blocking external networks, wrong API key, rate limit). Check the error message, fix the issue, then click Retry.
Document shows "error" + "fetch failed"Network connectivity issue. Disconnect VPN if it blocks external API calls, then click Retry.
Slow responsesEnable streaming in Admin settings. Use a smaller/faster model (GPT-4o-mini vs GPT-4o).
Bot mixes up lendersReduce "Max Chunks" in Admin settings, or increase the similarity threshold to get more focused results.
Garbled/incomplete responsesThis was a streaming parser issue — should be resolved. If it recurs, try disabling streaming temporarily.
Can't log inUsername is case-insensitive. If you forgot your password, another admin can delete and recreate your account.

Data & Storage

  • Database: data/chatbot.db (SQLite). Back up this file to preserve everything.
  • Uploaded files: Stored in the uploads/ directory.
  • Sessions: Stored in memory — users must re-login after server restart.
  • API keys: Stored in the database, never sent to the client browser (UI shows masked values).
  • Chat logs: Permanent until explicitly cleared by an admin via the Chat Logs tab.
  • Backups: To back up the entire system, copy data/chatbot.db and the uploads/ folder.

Mobile Access

  • The app is fully responsive and works on phones and tablets.
  • On mobile, the top navigation tabs move into a hamburger menu (≡) on the top-right.
  • The conversation sidebar also moves into the hamburger menu.
  • All features (chat, upload, admin settings) are accessible on mobile.
Menu
Conversations