123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. set -e
  3. # build prefix
  4. CHATGPT_ON_WECHAT_PREFIX=${CHATGPT_ON_WECHAT_PREFIX:-""}
  5. # path to config.json
  6. CHATGPT_ON_WECHAT_CONFIG_PATH=${CHATGPT_ON_WECHAT_CONFIG_PATH:-""}
  7. # execution command line
  8. CHATGPT_ON_WECHAT_EXEC=${CHATGPT_ON_WECHAT_EXEC:-""}
  9. # use environment variables to pass parameters
  10. # if you have not defined environment variables, set them below
  11. # export OPEN_AI_API_KEY=${OPEN_AI_API_KEY:-'YOUR API KEY'}
  12. # export OPEN_AI_PROXY=${OPEN_AI_PROXY:-""}
  13. # export SINGLE_CHAT_PREFIX=${SINGLE_CHAT_PREFIX:-'["bot", "@bot"]'}
  14. # export SINGLE_CHAT_REPLY_PREFIX=${SINGLE_CHAT_REPLY_PREFIX:-'"[bot] "'}
  15. # export GROUP_CHAT_PREFIX=${GROUP_CHAT_PREFIX:-'["@bot"]'}
  16. # export GROUP_NAME_WHITE_LIST=${GROUP_NAME_WHITE_LIST:-'["ChatGPT测试群", "ChatGPT测试群2"]'}
  17. # export IMAGE_CREATE_PREFIX=${IMAGE_CREATE_PREFIX:-'["画", "看", "找"]'}
  18. # export CONVERSATION_MAX_TOKENS=${CONVERSATION_MAX_TOKENS:-"1000"}
  19. # export SPEECH_RECOGNITION=${SPEECH_RECOGNITION:-"False"}
  20. # export CHARACTER_DESC=${CHARACTER_DESC:-"你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。"}
  21. # export EXPIRES_IN_SECONDS=${EXPIRES_IN_SECONDS:-"3600"}
  22. # CHATGPT_ON_WECHAT_PREFIX is empty, use /app
  23. if [ "$CHATGPT_ON_WECHAT_PREFIX" == "" ] ; then
  24. CHATGPT_ON_WECHAT_PREFIX=/app
  25. fi
  26. # CHATGPT_ON_WECHAT_CONFIG_PATH is empty, use '/app/config.json'
  27. if [ "$CHATGPT_ON_WECHAT_CONFIG_PATH" == "" ] ; then
  28. CHATGPT_ON_WECHAT_CONFIG_PATH=$CHATGPT_ON_WECHAT_PREFIX/config.json
  29. fi
  30. # CHATGPT_ON_WECHAT_EXEC is empty, use ‘python app.py’
  31. if [ "$CHATGPT_ON_WECHAT_EXEC" == "" ] ; then
  32. CHATGPT_ON_WECHAT_EXEC="python app.py"
  33. fi
  34. # modify content in config.json
  35. if [ "$OPEN_AI_API_KEY" == "YOUR API KEY" ] || [ "$OPEN_AI_API_KEY" == "" ]; then
  36. echo -e "\033[31m[Warning] You need to set OPEN_AI_API_KEY before running!\033[0m"
  37. fi
  38. # go to prefix dir
  39. cd $CHATGPT_ON_WECHAT_PREFIX
  40. # excute
  41. $CHATGPT_ON_WECHAT_EXEC