Skip to main content

Chatting with PDFs

Once you’ve uploaded a PDF, you can start having intelligent conversations with your document. The AI assistant understands your PDF’s content and can answer questions, summarize information, and help you extract insights.

Getting Started

After uploading a PDF, you’ll be automatically redirected to the chat interface. The interface consists of:
  • Header: Shows “Chat” at the top
  • Message Area: Displays the conversation history
  • Input Field: Where you type your questions
  • Send Button: Click or press Enter to submit your question
The AI uses GPT-4 combined with semantic search through your PDF to provide accurate, context-aware answers.

How to Ask Questions

1

Type Your Question

In the input field at the bottom, type your question. The placeholder text reads “Ask any question…”
2

Submit Your Query

Press Enter or click the Send button (arrow icon) to submit your question.
3

Wait for Response

The AI will:
  • Search through your PDF for relevant context
  • Generate a response based on the document content
  • Stream the answer back to you in real-time
4

Continue the Conversation

Ask follow-up questions to dive deeper into the topic. The AI maintains conversation context.

Types of Questions You Can Ask

Summarization Questions

Get high-level overviews of your document:
- "What is this document about?"
- "Summarize the main points of this PDF"
- "What are the key takeaways?"
- "Give me an executive summary"

Specific Information Queries

Extract specific facts or data:
- "What does the document say about [topic]?"
- "What are the requirements mentioned in section 3?"
- "What dates are mentioned in this document?"
- "Who are the authors or contributors?"

Comparison Questions

Compare different sections or concepts:
- "What's the difference between X and Y in this document?"
- "Compare the approaches discussed in chapters 2 and 3"
- "How does this document define success versus failure?"

Analysis Questions

Get deeper insights:
- "What are the implications of the findings?"
- "What conclusions can be drawn from this data?"
- "What are the strengths and weaknesses discussed?"
- "What recommendations does the document make?"

How the Chat Works

Here’s what happens when you send a message:
ChatComponent.tsx
const { input, handleInputChange, handleSubmit, messages } = useChat({
  api: "/api/chat",
  body: {
    chatId,
  },
  initialMessages: data || [],
});

// The chat interface
<form onSubmit={handleSubmit}>
  <Input
    value={input}
    onChange={handleInputChange}
    placeholder="Ask any question..."
    className="w-full"
  />
  <Button className="bg-blue-600 ml-2">
    <Send className="h-4 w-4" />
  </Button>
</form>

Behind the Scenes

  1. Context Retrieval: Your question is converted to a vector embedding and matched against indexed PDF content
  2. Relevant Extraction: The most relevant passages from your PDF are retrieved
  3. AI Generation: GPT-4 generates an answer based on the retrieved context
  4. Streaming Response: The answer is streamed back to you in real-time
  5. Message Storage: Both your question and the AI’s response are saved to the database
The AI is specifically instructed to only answer based on the PDF content. If information isn’t in the document, it will tell you rather than making up an answer.

AI System Instructions

The AI assistant is configured with these guidelines:
const prompt = {
  role: "system",
  content: `AI assistant is a brand new, powerful, human-like artificial intelligence.
  The traits of AI include expert knowledge, helpfulness, cleverness, and articulateness.
  AI is a well-behaved and well-mannered individual.
  AI is always friendly, kind, and inspiring, and he is eager to provide vivid and thoughtful responses to the user.
  AI has the sum of all knowledge in their brain, and is able to accurately answer nearly any question about any topic in conversation.
  START CONTEXT BLOCK
  ${context}
  END OF CONTEXT BLOCK
  AI assistant will take into account any CONTEXT BLOCK that is provided in a conversation.
  If the context does not provide the answer to question, the AI assistant will say, "I'm sorry, but I don't know the answer to that question".
  AI assistant will not apologize for previous responses, but instead will indicated new information was gained.
  AI assistant will not invent anything that is not drawn directly from the context.
  `,
};

Tips for Better Results

Be Specific: Instead of “Tell me about the data”, ask “What are the sales figures for Q2 mentioned in the report?”
Use Document Structure: Reference sections, chapters, or page areas if you know them: “What does the conclusion section say about future work?”
Ask Follow-ups: Build on previous answers with follow-up questions for deeper understanding.
Break Down Complex Questions: Instead of one complex multi-part question, ask several simpler questions in sequence.

Example Conversations

Example 1: Research Paper

You: What is this paper about?AI: This paper discusses the implementation of transformer models for natural language processing tasks…You: What methodology did they use?AI: The researchers employed a combination of supervised learning with a dataset of 100,000 labeled examples…You: What were their main findings?AI: The main findings indicate that the transformer architecture achieved 95% accuracy on the benchmark…

Example 2: Business Report

You: Summarize the Q3 financial resultsAI: According to the document, Q3 revenue was $5.2M, representing 23% growth year-over-year…You: What factors contributed to this growth?AI: The report attributes growth to three main factors: expanded product line, new market entry, and improved customer retention…

Example 3: Technical Manual

You: How do I configure the database connection?AI: The manual specifies that database configuration requires setting three parameters in the config file…You: What are the security best practices mentioned?AI: The document recommends using encrypted connections, implementing role-based access control…

Message History

All conversations are automatically saved:
  • Persistent Storage: Messages are stored in the database and linked to your chat session
  • Auto-Loading: When you return to a chat, previous messages are automatically loaded
  • Context Awareness: The AI can reference earlier parts of the conversation
const { data, isLoading } = useQuery({
  queryKey: ["chats", chatId],
  queryFn: async () => {
    const response = await fetch("/api/get-messages", {
      method: "POST",
      body: JSON.stringify({ chatId }),
    });
    const data = await response.json();
    return data;
  },
});

Limitations

Document-Only Responses: The AI can only answer questions based on content in your uploaded PDF. It won’t use external knowledge or real-time information.
No Image Analysis: Currently, the system extracts text content only. Images, charts, and diagrams in your PDF are not analyzed.

Troubleshooting

The information might not be in your PDF, or:
  • Try rephrasing your question
  • Ask about a broader topic first
  • Check if the information is in an image or chart (not currently supported)
Response time depends on:
  • Document size and complexity
  • Server load
  • Your internet connection
Typical response time is 3-10 seconds.
Try:
  • Refreshing the page
  • Checking your internet connection
  • Signing out and back in

Next Steps

Upload Another PDF

Learn how to upload additional PDF documents

Upgrade to Pro

Get unlimited chats and advanced features with Pro

Build docs developers (and LLMs) love