From 0b802a61ecb33ee97e486b2e23c0b927d2765485 Mon Sep 17 00:00:00 2001 From: zwssunny Date: Mon, 27 Feb 2023 22:24:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E6=89=A7=E8=A1=8C=E8=84=9A=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + shutdown.sh | 16 ++++++++++++++++ start.sh | 15 +++++++++++++++ tout.sh | 7 +++++++ 4 files changed, 39 insertions(+) create mode 100755 shutdown.sh create mode 100755 start.sh create mode 100755 tout.sh diff --git a/.gitignore b/.gitignore index a9f6f68..c587458 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ venv* *.pyc config.json QR.png +nohub.out \ No newline at end of file diff --git a/shutdown.sh b/shutdown.sh new file mode 100755 index 0000000..bf3a476 --- /dev/null +++ b/shutdown.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +#关闭服务 + +export BASE_DIR=`pwd` +pid=`ps ax | grep -i app.py | grep "${BASE_DIR}" | grep python3 | grep -v grep | awk '{print $1}'` +if [ -z "$pid" ] ; then + echo "No chatgpt-on-wechat running." + exit -1; +fi + +echo "The chatgpt-on-wechat(${pid}) is running..." + +kill ${pid} + +echo "Send shutdown request to chatgpt-on-wechat(${pid}) OK" diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..8a0dc15 --- /dev/null +++ b/start.sh @@ -0,0 +1,15 @@ +#!/bin/bash +#后台运行Chat_on_webchat执行脚本 + +export BASE_DIR=`pwd` +echo $BASE_DIR + +# check the nohup.out log output file +if [ ! -f "${BASE_DIR}/nohup.out" ]; then + touch "${BASE_DIR}/nohup.out" +echo "create file ${BASE_DIR}/nohup.out" +fi + +nohup python3 "${BASE_DIR}/app.py" & tail -f "${BASE_DIR}/nohup.out" + +echo "Chat_on_webchat is starting,you can check the ${BASE_DIR}/nohup.out" diff --git a/tout.sh b/tout.sh new file mode 100755 index 0000000..296d963 --- /dev/null +++ b/tout.sh @@ -0,0 +1,7 @@ +#!/bin/bash +#打开日志 + +export BASE_DIR=`pwd` +echo $BASE_DIR + +tail -f "${BASE_DIR}/nohup.out" From b81d947dbbcdc28c191b45882fca4186667b53b0 Mon Sep 17 00:00:00 2001 From: zwssunny Date: Mon, 27 Feb 2023 22:33:31 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0#=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E6=89=80=E6=9C=89=E4=BA=BA=E8=AE=B0=E5=BF=86=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot/openai/open_ai_bot.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bot/openai/open_ai_bot.py b/bot/openai/open_ai_bot.py index 4c48c52..9eeb3c9 100644 --- a/bot/openai/open_ai_bot.py +++ b/bot/openai/open_ai_bot.py @@ -22,6 +22,9 @@ class OpenAIBot(Bot): if query == '#清除记忆': Session.clear_session(from_user_id) return '记忆已清除' + elif query == '#清除所有': + Session.clear_all_session() + return '所有人记忆已清除' new_query = Session.build_session_query(query, from_user_id) logger.debug("[OPEN_AI] session query={}".format(new_query)) @@ -157,3 +160,7 @@ class Session(object): @staticmethod def clear_session(user_id): user_session[user_id] = [] + + @staticmethod + def clear_all_session(): + user_session.clear() \ No newline at end of file From 8729a31119a4b4c516803c41f3971c0da3d9643f Mon Sep 17 00:00:00 2001 From: zwssunny Date: Tue, 28 Feb 2023 08:46:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=9B=E5=BB=BAscripts=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=EF=BC=8C=E4=B8=93=E9=97=A8=E6=94=BE=E8=B0=83=E7=94=A8=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shutdown.sh => scripts/shutdown.sh | 2 +- start.sh => scripts/start.sh | 1 + scripts/tout.sh | 14 ++++++++++++++ tout.sh | 7 ------- 4 files changed, 16 insertions(+), 8 deletions(-) rename shutdown.sh => scripts/shutdown.sh (95%) rename start.sh => scripts/start.sh (95%) create mode 100755 scripts/tout.sh delete mode 100755 tout.sh diff --git a/shutdown.sh b/scripts/shutdown.sh similarity index 95% rename from shutdown.sh rename to scripts/shutdown.sh index bf3a476..c2bf6b1 100755 --- a/shutdown.sh +++ b/scripts/shutdown.sh @@ -1,7 +1,7 @@ #!/bin/bash #关闭服务 - +cd `dirname $0`/.. export BASE_DIR=`pwd` pid=`ps ax | grep -i app.py | grep "${BASE_DIR}" | grep python3 | grep -v grep | awk '{print $1}'` if [ -z "$pid" ] ; then diff --git a/start.sh b/scripts/start.sh similarity index 95% rename from start.sh rename to scripts/start.sh index 8a0dc15..ac92f88 100755 --- a/start.sh +++ b/scripts/start.sh @@ -1,6 +1,7 @@ #!/bin/bash #后台运行Chat_on_webchat执行脚本 +cd `dirname $0`/.. export BASE_DIR=`pwd` echo $BASE_DIR diff --git a/scripts/tout.sh b/scripts/tout.sh new file mode 100755 index 0000000..5b71491 --- /dev/null +++ b/scripts/tout.sh @@ -0,0 +1,14 @@ +#!/bin/bash +#打开日志 + +cd `dirname $0`/.. +export BASE_DIR=`pwd` +echo $BASE_DIR + +# check the nohup.out log output file +if [ ! -f "${BASE_DIR}/nohup.out" ]; then + echo "No file ${BASE_DIR}/nohup.out" + exit -1; +fi + +tail -f "${BASE_DIR}/nohup.out" diff --git a/tout.sh b/tout.sh deleted file mode 100755 index 296d963..0000000 --- a/tout.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -#打开日志 - -export BASE_DIR=`pwd` -echo $BASE_DIR - -tail -f "${BASE_DIR}/nohup.out"