Sign inSign up

sheepgreen/chatgpt

By sheepgreen

Updated about 3 years ago

A Telegram bot that integrates with OpenAI's ChatGPT to provide answers with typing status support

Image
Machine learning & AI
4

10K+

sheepgreen/chatgpt repository overview

Main branch

n3d1117 is back! Use this.

Update

2023.3.2 Use official ChatGPT API

A branch for bot to interact with chatgpt official api ( comes with acheong08 )
Configuration

Customize the configuration by create a file named .env, then editing the settings as desired:

OPENAI_API_KEY="<YOUR_OPENAI_API_KEY>"
TELEGRAM_BOT_TOKEN="<YOUR_TELEGRAM_BOT_TOKEN>"
  • OPENAI_API_KEY: Your OpenAI api key. Steps to follow
  1. Create account on OpenAI
  2. Go to https://platform.openai.com/account/api-keys
  3. Copy API key

Additional optional configuration values:

OPENAI_MODEL="<ANY_MODEL_AVAILABLE_FROM_OPENAI>" # Defaults to "gpt-3.5-turbo"
Usage

Create a file named docker-compose.yml(same directory as .env)

services:
  chatgpt:
    image: sheepgreen/chatgpt
    container_name: chatgpt
    volumes:
      - ./.env:/home/appuser/.env
    restart: always

Then run docker-compose up -d,that's all!

Proxy branch

I found a great project which also based on n3d1117 and acheong08, thanks to his awesome job. You should use this instead of mine.

A branch for bot to interact with chatgpt official api ( comes with n3d1117 and acheong08 ), with showing typing status and streaming responses support

Configuration

Customize the configuration by create a file named .env, then editing the settings as desired (choose only one method ):

//method 1
OPENAI_EMAIL="<YOUR_OPENAI_EMAIL>"
OPENAI_PASSWORD="<YOUR_OPENAI_PASSWORD>"
//method 2
OPENAI_SESSION_TOKEN="<YOUR_OPENAI_SESSION_TOKEN>"
//method 3
OPENAI_ACCESS_TOKEN="<YOUR_OPENAI_ACCESS_TOKEN>"
//below is a must
TELEGRAM_BOT_TOKEN="<YOUR_TELEGRAM_BOT_TOKEN>"
  • OPENAI_EMAIL,OPENAI_PASSWORD: Your OpenAI credentials (these are only sent to the OpenAI server to periodically refresh the access token and never shared). You can read more about it here
  • OPENAI_SESSION_TOKEN: Follow steps below
  1. Go to https://chat.openai.com/chat and open the developer tools by F12.
  2. Find the __Secure-next-auth.session-token cookie in Application > Storage > Cookies > https://chat.openai.com.
  3. Copy the value in the Cookie Value field.

Additional optional (but recommended) configuration values:

ALLOWED_TELEGRAM_USER_IDS="<USER_ID_1>,<USER_ID_2>,..." # Defaults to "*"
PROXY="<HTTP/HTTPS_PROXY>" # E.g. "http://localhost:8080", defaults to none
USE_STREAM=false # Defaults to true
  • ALLOWED_TELEGRAM_USER_IDS: A comma-separated list of Telegram user IDs that are allowed to interact with the bot (use getidsbot to find your user ID). Important: by default, everyone is allowed (*)
  • PROXY: Proxy to be used when authenticating with OpenAI
  • USE_STREAM: Streams the response as the bot types. Set to false to only answer once the response is fully generated
Usage

Create a file named docker-compose.yml(same directory as .env)

services:
  chatgpt:
    image: sheepgreen/chatgpt:proxy
    container_name: chatgpt
#    environment:
#      - CHATGPT_BASE_URL=YOUR_PROXY_ENDPOINT(by default uses the author's, may have problems sometimes)
    volumes:
      - ./.env:/home/appuser/.env
    restart: always

Then run docker-compose up -d,that's all!

Tag summary

Content type

Image

Digest

sha256:8c8cf6a5b

Size

102.3 MB

Last updated

about 3 years ago

docker pull sheepgreen/chatgpt