forked from zhayujie/chatgpt-on-wechat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request zhayujie#223 from limccn/master
feat: use entrypoint.sh override environment variables
- Loading branch information
Showing
8 changed files
with
116 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#!/bin/bash | ||
|
||
docker build -f Dockerfile.alpine \ | ||
--build-arg CHATGPT_ON_WECHAT_VER=1.0.0\ | ||
-t zhayujie/chatgpt-on-wechat:1.0.0-alpine . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#!/bin/bash | ||
|
||
docker build -f Dockerfile.debian \ | ||
--build-arg CHATGPT_ON_WECHAT_VER=1.0.0\ | ||
-t zhayujie/chatgpt-on-wechat:1.0.0-debian . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# build prefix | ||
CHATGPT_ON_WECHAT_PREFIX=${CHATGPT_ON_WECHAT_PREFIX:-""} | ||
# path to config.json | ||
CHATGPT_ON_WECHAT_CONFIG_PATH=${CHATGPT_ON_WECHAT_CONFIG_PATH:-""} | ||
# execution command line | ||
CHATGPT_ON_WECHAT_EXEC=${CHATGPT_ON_WECHAT_EXEC:-""} | ||
|
||
OPEN_AI_API_KEY=${OPEN_AI_API_KEY:-""} | ||
SINGLE_CHAT_PREFIX=${SINGLE_CHAT_PREFIX:-""} | ||
SINGLE_CHAT_REPLY_PREFIX=${SINGLE_CHAT_REPLY_PREFIX:-""} | ||
GROUP_CHAT_PREFIX=${GROUP_CHAT_PREFIX:-""} | ||
GROUP_NAME_WHITE_LIST=${GROUP_NAME_WHITE_LIST:-""} | ||
IMAGE_CREATE_PREFIX=${IMAGE_CREATE_PREFIX:-""} | ||
CONVERSATION_MAX_TOKENS=${CONVERSATION_MAX_TOKENS:-""} | ||
CHARACTER_DESC=${CHARACTER_DESC:-""} | ||
|
||
# CHATGPT_ON_WECHAT_PREFIX is empty, use /app | ||
if [ "$CHATGPT_ON_WECHAT_PREFIX" == "" ] ; then | ||
CHATGPT_ON_WECHAT_PREFIX=/app | ||
fi | ||
|
||
# APP_PREFIX is empty, use '/app/config.json' | ||
if [ "$CHATGPT_ON_WECHAT_CONFIG_PATH" == "" ] ; then | ||
CHATGPT_ON_WECHAT_CONFIG_PATH=$CHATGPT_ON_WECHAT_PREFIX/config.json | ||
fi | ||
|
||
# CHATGPT_ON_WECHAT_EXEC is empty, use ‘python app.py’ | ||
if [ "$CHATGPT_ON_WECHAT_EXEC" == "" ] ; then | ||
CHATGPT_ON_WECHAT_EXEC="python app.py" | ||
fi | ||
|
||
# modify content in config.json | ||
if [ "$OPEN_AI_API_KEY" != "" ] ; then | ||
sed -i "2c \"open_ai_api_key\": \"$OPEN_AI_API_KEY\"," $CHATGPT_ON_WECHAT_CONFIG_PATH | ||
else | ||
echo -e "\033[31m[Warning] You need to set OPEN_AI_API_KEY before running!\033[0m" | ||
fi | ||
|
||
if [ "$SINGLE_CHAT_PREFIX" != "" ] ; then | ||
sed -i "3c \"single_chat_prefix\": $SINGLE_CHAT_PREFIX," $CHATGPT_ON_WECHAT_CONFIG_PATH | ||
fi | ||
|
||
if [ "$SINGLE_CHAT_REPLY_PREFIX" != "" ] ; then | ||
sed -i "4c \"single_chat_reply_prefix\": $SINGLE_CHAT_REPLY_PREFIX," $CHATGPT_ON_WECHAT_CONFIG_PATH | ||
fi | ||
|
||
if [ "$GROUP_CHAT_PREFIX" != "" ] ; then | ||
sed -i "5c \"group_chat_prefix\": $GROUP_CHAT_PREFIX," $CHATGPT_ON_WECHAT_CONFIG_PATH | ||
fi | ||
|
||
if [ "$GROUP_NAME_WHITE_LIST" != "" ] ; then | ||
sed -i "6c \"group_name_white_list\": $GROUP_NAME_WHITE_LIST," $CHATGPT_ON_WECHAT_CONFIG_PATH | ||
fi | ||
|
||
if [ "$IMAGE_CREATE_PREFIX" != "" ] ; then | ||
sed -i "7c \"image_create_prefix\": $IMAGE_CREATE_PREFIX," $CHATGPT_ON_WECHAT_CONFIG_PATH | ||
fi | ||
|
||
if [ "$CONVERSATION_MAX_TOKENS" != "" ] ; then | ||
sed -i "8c \"conversation_max_tokens\": $CONVERSATION_MAX_TOKENS," $CHATGPT_ON_WECHAT_CONFIG_PATH | ||
fi | ||
|
||
if [ "$CHARACTER_DESC" != "" ] ; then | ||
sed -i "9c \"character_desc\": \"$CHARACTER_DESC\"" $CHATGPT_ON_WECHAT_CONFIG_PATH | ||
fi | ||
|
||
# go to prefix dir | ||
cd $CHATGPT_ON_WECHAT_PREFIX | ||
# excute | ||
$CHATGPT_ON_WECHAT_EXEC | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
OPEN_AI_API_KEY=YOUR API KEY | ||
SINGLE_CHAT_PREFIX=["BOT", "@BOT"] | ||
SINGLE_CHAT_REPLY_PREFIX="[BOT] " | ||
GROUP_CHAT_PREFIX=["@BOT"] | ||
GROUP_NAME_WHITE_LIST=["CHATGPT测试群", "CHATGPT测试群2"] | ||
IMAGE_CREATE_PREFIX=["画", "看", "找"] | ||
CONVERSATION_MAX_TOKENS=1000 | ||
CHARACTER_DESC=你是CHATGPT, 一个由OPENAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。 | ||
|
||
# Optional | ||
#CHATGPT_ON_WECHAT_PREFIX=/app | ||
#CHATGPT_ON_WECHAT_CONFIG_PATH=/app/config.json | ||
#CHATGPT_ON_WECHAT_EXEC=python app.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters