Git Product home page Git Product logo

multi-doc-chatbot's Introduction

Multi Document Reader and Chatbot using LangChain and OpenAI

[Updated January 2024 to work with LangChain v0.1.0]

Summary

Provided here are a few python scripts to help get started with building your own multi document reader and chatbot. The scripts increase in complexity and features, as follows:

single-doc.py Can handle interacting with a single pdf. Sends the entire document content to the LLM prompt.

single-long-doc.py Can handle interacting with a long single pdf. Uses embeddings and a vector store to handle sending only relevant information to the LLM prompts.

multi-doc-chatbot.py Can handle interacting with multiple different documents and document types (.pdf, .dox, .txt), and remembers the chat history and recent conversations. It uses embeddings and vector stores to send the relevant information to the LLM prompt. Also provides a chat interface via the terminal using stdin and stdout. Press q to escape the chat window.

I wrote an article which explores some of the concepts here, as well as walks through building each of the scripts. Can read that here

Getting started

Clone the repository, set up the virtual environment, and install the required packages

git clone [email protected]:smaameri/multi-doc-chatbot.git
cd multi-doc-chatbot
python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt

Store your OpenAI API key

Copy the example env file

cp .env.example .env

Now copy your OpenAI API key into the .env file, and save the file. It should send up looking something like

OPENAI_API_KEY=sk-

Start chatting

Kick of the multi-doc chatbot, and start interacting with your files. Place any files you would like to interact with inside the /docs folder. Enter q to exit the prompt at any time.

python3 multi-doc-chatbot.py

It's not perfect, and it does give strange answers sometimes, but it does get a basic setup running. It does show that getting a basic Q&A chain working is not enough to create a really good chatbot. To get that working, you will need to dig deeper and explore the concepts and ideas in more detail. Possibilities could include optimising the prompt templates, using different LLMs which can accept more tokens and context lengths, creating an agent to refine the results, and whatever else you can think of ๐Ÿ™‚

Screenshot 2023-05-20 at 12.06.43 PM.png

multi-doc-chatbot's People

Contributors

samimaameri avatar smaameri avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.