Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ChatGPT in SlackでAI Slackbotを楽しく運用する

September 13, 2023

ChatGPT in SlackでAI Slackbotを楽しく運用する



September 13, 2023

More Decks by iwamot

Other Decks in Technology


  1. ローカル環境・Amazon EC2等 # Create an app-level token with connections:write scope

    export SLACK_APP_TOKEN=xapp-1-... # Install the app into your workspace to grab this token export SLACK_BOT_TOKEN=xoxb-... # Visit https://platform.openai.com/account/api-keys for this token export OPENAI_API_KEY=sk-... (snip) python -m venv .venv source .venv/bin/activate pip install -r requirements.txt python main.py https://github.com/seratch/ChatGPT-in-Slack/blob/main/README.md
  2. Amazon ECS on AWS Fargate等 (Docker) FROM python:3.11.4-slim-buster as builder

    COPY requirements.txt /build/ WORKDIR /build/ RUN pip install -U pip && pip install -r requirements.txt FROM python:3.11.4-slim-buster as app WORKDIR /app/ COPY *.py /app/ RUN mkdir /app/app/ COPY app/*.py /app/app/ COPY --from=builder /usr/local/bin/ /usr/local/bin/ COPY --from=builder /usr/local/lib/ /usr/local/lib/ ENTRYPOINT python main.py https://github.com/seratch/ChatGPT-in-Slack/blob/main/Dockerfile
  3. AWS Lambda + Amazon API Gateway (Serverless Framework) frameworkVersion: '3'

    service: slack-chat-gpt-bot provider: name: aws runtime: python3.9 region: us-east-1 ... https://github.com/seratch/ChatGPT-in-Slack/blob/main/serverless.yml
  4. Azure OpenAIの利用 # To use Azure OpenAI, set the following

    optional environment variables according to your environment # default: None export OPENAI_API_TYPE=azure # default: https://api.openai.com/v1 export OPENAI_API_BASE=https://YOUR_RESOURCE_NAME.openai.azure.com # default: None export OPENAI_API_VERSION=2023-05-15 # default: None export OPENAI_DEPLOYMENT_ID=YOUR-DEPLOYMENT-ID https://github.com/seratch/ChatGPT-in-Slack/blob/main/README.md
  5. Function Calling(実験的機能) # Experimental: You can try out the Function

    Calling feature (default: None) export OPENAI_FUNCTION_CALL_MODULE_NAME=tests.function_call_example https://github.com/seratch/ChatGPT-in-Slack/blob/main/README.md