Skip to content

Commit

Permalink
Merge branch 'master' of github.com:zhayujie/chatgpt-on-wechat
Browse files Browse the repository at this point in the history
  • Loading branch information
zwssunny committed Feb 27, 2023
2 parents 0b802a6 + 02ca1f8 commit 999b2ea
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 33 deletions.
16 changes: 11 additions & 5 deletions docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM python:3.7.9-alpine
LABEL maintainer="[email protected]"
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'
Expand All @@ -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 \
Expand All @@ -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

Expand Down
10 changes: 6 additions & 4 deletions docker/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM python:3.7.9
LABEL maintainer="[email protected]"
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'
Expand All @@ -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

Expand Down
9 changes: 7 additions & 2 deletions docker/build.alpine.sh
Original file line number Diff line number Diff line change
@@ -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 .
--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

8 changes: 6 additions & 2 deletions docker/build.debian.sh
Original file line number Diff line number Diff line change
@@ -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 .
--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
13 changes: 7 additions & 6 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'
CHARACTER_DESC: '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'
22 changes: 14 additions & 8 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 6 additions & 5 deletions docker/sample-chatgpt-on-wechat/.env
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker/sample-chatgpt-on-wechat/Name
Original file line number Diff line number Diff line change
@@ -1 +1 @@
zhayujie/chatgpt-on-wechat:1.0.0-alpine
zhayujie/chatgpt-on-wechat

0 comments on commit 999b2ea

Please sign in to comment.