Search this site
Embedded Files

Home

How does it work?

The simple answer:

Docu-Chat is an AI-powered query engine that helps you extract insights from PDF documents. To use it:

  • Select a PDF file

  • Provide your OpenAI API key (see What is an OpenAI API Key? below)

  • Type a question related to the content of your document

  • The app will analyze the document and respond with an answer. It's like having a conversation with your document.

The technical answer:

Docu-Chat leverages several technologies to provide an interactive chat interface for querying PDF documents.

  • PDF Handling: The user uploads a PDF file through a Panel file input widget. The app processes it using the PyPDFLoader class to load the document.

  • LangChain Integration: LangChain is used to handle the retrieval of answers from the documents. The loaded PDF is split into smaller chunks using CharacterTextSplitter, and the chunks are then embedded using OpenAI embeddings. 

  • Chroma Vector Store: Chroma is utilized to create a seamless vector store from the embedded documents, which is then used as a retriever for similarity searches.

  • Query Processing: The user's query is processed, and any empty lines are removed. If there is a chat history, it's appended to the query to provide context. The RetrievalQA class from LangChain is used to perform a similarity search on the documents, and the retrieved answer is returned to the user. This app currently uses LangChain's "stuff"  chain to perform the query.

  • OpenAI Integration: An OpenAI API key is required for the embeddings. The key is entered by the user and set as an environment variable to authenticate with OpenAI services.

  • In-Memory Conversation History: The app maintains a chat history in memory, allowing the context of previous interactions to be considered in subsequent queries.

  • Hugging Face Hosting: The entire app is hosted on Hugging Face, providing seamless integration between LLMs and open source access to the code. See Why did you build this? for the link to source code.


What can I upload?

At the moment Docu-Chat is designed to analyze PDF files only. For best results, upload PDFs with machine readable text. Scanned documents and PDFs without machine readable characters will result in lower quality results. There's no limit to the size or length of file you upload, but very large files will require more time to process and more OpenAI tokens (see What is an "OpenAI API Key" and where do I get one?).

Please note that although this application has been designed with user privacy and data security in mind, it is not recommended to upload sensitive documents. See the full app disclaimer at the bottom of this page.


What's an OpenAI API key?

What is an API?

An API (Application Programming Interface) is a set of rules that allow different software applications (like Docu-Chat and OpenAI) to communicate with each other. The API defines how requests and responses (like the questions you ask) should be formatted, and what data (like the documents you upload) can be accessed.

And what is an API Key?

An API Key is basically your unique password that allows you to access the specific services provided by the API. The key helps the API provider (in this case OpenAI) to identify you, track your usage, and control access to the data and functions. Essentially, the API Key ensures that only authorized users can interact with OpenAI.

How do I get my OpenAI API Key?

You can get your key by doing the following:

  • Create an OpenAI account‍, here ⧉ (if you haven't already got one)

  • Navigate to the API section, here ⧉

  • Generate a new API Key and save it somewhere safe

  • Set up billing, and set usage limits (optional but recommended)

Once you have a key, you'll need to enter it into this application before you can use it – that way, OpenAI knows who's making the request!


Is it free to use?

Yes and no. Let me explain:

The app itself is free to use. I don't charge anything for the app and don't make any money from it! But Docu-Chat uses OpenAI to process your requests. OpenAI charge a very small amount of money for this, and you'll need to provide an OpenAI API Key before using this application. OpenAI will charge you approximately $0.03 for every 15,000 words you upload, and $0.04 for every 15,000 words of analysis generated. Since the average length of book is 90,000 words, it's about 18 cent to analyze a whole book (...pretty cheap). Note, this application uses OpenAI's GPT-3.5-Turbo model (the most advanced model at the time of deployment).


Why did you build Docu-Chat?

I built Docu-Chat in December 2022 primarily to experiment with OpenAI's GPT-3.5-Turbo model, and as a tool to help me. I work fast, and finding specific answers within extensive documents can be time-consuming. Docu-Chat improves efficiency and streamlines information extraction. Since building this, many better products have been released, but I keep Docu-Chat as an archive of my work.

Docu-Chat is open source and free-to-use. You're welcome to clone, remix, re-purpose, or upgrade this app yourself via Hugging Face ⧉

Take me home

© McKenzie Lloyd-Smith 2024 | Created by me, fuelled by ☕️

Google Sites
Report abuse
Google Sites
Report abuse