Chat with a pdf

Chat with pdf documents

ChatGPT is a powerful tool for interacting with text data and generating human-like responses to queries. Yet, you cannot directely upload multiple PDF documents (such as research articles) to ChatGPT interface. Using the OpenAI API and the Python library LangChain (https://python.langchain.com/en/latest/) makes it, however, possible to interact with multiple documents. This allows to quickly parse through multiple PDF documents, extract the relevant information, and provide responses in a fraction of the time it would take to read these documents.

To do that I have made a simple app that enables to chat with multiple pdf documents. The app is avialable here: https://benjolras-chat-with-pdf-app-gpt-app-bernard-enjolras-org-d7tmbe.streamlit.app/

To use this app you will need an OpenAI API-key.

Getting OpenAI API-key

The OpenAI API provides developers with access to state-of-the-art machine learning models, including GPT-3, that can be integrated into their applications to enhance their capabilities.

Here are the steps to get an OpenAI API key:

  • Create an OpenAI account: To get an API key, you need to create an account on the OpenAI website (https://www.openai.com/). Go to the OpenAI homepage and click on the “Sign up” button in the top right corner. Follow the instructions to create an account.

  • After signing up or logging in, navigate to the API section by clicking on “API” at the top of the page or by visiting (https://platform.openai.com/)

  • Get an API key: The key will be available in your OpenAI dashboard under the “API Keys” section. You can copy the key and use it in your code to access the API.

  • After selecting a plan, you will be provided with your unique API key. Make sure to keep it secure, as it grants access to the API with your account’s usage limits and privileges.

  • Start using the API: With your API key in hand, you can start using the OpenAI API in your applications. The OpenAI website provides comprehensive documentation and guides on how to use the API, including code examples for various programming languages.

  • It is essential to note that OpenAI limits the number of requests you can make to the API, depending on the plan you have signed up for. Make sure you understand the pricing plans and the usage limits before you start using the API.

Bernard Enjolras
Research Professor at The Institute for Social research in Oslo and the Director of the Center for Research on Civil Society and Voluntary Sector.

My research interests include volunteering, voluntary organizations, governance, social capital and trust, civic engagement as well as the digitization of the public sphere, social media and freedom of expression.