您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

entrypoint.sh 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. OPEN_AI_API_KEY=${OPEN_AI_API_KEY:-""}
  10. SINGLE_CHAT_PREFIX=${SINGLE_CHAT_PREFIX:-""}
  11. SINGLE_CHAT_REPLY_PREFIX=${SINGLE_CHAT_REPLY_PREFIX:-""}
  12. GROUP_CHAT_PREFIX=${GROUP_CHAT_PREFIX:-""}
  13. GROUP_NAME_WHITE_LIST=${GROUP_NAME_WHITE_LIST:-""}
  14. IMAGE_CREATE_PREFIX=${IMAGE_CREATE_PREFIX:-""}
  15. CONVERSATION_MAX_TOKENS=${CONVERSATION_MAX_TOKENS:-""}
  16. CHARACTER_DESC=${CHARACTER_DESC:-""}
  17. # CHATGPT_ON_WECHAT_PREFIX is empty, use /app
  18. if [ "$CHATGPT_ON_WECHAT_PREFIX" == "" ] ; then
  19. CHATGPT_ON_WECHAT_PREFIX=/app
  20. fi
  21. # APP_PREFIX is empty, use '/app/config.json'
  22. if [ "$CHATGPT_ON_WECHAT_CONFIG_PATH" == "" ] ; then
  23. CHATGPT_ON_WECHAT_CONFIG_PATH=$CHATGPT_ON_WECHAT_PREFIX/config.json
  24. fi
  25. # CHATGPT_ON_WECHAT_EXEC is empty, use ‘python app.py’
  26. if [ "$CHATGPT_ON_WECHAT_EXEC" == "" ] ; then
  27. CHATGPT_ON_WECHAT_EXEC="python app.py"
  28. fi
  29. # modify content in config.json
  30. if [ "$OPEN_AI_API_KEY" != "" ] ; then
  31. sed -i "2c \"open_ai_api_key\": \"$OPEN_AI_API_KEY\"," $CHATGPT_ON_WECHAT_CONFIG_PATH
  32. else
  33. echo -e "\033[31m[Warning] You need to set OPEN_AI_API_KEY before running!\033[0m"
  34. fi
  35. if [ "$SINGLE_CHAT_PREFIX" != "" ] ; then
  36. sed -i "3c \"single_chat_prefix\": $SINGLE_CHAT_PREFIX," $CHATGPT_ON_WECHAT_CONFIG_PATH
  37. fi
  38. if [ "$SINGLE_CHAT_REPLY_PREFIX" != "" ] ; then
  39. sed -i "4c \"single_chat_reply_prefix\": $SINGLE_CHAT_REPLY_PREFIX," $CHATGPT_ON_WECHAT_CONFIG_PATH
  40. fi
  41. if [ "$GROUP_CHAT_PREFIX" != "" ] ; then
  42. sed -i "5c \"group_chat_prefix\": $GROUP_CHAT_PREFIX," $CHATGPT_ON_WECHAT_CONFIG_PATH
  43. fi
  44. if [ "$GROUP_NAME_WHITE_LIST" != "" ] ; then
  45. sed -i "6c \"group_name_white_list\": $GROUP_NAME_WHITE_LIST," $CHATGPT_ON_WECHAT_CONFIG_PATH
  46. fi
  47. if [ "$IMAGE_CREATE_PREFIX" != "" ] ; then
  48. sed -i "7c \"image_create_prefix\": $IMAGE_CREATE_PREFIX," $CHATGPT_ON_WECHAT_CONFIG_PATH
  49. fi
  50. if [ "$CONVERSATION_MAX_TOKENS" != "" ] ; then
  51. sed -i "8c \"conversation_max_tokens\": $CONVERSATION_MAX_TOKENS," $CHATGPT_ON_WECHAT_CONFIG_PATH
  52. fi
  53. if [ "$CHARACTER_DESC" != "" ] ; then
  54. sed -i "9c \"character_desc\": \"$CHARACTER_DESC\"" $CHATGPT_ON_WECHAT_CONFIG_PATH
  55. fi
  56. # go to prefix dir
  57. cd $CHATGPT_ON_WECHAT_PREFIX
  58. # excute
  59. $CHATGPT_ON_WECHAT_EXEC