Giter Site home page Giter Site logo

chatbot-scalevp's Introduction

Simple Chatbot

A chatbot with minimal dependencies.

Objectives

  • This project demonstrates how to build a chatbot for small datasets with minimal dependencies.
  • It is released with the dataset and web UI that power the chat for Scale Venture Partners.
  • It can be easily (and freely) customized for any organization.

How it works

The chatbot implements a basic agent that integrates with a local vector database and OpenAI models.

Chatbot architecture

Read more about the background, architecture and learnings in the release announcement on our blog.

How to use it

Docker (recommended)

  1. Set your OpenAI API key in the OPENAI_API_KEY environment variable: export OPENAI_API_KEY=your_openai_api_key
  2. Clone the repository: git clone https://github.com/jvrdnd/chatbot.git
  3. Navigate to the repository: cd chatbot
  4. Start the chatbot: docker compose up --build
  5. Go to 127.0.0.1 in your browser
  6. Start asking questions!

Local

  1. Set the OPENAI_API_KEY environment variable to your OpenAI API key: export OPENAI_API_KEY=your_openai_api_key
  2. Clone the repository: git clone https://github.com/jvrdnd/chatbot.git
  3. Navigate to the repository: cd chatbot
  4. Set the INDEX_PATH environment variable to a directory in which you have write permissions: export INDEX_PATH=your_path
  5. Install the dependencies: pip install -r api/src/requirements.txt
  6. Run the job that populates the vector database: python job/src/main.py
  7. Start the API: uwsgi --http :9090 --wsgi-file api/src/app.py --gevent 100
  8. Open the file ui/src/index.html in your browser
  9. Start asking questions!

How to customize it

Data

The documents that go into the vector database are generated from job/src/data.json following the job/src/schema.json specification. Customizing these files will enable the chatbot to answer questions about your data.

data.json and schema.json have matching top-level attributes which define document sections. For example, in the case of the Scale chatbot, the sections mirror those on our website because that is the source of our data.

Each section contains a list of documents, each of which is represented by a series of attributes captured in data.json. Using schema.json, this structured data is encoded into plain text documents that can be turned into embeddings. Each document is encoded as follows:

  • The first line shows the name of the current section (specified in the heading attribute of the schema), as well as the values of select attributes of the data (whose key is specified in the context attribute of the schema).
  • For every attribute that is not part of the context, a page is created. An optional descriptor for the page contents can be shown on the second line of the document if it is specifed in the descriptors attribute of the schema.

data.json and schema.json in this repository provide a comprehensive example of how to construct your own data files.

Web UI

The web UI implements server-sent events (SSE) to support streaming responses from the LLM. It can be fully customized by making changes to the files in ui/src/.

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.