diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine index 741e6fb..c647b80 100644 --- a/docker/Dockerfile.alpine +++ b/docker/Dockerfile.alpine @@ -3,7 +3,7 @@ FROM python:3.7.9-alpine LABEL maintainer="foo@bar.com" ARG TZ='Asia/Shanghai' -ARG CHATGPT_ON_WECHAT_VER=1.0.0 +ARG CHATGPT_ON_WECHAT_VER=1.0.2 ENV BUILD_PREFIX=/app \ BUILD_OPEN_AI_API_KEY='YOUR OPEN AI KEY HERE' @@ -12,7 +12,11 @@ RUN apk add --no-cache \ bash \ curl \ wget \ - openssh + gcc \ + g++ \ + ca-certificates \ + openssh \ + libffi-dev RUN wget -t 3 -T 30 -nv -O chatgpt-on-wechat-${CHATGPT_ON_WECHAT_VER}.tar.gz \ https://github.com/zhayujie/chatgpt-on-wechat/archive/refs/tags/${CHATGPT_ON_WECHAT_VER}.tar.gz \ @@ -26,9 +30,11 @@ RUN cd ${BUILD_PREFIX} \ && cp config-template.json ${BUILD_PREFIX}/config.json \ && sed -i "2s/YOUR API KEY/${BUILD_OPEN_AI_API_KEY}/" ${BUILD_PREFIX}/config.json -RUN /usr/local/bin/python -m pip install --upgrade pip \ - && pip install itchat-uos==1.5.0.dev0 \ - && pip install --upgrade openai +RUN /usr/local/bin/python -m pip install --no-cache --upgrade pip \ + && pip install --no-cache \ + itchat-uos==1.5.0.dev0 \ + openai \ + wechaty ADD ./entrypoint.sh /entrypoint.sh diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian index c808b42..1d4ff51 100644 --- a/docker/Dockerfile.debian +++ b/docker/Dockerfile.debian @@ -3,7 +3,7 @@ FROM python:3.7.9 LABEL maintainer="foo@bar.com" ARG TZ='Asia/Shanghai' -ARG CHATGPT_ON_WECHAT_VER=1.0.0 +ARG CHATGPT_ON_WECHAT_VER=1.0.2 ENV BUILD_PREFIX=/app \ BUILD_OPEN_AI_API_KEY='YOUR OPEN AI KEY HERE' @@ -26,9 +26,11 @@ RUN cd ${BUILD_PREFIX} \ && cp config-template.json ${BUILD_PREFIX}/config.json \ && sed -i "2s/YOUR API KEY/${BUILD_OPEN_AI_API_KEY}/" ${BUILD_PREFIX}/config.json -RUN /usr/local/bin/python -m pip install --upgrade pip \ - && pip install itchat-uos==1.5.0.dev0 \ - && pip install --upgrade openai +RUN /usr/local/bin/python -m pip install --no-cache --upgrade pip \ + && pip install --no-cache \ + itchat-uos==1.5.0.dev0 \ + openai \ + wechaty ADD ./entrypoint.sh /entrypoint.sh diff --git a/docker/build.alpine.sh b/docker/build.alpine.sh index a5bacab..6fda600 100644 --- a/docker/build.alpine.sh +++ b/docker/build.alpine.sh @@ -1,5 +1,10 @@ #!/bin/bash +CHATGPT_ON_WECHAT_TAG=1.0.2 + docker build -f Dockerfile.alpine \ - --build-arg CHATGPT_ON_WECHAT_VER=1.0.0\ - -t zhayujie/chatgpt-on-wechat:1.0.0-alpine . \ No newline at end of file + --build-arg CHATGPT_ON_WECHAT_VER=$CHATGPT_ON_WECHAT_TAG \ + -t zhayujie/chatgpt-on-wechat . + +docker tag zhayujie/chatgpt-on-wechat zhayujie/chatgpt-on-wechat:$CHATGPT_ON_WECHAT_TAG-alpine + \ No newline at end of file diff --git a/docker/build.debian.sh b/docker/build.debian.sh index 91a7575..a5285f3 100644 --- a/docker/build.debian.sh +++ b/docker/build.debian.sh @@ -1,5 +1,9 @@ #!/bin/bash +CHATGPT_ON_WECHAT_TAG=1.0.2 + docker build -f Dockerfile.debian \ - --build-arg CHATGPT_ON_WECHAT_VER=1.0.0\ - -t zhayujie/chatgpt-on-wechat:1.0.0-debian . \ No newline at end of file + --build-arg CHATGPT_ON_WECHAT_VER=$CHATGPT_ON_WECHAT_TAG \ + -t zhayujie/chatgpt-on-wechat . + +docker tag zhayujie/chatgpt-on-wechat zhayujie/chatgpt-on-wechat:$CHATGPT_ON_WECHAT_TAG-debian \ No newline at end of file diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index cdde5c3..78d8a5c 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -4,14 +4,15 @@ services: build: context: ./ dockerfile: Dockerfile.alpine - image: zhayujie/chatgpt-on-wechat:1.0.0-alpine + image: zhayujie/chatgpt-on-wechat container_name: sample-chatgpt-on-wechat environment: 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"]' + WECHATY_PUPPET_SERVICE_TOKEN: 'WECHATY PUPPET SERVICE TOKEN' + 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训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。' \ No newline at end of file + CHARACTER_DESC: '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。' \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index d7923a8..214ca86 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -22,7 +22,7 @@ if [ "$CHATGPT_ON_WECHAT_PREFIX" == "" ] ; then CHATGPT_ON_WECHAT_PREFIX=/app fi -# APP_PREFIX is empty, use '/app/config.json' +# CHATGPT_ON_WECHAT_CONFIG_PATH 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 @@ -39,32 +39,38 @@ else echo -e "\033[31m[Warning] You need to set OPEN_AI_API_KEY before running!\033[0m" fi +if [ "$WECHATY_PUPPET_SERVICE_TOKEN" != "" ] ; then + sed -i "3c \"wechaty_puppet_service_token\": \"$WECHATY_PUPPET_SERVICE_TOKEN\"," $CHATGPT_ON_WECHAT_CONFIG_PATH +else + echo -e "\033[31m[Info] You need to set WECHATY_PUPPET_SERVICE_TOKEN if you use wechaty!\033[0m" +fi + if [ "$SINGLE_CHAT_PREFIX" != "" ] ; then - sed -i "3c \"single_chat_prefix\": $SINGLE_CHAT_PREFIX," $CHATGPT_ON_WECHAT_CONFIG_PATH + sed -i "4c \"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 + sed -i "5c \"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 + sed -i "6c \"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 + sed -i "7c \"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 + sed -i "8c \"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 + sed -i "9c \"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 + sed -i "10c \"character_desc\": \"$CHARACTER_DESC\"" $CHATGPT_ON_WECHAT_CONFIG_PATH fi # go to prefix dir diff --git a/docker/sample-chatgpt-on-wechat/.env b/docker/sample-chatgpt-on-wechat/.env index 33395ee..995a7f3 100644 --- a/docker/sample-chatgpt-on-wechat/.env +++ b/docker/sample-chatgpt-on-wechat/.env @@ -1,11 +1,12 @@ 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"] +WECHATY_PUPPET_SERVICE_TOKEN=WECHATY PUPPET SERVICE TOKEN +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训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。 +CHARACTER_DESC=你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。 # Optional #CHATGPT_ON_WECHAT_PREFIX=/app diff --git a/docker/sample-chatgpt-on-wechat/Name b/docker/sample-chatgpt-on-wechat/Name index 3124be0..47a5dd5 100644 --- a/docker/sample-chatgpt-on-wechat/Name +++ b/docker/sample-chatgpt-on-wechat/Name @@ -1 +1 @@ -zhayujie/chatgpt-on-wechat:1.0.0-alpine +zhayujie/chatgpt-on-wechat