Code Monkey home page Code Monkey logo

chatgpt-slackbot's Introduction

ChatGPT Slackbot

Slackを通じて会話人工知能のChatGPTを利用するためのBOTスクリプト。
会話の履歴数はデフォルトでは10個前まで参照。ユーザーごと、チャンネルごとに異なる履歴を保持する。 環境構築にはOpenAIのAPIトークン及びSlackのBoltのアプリケーショントークンが必要。

ボットの使い方

  • AIとの会話: !gpt [会話内容]
  • AIとの会話の履歴をリセット: !gpt-rs
  • 使い方を表示: !gpt-help

セッションの概念はないが、API側には不正行為検出のためにSlack上のユーザーIDを渡している。

環境構築

OpenAIのAPI Token(SECRET KEY)とOrganazation IDを取得。

OpenAI API Keysにアクセスしてアカウント作成の後、SECRET KEYとOrganization IDを取得。

Slack Botのトークンの用意

Bolt 入門ガイドに準拠。

  • SLACK_BOT_TOKEN
  • SLACK_APP_TOKEN

を取得しておく。

SLACK_BOT_TOKENで要求するスコープ

  • chat:write

Event SubscriptionsのSubscribe to Bot Events で要求するスコープ

  • message.channels
  • message.groups
  • message.im
  • message.mpim

インストール方法

Python3.9.6以上で動作を確認済み。

.env ファイルを実行フォルダ内に作成して、自分のクレデンシャル情報を記述

ORGANAZTION_ID=org-xxxxxxxxxxxxxxxxx
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxx
SLACK_BOT_TOKEN=xoxb-9999999
SLACK_APP_TOKEN=xapp-9999999-9999999
NAME_SUFFIX=-main

NAME_SUFFIXは複数、Dockerコンテナを起動する際にコンテナ名がかぶらないようにするためのサフィックス。

あとは以下を実行してイメージをビルド&実行。

docker compose --env-file ./opt/.env up -d --build

以上で起動。

docker compose --env-file ./opt/.env down

で停止。

docker compose logs

でログ確認。

LICNESE

MIT

chatgpt-slackbot's People

Contributors

sifue 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.