diff --git a/new-bing/Dockerfile b/new-bing/Dockerfile index d6369df..6ed2d80 100644 --- a/new-bing/Dockerfile +++ b/new-bing/Dockerfile @@ -2,7 +2,7 @@ FROM sanicframework/sanic:3.11-latest WORKDIR /sanic -COPY app.py EdgeGPT.py cookie.json cookie1.json cookie2.json requirements.txt /sanic/ +COPY app.py EdgeGPT.py requirements.txt /sanic/ RUN pip install -r requirements.txt diff --git a/new-bing/README.md b/new-bing/README.md index 13262c7..d60cd7e 100644 --- a/new-bing/README.md +++ b/new-bing/README.md @@ -1,3 +1,14 @@ [登录 bing 账号](https://login.live.com/), 使用[Cookie-Editor 扩展](https://chrome.google.com/webstore/detail/cookie-editor/hlkenndednhfkekhgcdicdfddnkalmdm)将 cookie 以 json 格式导出,保存为`cookie.json`文件,同时将`COOKIE_FILE`环境变量的值指向该文件。 +## 部署 + +``` +1.新建cookies目录,将cookie.json放入该目录,支持3个cookie,可分别命名为cookie.json,cookie1.json,cookie2.json +2.cp env.example env # 根据实际情况修改 +3.bash start.sh 0.0.1 +4.curl -X POST 'http://127.0.0.1:8000/chat' -H 'content-type: application/json' --data '{"q":"你是谁?","t":1,"sid":"1"}' 验证是否成功 +``` + +**⚠️ 目前中国大陆的IP会返回404,自备代理** 见[https://github.com/acheong08/EdgeGPT/issues/178](https://github.com/acheong08/EdgeGPT/issues/178) + `EdgeGPT.py`文件 fork 至[https://github.com/acheong08/EdgeGPT](https://github.com/acheong08/EdgeGPT),并做了些许修改,在此表示感谢! diff --git a/new-bing/app.py b/new-bing/app.py index 24bfb6e..6a79f84 100644 --- a/new-bing/app.py +++ b/new-bing/app.py @@ -26,9 +26,11 @@ def reset_cookie(): return cookie = os.environ.get('COOKIE_FILE') if cookie == COOKIE: - os.environ['COOKIE_FILE'] = BAK_COOKIE + if BAK_COOKIE: + os.environ['COOKIE_FILE'] = BAK_COOKIE elif cookie == BAK_COOKIE: - os.environ['COOKIE_FILE'] = BAK_COOKIE1 + if BAK_COOKIE1: + os.environ['COOKIE_FILE'] = BAK_COOKIE1 elif cookie == BAK_COOKIE1: os.environ['COOKIE_FILE'] = COOKIE LOCK.release() diff --git a/new-bing/env.example b/new-bing/env.example index e304a2e..fadac6e 100644 --- a/new-bing/env.example +++ b/new-bing/env.example @@ -1,5 +1,6 @@ -WXAPPID= -WXAPPSECRET= -COOKIE_FILE=/sanic/cookie.json -COOKIE_FILE1=/sanic/cookie1.json -COOKIE_FILE2=/sanic/cookie2.json +WXAPPID=用不到小程序可以不填 +WXAPPSECRET=用不到小程序可以不填 +COOKIE_FILE=/sanic/cookies/cookie.json +COOKIE_FILE1=/sanic/cookies/cookie1.json # 备用cookie1, 没有可以删掉 +COOKIE_FILE2=/sanic/cookies/cookie2.json # 备用cookie2, 没有可以删掉 +https_proxy=http://127.0.0.1:1080 # 目前中国大陆的IP会返回404,所以最好能加个代理 diff --git a/new-bing/start.sh b/new-bing/start.sh index a56de19..749e151 100644 --- a/new-bing/start.sh +++ b/new-bing/start.sh @@ -1,3 +1,6 @@ docker pull yy194131/new-bing:$1 -docker stop new-bing && docker rm new-bing -docker run --restart always --name new-bing --env-file $(pwd)/env -p 8000:8000 -d yy194131/new-bing:$1 +count=$(docker ps -a | grep new-bing | wc -l) +if [ $count -gt 0 ]; then + docker stop new-bing && docker rm new-bing +fi +docker run --restart always --name new-bing -v $(pwd)/cookies:/sanic/cookies --env-file $(pwd)/env -p 8000:8000 -d yy194131/new-bing:$1