Coder Social home page Coder Social logo

mrsstax's Introduction

QA Slack Bot - MrsStax

Introduction

This application is a Slack Bot that uses Langchain and OpenAI's GPT3 language model to provide domain specific answers. You provide the documents.

This app includes the OpenStax textbook "Principles of Macroeconomics 3e" for demonstration purposes.

Principles of Macroeconomics 3e is licensed under a Creative Commons Attribution 4.0 International (CC BY) license, which means that you can distribute, remix, and build upon the content, as long as you provide attribution to OpenStax and its content contributors.

Features

  • GPT3 based Slack Bot using your own documents (PDF or docx) for added context and increased accuracy.
  • Utilizes a local vector database (FAISS-CPU)

Usage

To use the MrsStax Slack Bot, the following environment variables need to be set in your .env file:

  • SLACK_BOT_TOKEN: Token for the Slack Bot.
  • SLACK_APP_TOKEN: Token for the Slack app.
  • OPENAI_API_TOKEN: Token for OpenAi

Installation

Requires Python3.10 or higher

Clone this repo and run the following commands

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp env.example .env
  1. Set your OPENAI_API_TOKEN in the .env file.

  2. Create new Slack App - https://api.slack.com

  3. Click on "Basic Information"

    • Click on "Generate Token and Scopes"

      • Token Name = "App Token"
      • App Scope = "connections:write"
    • Copy "App Token" and paste it into your .env file as "SLACK_APP_TOKEN".

  4. Click on "Socket Mode"

    • Click on "Enable"
  5. Click on "OAuth & Permissions" and add the following permissions.

    • app_mentions:read

    • chat:write

    • chat:write.public

    • im:history

    • Copy "Bot User OAuth Token" and paste it into your .env file as "SLACK_BOT_TOKEN".

  6. Click on "App Home" and make sure "Messages Tab" is enabled and check the box for "Allow users to send Slash commands and messages from the messages tab".

  7. Click on "Event Subscriptions" and enable it. Click on "Subscribe to bot events" and add "message.im"

  8. Install App into your Slack.

  9. Upload or copy your .pdf or .docx files to the "docs" folder.

  10. Run the following commands.

python ingest.py
python app.py
  1. Visit your Slack and send direct message to your bot.

If you left the two original files (Macroeconomics3e-WEB.pdf, pdf1.txt) in your docs directory you should be able to ask your bot economics related questions. For example.

  • Q1. Residents of the town of Smithfield like to consume hams, but each ham requires 10 people to produce it and takes a month. If the town has a total of 100 people, what is the maximum amount of ham the residents can consume in a month?

  • Q2. Why might Belgium, France, Italy, and Sweden have a higher export to GDP ratio than the United States?

  • Q3. What is dumping? Why does prohibiting it often work better in theory than in practice?

  1. Your vector database needs to be re-indexed each time you add or remove documents from your docs folder. To do this simply run python ingest.py.

mrsstax's People

Contributors

lightninginabox avatar marutiborker avatar normandmickey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mrsstax's Issues

No response after run app.py

Hi There!

Thanks for the cool project! I set up a slack bot and finished all steps until step 10. However, my slack bot doesn't response me at all. Any way I may try to debug?

image

Thanks, Rachel

Rate limit error

A have an rate limit error when ingesting:
'errors': {'error': [{'message': 'update vector: failed with status: 429%!!(MISSING)(EXTRA string=Rate limit reached for default-global-with-image-limits in organization org-m63Ws2YtNTuk2VHj5iRVQ7kp on requests per min. Limit: 60 / min. Please try again in 1s. Contact [email protected] if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit https://platform.openai.com/account/billing to add a payment method.)'}]}}

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.