From 1964fc76c8aa442c5aefe3ef82c1a271f2ca4fe2 Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Mon, 20 Mar 2023 13:25:02 +0000 Subject: [PATCH 1/2] =?UTF-8?q?doc:=20=E5=AE=8C=E5=96=84wiki=E6=8C=87?= =?UTF-8?q?=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2c05c344..d7e1f3f4 100644 --- a/README.md +++ b/README.md @@ -130,8 +130,6 @@ **部署过程中遇到任何问题,请先在[QChatGPT](https://github.com/RockChinQ/QChatGPT/issues)或[qcg-installer](https://github.com/RockChinQ/qcg-installer/issues)的issue里进行搜索** -> **❗部署完成后必看: [指令说明](https://github.com/RockChinQ/QChatGPT/wiki/%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8#%E6%9C%BA%E5%99%A8%E4%BA%BA%E6%8C%87%E4%BB%A4)❗** - ### - 注册OpenAI账号 > 若您要直接使用非OpenAI的模型(如New Bing),可跳过此步骤,直接进行之后的部署,完成后按照相关插件的文档进行配置即可 @@ -214,7 +212,8 @@ python3 main.py ## 🚀使用 -查看[Wiki功能使用页](https://github.com/RockChinQ/QChatGPT/wiki/%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8#%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F) +**部署完成后必看: [指令说明](https://github.com/RockChinQ/QChatGPT/wiki/%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8#%E6%9C%BA%E5%99%A8%E4%BA%BA%E6%8C%87%E4%BB%A4)** +所有功能查看[Wiki功能使用页](https://github.com/RockChinQ/QChatGPT/wiki/%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8#%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F) ## 🧩插件生态 From d2a7a572456c93e7be95c62359ff9e7d7f38cc63 Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Mon, 20 Mar 2023 13:40:23 +0000 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E4=B8=BAGitHub=20API=E7=9A=84?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E4=BD=BF=E7=94=A8=E4=BB=A3=E7=90=86=20(#312)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/audit/gatherer.py | 2 +- pkg/utils/announcement.py | 3 +++ pkg/utils/network.py | 9 +++++++++ pkg/utils/updater.py | 9 +++++++-- 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 pkg/utils/network.py diff --git a/pkg/audit/gatherer.py b/pkg/audit/gatherer.py index 6237b8ca..4768d271 100644 --- a/pkg/audit/gatherer.py +++ b/pkg/audit/gatherer.py @@ -46,7 +46,7 @@ class DataGatherer: config = pkg.utils.context.get_config() if hasattr(config, "report_usage") and not config.report_usage: return - res = requests.get("http://rockchin.top:18989/usage?service_name=qchatgpt.{}&version={}&count={}".format(subservice_name, self.version_str, count)) + res = requests.get("http://reports.rockchin.top:18989/usage?service_name=qchatgpt.{}&version={}&count={}".format(subservice_name, self.version_str, count)) if res.status_code != 200 or res.text != "ok": logging.warning("report to server failed, status_code: {}, text: {}".format(res.status_code, res.text)) except: diff --git a/pkg/utils/announcement.py b/pkg/utils/announcement.py index 75a8269d..bec74bad 100644 --- a/pkg/utils/announcement.py +++ b/pkg/utils/announcement.py @@ -3,10 +3,13 @@ import os import requests +import pkg.utils.network as network + def read_latest() -> str: resp = requests.get( url="https://api.github.com/repos/RockChinQ/QChatGPT/contents/res/announcement", + proxies=network.wrapper_proxies() ) obj_json = resp.json() b64_content = obj_json["content"] diff --git a/pkg/utils/network.py b/pkg/utils/network.py new file mode 100644 index 00000000..72950658 --- /dev/null +++ b/pkg/utils/network.py @@ -0,0 +1,9 @@ + +def wrapper_proxies() -> dict: + """获取代理""" + import config + + return { + "http": config.openai_config['proxy'], + "https": config.openai_config['proxy'] + } if 'proxy' in config.openai_config and (config.openai_config['proxy'] is not None) else None diff --git a/pkg/utils/updater.py b/pkg/utils/updater.py index d8398c03..57f81a9a 100644 --- a/pkg/utils/updater.py +++ b/pkg/utils/updater.py @@ -6,6 +6,7 @@ import requests import json import pkg.utils.constants +import pkg.utils.network as network def check_dulwich_closure(): @@ -36,7 +37,8 @@ def pull_latest(repo_path: str) -> bool: def get_release_list() -> list: """获取发行列表""" rls_list_resp = requests.get( - url="https://api.github.com/repos/RockChinQ/QChatGPT/releases" + url="https://api.github.com/repos/RockChinQ/QChatGPT/releases", + proxies=network.wrapper_proxies() ) rls_list = rls_list_resp.json() @@ -83,7 +85,10 @@ def update_all(cli: bool = False) -> bool: else: print("开始下载最新版本: {}".format(latest_rls['zipball_url'])) zip_url = latest_rls['zipball_url'] - zip_resp = requests.get(url=zip_url) + zip_resp = requests.get( + url=zip_url, + proxies=network.wrapper_proxies() + ) zip_data = zip_resp.content # 检查temp/updater目录