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/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 diff --git a/scripts/shutdown.sh b/scripts/shutdown.sh new file mode 100755 index 0000000..c2bf6b1 --- /dev/null +++ b/scripts/shutdown.sh @@ -0,0 +1,16 @@ +#!/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 + 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/scripts/start.sh b/scripts/start.sh new file mode 100755 index 0000000..ac92f88 --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,16 @@ +#!/bin/bash +#后台运行Chat_on_webchat执行脚本 + +cd `dirname $0`/.. +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/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"