Skip to content

vishal-git/doc-qa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Talk to a document 📃🦜

This repository is for an app that lets you (a) summarize a document and (b) ask questions about the document. You can point to the URL that contains some text (e.g., an article, a blog post, or an essay) and the app will summarize its content. You can then chat with an agent to ask questions about the document.

Instructions to Launch the App 🚀

Show instructions

Once you make a copy of this codebase on your computer, activate a Python virtual environment using the following command:

python -m venv .venv --prompt doc-qa

Once the Python virtual environment is created, activate it and install all dependencies from requirements.txt.

source .venv/bin/activate

pip install -r requirements.txt

Once all dependencies are installed, you can launch the app using the following command:

streamlit run src/app.py

In a few seconds the app will be launched in your browser. If that doesn't happen automatically, you can copy the URL that's printed in the output.

Secrets 🔑

Show config settings

This app makes a call to the OpenAI API. You will need to get the API key from OpenAI and store it locally in the .env file.

How to Use the App 🤔

Show intructions

Once the app is launched in the browser, you will see the following:

Enter URL

You can paste a URL link that contains some text, such as an article, a blog post, or an essay. Hit Ctrl + Enter once you paste the URL.

A summary of the article will displayed in a few minutes. See example below for an [article] about when to use classes in Python. [article]: https://death.andgravity.com/same-functions

Example Summary

Once a summary is displayed, you can start chatting with the agent and ask questions about the document. Here are some examples:

Example QA

Note that the agent does have memory about recent questions. In the follow-up question above, I asked if there are any alternatives to it, and the agent knew what Imeant by "it" (using Python classes).

How it Works ⚙️

Show details

Here's the list of tools used to develop this app:

Tools used

Streamlit LangChain FAISS OpenAI

The text from the document is loaded and summarized using LangChain.

Then the document is divided into multiple chunks, each of which are passed to OpenAI API to create embeddings. These embeddings are stored in a local vector database using FAISS.

When you ask a question, the question text gets converted into an embedding vector, which is then compared with all vectors that are available in the vector database. The most appropriate chunk of text is returned and passed on to OpenAI API as context for the question.

Please note that the app uses gpt-3.5-turbo-16k from OpenAI. You can change this, and some other settings in config.py.

Potential Improvements 💡

Show details

Here are some improvements that can enhance the functionality or utility of this app:

  1. Allow users to upload PDF document as well. Currently, the app only accepts URL links as inputs.
  2. Instead of typing their questions, allow the users to ask their question by using voice (microphone).
  3. Include some error handling.

Sources 🔎

Show sources

LLM Chain Documentation: Agent with Memory

Streamlit Tutorial: Build Conversational App

About

Document Summarizer and QA Agent

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published