Upload Document to Chat (Ad-Hoc context)
Upload Document to Chat (Ad-Hoc context)
Overview
Flow ID: upload-document-to-chat
Category: Chat Interactions
Estimated Duration: 10-30 seconds
User Role: All Users
Complexity: Simple
Purpose: Quickly add a single file (PDF, TXT, etc.) to the current chat context without creating a permanent Dataset. This is useful for “talk to this PDF” scenarios where the document is transient or one-off.
Trigger
What initiates this flow:
- User manually initiates
Specific trigger: Clicking the Paperclip Icon in the chat input bar.
Prerequisites
Before starting, users must have:
- Supported file types (PDF, DOCX, TXT, CSV)
- File size under limit (usually ~10MB or token equivalent)
User Intent Analysis
Primary Intent
“I just want to ask a question about this specific file right now, I don’t want to manage a database.”
Step-by-Step Flow
Main Path (Happy Path)
Step 1: Upload File
- User Action: Click Paperclip Icon > Select File.
- System Response:
- File appears as “chip” in input area.
- Progress bar (uploading/parsing).
Step 2: Processing (Fast)
- System Action:
- Extract text.
- (Optional) Rough chunking or full-text injection depending on size.
- Note: This usually bypasses the heavy vector embedding job pipeline for immediate availability in RAM.
Step 3: Ask Question
- User Action: Type “Summarize this” or “What are the main points?”
- System Response: AI answers using the uploaded file’s content.
Step 4: Persistence Check
- Condition: Does this file stick around?
- Behavior: Usually Session-Scoped. If the user leaves the chat, the file context is lost unless explicitly saved to a dataset.
Error States & Recovery
Error 1: File Too Large (Token Limit)
Cause: Uploading a 500-page book into a context window of 8k tokens
User Experience: “File too large for context window.”
Recovery: System suggests adding it to a Dataset (Blockify Job) instead for full indexing.
Error 2: Unreadable Text
Cause: Scanned PDF (Image) without OCR
User Experience: AI hallucinates or says “It looks empty.”
Recovery: User must OCR file externally first.
Pain Points & Friction
- Token Accounting: Users don’t understand that a 5MB text file might consume their entire context budget, confusing the AI.
- Mitigation: “Token Usage” bar clearly showing file impact.
Design Considerations
- Visual Feedback: Distinct icon for “File in Context”.
- Interaction: Allow clicking the file chip to “Remove” it from pending message.
Related Flows
- Rag Enabled Chat - The robust, persistent version
- Upload Files to Job - Batch processing
Technical References
src/components/chat/file-uploader.jssrc/utils/text-extractor.js