Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
331c68ec08 | ||
|
|
723349deba | ||
|
|
24c8f095f1 | ||
|
|
92503e0a78 | ||
|
|
f7b251c13a | ||
|
|
60047a557a | ||
|
|
c3f325ba04 | ||
|
|
8140519c82 | ||
|
|
168f25115b |
@@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a report to help us improve
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Describe the bug 简述**
|
|
||||||
|
|
||||||
**Screen Shot 截图**
|
|
||||||
|
|
||||||
**Terminal Traceback 终端traceback(如果有)**
|
|
||||||
|
|
||||||
|
|
||||||
Before submitting an issue 提交issue之前:
|
|
||||||
- Please try to upgrade your code. 如果您的代码不是最新的,建议您先尝试更新代码
|
|
||||||
- Please check project wiki for common problem solutions.项目[wiki](https://github.com/binary-husky/chatgpt_academic/wiki)有一些常见问题的解决方法
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
@@ -140,4 +140,3 @@ gpt_log
|
|||||||
private.md
|
private.md
|
||||||
private_upload
|
private_upload
|
||||||
other_llms
|
other_llms
|
||||||
cradle.py
|
|
||||||
@@ -46,8 +46,6 @@ arxiv小助手 | [函数插件] 输入arxiv文章url即可一键翻译摘要+下
|
|||||||
图片显示 | 可以在markdown中显示图片
|
图片显示 | 可以在markdown中显示图片
|
||||||
多线程函数插件支持 | 支持多线调用chatgpt,一键处理海量文本或程序
|
多线程函数插件支持 | 支持多线调用chatgpt,一键处理海量文本或程序
|
||||||
支持GPT输出的markdown表格 | 可以输出支持GPT的markdown表格
|
支持GPT输出的markdown表格 | 可以输出支持GPT的markdown表格
|
||||||
启动暗色gradio[主题](https://github.com/binary-husky/chatgpt_academic/issues/173) | 在浏览器url后面添加```/?__dark-theme=true```可以切换dark主题
|
|
||||||
huggingface免科学上网[在线体验](https://huggingface.co/spaces/qingxu98/gpt-academic) | 登陆huggingface后复制[此空间](https://huggingface.co/spaces/qingxu98/gpt-academic)
|
|
||||||
…… | ……
|
…… | ……
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -115,7 +113,7 @@ python -m pip install -r requirements.txt
|
|||||||
# (选择二.2)conda activate gptac_venv
|
# (选择二.2)conda activate gptac_venv
|
||||||
# (选择二.3)python -m pip install -r requirements.txt
|
# (选择二.3)python -m pip install -r requirements.txt
|
||||||
|
|
||||||
# 备注:使用官方pip源或者阿里pip源,其他pip源(如一些大学的pip)有可能出问题,临时换源方法:
|
# 备注:使用官方pip源或者阿里pip源,其他pip源(如清华pip)有可能出问题,临时换源方法:
|
||||||
# python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
# python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -257,24 +255,9 @@ python check_proxy.py
|
|||||||
<img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" >
|
<img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" >
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
## Todo:
|
||||||
|
|
||||||
### 源代码转译英文
|
- (Top Priority) 调用另一个开源项目text-generation-webui的web接口,使用其他llm模型
|
||||||
|
- 总结大工程源代码时,文本过长、token溢出的问题(目前的方法是直接二分丢弃处理溢出,过于粗暴,有效信息大量丢失)
|
||||||
|
|
||||||
<div align="center">
|
|
||||||
<img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" >
|
|
||||||
</div>
|
|
||||||
|
|
||||||
## Todo 与 版本规划:
|
|
||||||
|
|
||||||
- version 3 (Todo):
|
|
||||||
- - 支持gpt4和其他更多llm
|
|
||||||
- version 2.3+ (Todo):
|
|
||||||
- - 总结大工程源代码时文本过长、token溢出的问题
|
|
||||||
- - 实现项目打包部署
|
|
||||||
- - 函数插件参数接口优化
|
|
||||||
- - 自更新
|
|
||||||
- version 2.3: 增强多线程交互性
|
|
||||||
- version 2.2: 函数插件支持热重载
|
|
||||||
- version 2.1: 可折叠式布局
|
|
||||||
- version 2.0: 引入模块化函数插件
|
|
||||||
- version 1.0: 基础功能
|
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
import os; os.environ['no_proxy'] = '*' # 避免代理网络产生意外污染
|
||||||
|
import gradio as gr
|
||||||
|
from predict import predict
|
||||||
|
from toolbox import format_io, find_free_port, on_file_uploaded, on_report_generated, get_conf
|
||||||
|
|
||||||
|
# 建议您复制一个config_private.py放自己的秘密, 如API和代理网址, 避免不小心传github被别人看到
|
||||||
|
proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION, CHATBOT_HEIGHT = \
|
||||||
|
get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION', 'CHATBOT_HEIGHT')
|
||||||
|
|
||||||
|
# 如果WEB_PORT是-1, 则随机选取WEB端口
|
||||||
|
PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT
|
||||||
|
if not AUTHENTICATION: AUTHENTICATION = None
|
||||||
|
|
||||||
|
initial_prompt = "Serve me as a writing and programming assistant."
|
||||||
|
title_html = "<h1 align=\"center\">ChatGPT 学术优化</h1>"
|
||||||
|
description = """代码开源和更新[地址🚀](https://github.com/binary-husky/chatgpt_academic),感谢热情的[开发者们❤️](https://github.com/binary-husky/chatgpt_academic/graphs/contributors)"""
|
||||||
|
|
||||||
|
# 问询记录, python 版本建议3.9+(越新越好)
|
||||||
|
import logging
|
||||||
|
os.makedirs("gpt_log", exist_ok=True)
|
||||||
|
try:logging.basicConfig(filename="gpt_log/chat_secrets.log", level=logging.INFO, encoding="utf-8")
|
||||||
|
except:logging.basicConfig(filename="gpt_log/chat_secrets.log", level=logging.INFO)
|
||||||
|
print("所有问询记录将自动保存在本地目录./gpt_log/chat_secrets.log, 请注意自我隐私保护哦!")
|
||||||
|
|
||||||
|
# 一些普通功能模块
|
||||||
|
from functional import get_functionals
|
||||||
|
functional = get_functionals()
|
||||||
|
|
||||||
|
# 高级函数插件
|
||||||
|
from functional_crazy import get_crazy_functionals
|
||||||
|
crazy_fns = get_crazy_functionals()
|
||||||
|
|
||||||
|
# 处理markdown文本格式的转变
|
||||||
|
gr.Chatbot.postprocess = format_io
|
||||||
|
|
||||||
|
# 做一些外观色彩上的调整
|
||||||
|
from theme import adjust_theme, advanced_css
|
||||||
|
set_theme = adjust_theme()
|
||||||
|
|
||||||
|
cancel_handles = []
|
||||||
|
with gr.Blocks(theme=set_theme, analytics_enabled=False, css=advanced_css) as demo:
|
||||||
|
gr.HTML(title_html)
|
||||||
|
# To add a Duplicate Space badge
|
||||||
|
gr.HTML('''<center><a href="https://huggingface.co/spaces/qingxu98/gpt-academic?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>请您打开此页面后务必点击上方的“复制空间”(Duplicate Space)按钮!<br/>切忌在“复制空间”(Duplicate Space)之前填入API_KEY或进行提问,否则您的API_KEY将极可能被空间所有者攫取!</center>''')
|
||||||
|
|
||||||
|
with gr.Row().style(equal_height=True):
|
||||||
|
with gr.Column(scale=2):
|
||||||
|
chatbot = gr.Chatbot()
|
||||||
|
chatbot.style(height=CHATBOT_HEIGHT)
|
||||||
|
history = gr.State([])
|
||||||
|
with gr.Column(scale=1):
|
||||||
|
with gr.Row():
|
||||||
|
api_key = gr.Textbox(show_label=False, placeholder="输入API_KEY,输入后自动生效.").style(container=False)
|
||||||
|
with gr.Row():
|
||||||
|
txt = gr.Textbox(show_label=False, placeholder="输入问题.").style(container=False)
|
||||||
|
with gr.Row():
|
||||||
|
submitBtn = gr.Button("提交", variant="primary")
|
||||||
|
with gr.Row():
|
||||||
|
resetBtn = gr.Button("重置", variant="secondary"); resetBtn.style(size="sm")
|
||||||
|
stopBtn = gr.Button("停止", variant="secondary"); stopBtn.style(size="sm")
|
||||||
|
with gr.Row():
|
||||||
|
from check_proxy import check_proxy
|
||||||
|
status = gr.Markdown(f"Tip: 按Enter提交, 按Shift+Enter换行。当前模型: {LLM_MODEL} \n {check_proxy(proxies)}")
|
||||||
|
with gr.Accordion("基础功能区", open=True) as area_basic_fn:
|
||||||
|
with gr.Row():
|
||||||
|
for k in functional:
|
||||||
|
variant = functional[k]["Color"] if "Color" in functional[k] else "secondary"
|
||||||
|
functional[k]["Button"] = gr.Button(k, variant=variant)
|
||||||
|
with gr.Accordion("函数插件区", open=True) as area_crazy_fn:
|
||||||
|
with gr.Row():
|
||||||
|
gr.Markdown("注意:以下“红颜色”标识的函数插件需从input区读取路径作为参数.")
|
||||||
|
with gr.Row():
|
||||||
|
for k in crazy_fns:
|
||||||
|
if not crazy_fns[k].get("AsButton", True): continue
|
||||||
|
variant = crazy_fns[k]["Color"] if "Color" in crazy_fns[k] else "secondary"
|
||||||
|
crazy_fns[k]["Button"] = gr.Button(k, variant=variant)
|
||||||
|
with gr.Row():
|
||||||
|
with gr.Accordion("更多函数插件", open=True):
|
||||||
|
dropdown_fn_list = [k for k in crazy_fns.keys() if not crazy_fns[k].get("AsButton", True)]
|
||||||
|
with gr.Column(scale=1):
|
||||||
|
dropdown = gr.Dropdown(dropdown_fn_list, value=r"打开插件列表", label="").style(container=False)
|
||||||
|
with gr.Column(scale=1):
|
||||||
|
switchy_bt = gr.Button(r"请先从插件列表中选择", variant="secondary")
|
||||||
|
with gr.Row():
|
||||||
|
with gr.Accordion("点击展开“文件上传区”。上传本地文件可供红色函数插件调用。", open=False) as area_file_up:
|
||||||
|
file_upload = gr.Files(label="任何文件, 但推荐上传压缩文件(zip, tar)", file_count="multiple")
|
||||||
|
with gr.Accordion("展开SysPrompt & 交互界面布局 & Github地址", open=False):
|
||||||
|
system_prompt = gr.Textbox(show_label=True, placeholder=f"System Prompt", label="System prompt", value=initial_prompt)
|
||||||
|
top_p = gr.Slider(minimum=-0, maximum=1.0, value=1.0, step=0.01,interactive=True, label="Top-p (nucleus sampling)",)
|
||||||
|
temperature = gr.Slider(minimum=-0, maximum=2.0, value=1.0, step=0.01, interactive=True, label="Temperature",)
|
||||||
|
checkboxes = gr.CheckboxGroup(["基础功能区", "函数插件区"], value=["基础功能区", "函数插件区"], label="显示/隐藏功能区")
|
||||||
|
gr.Markdown(description)
|
||||||
|
# 功能区显示开关与功能区的互动
|
||||||
|
def fn_area_visibility(a):
|
||||||
|
ret = {}
|
||||||
|
ret.update({area_basic_fn: gr.update(visible=("基础功能区" in a))})
|
||||||
|
ret.update({area_crazy_fn: gr.update(visible=("函数插件区" in a))})
|
||||||
|
return ret
|
||||||
|
checkboxes.select(fn_area_visibility, [checkboxes], [area_basic_fn, area_crazy_fn] )
|
||||||
|
# 整理反复出现的控件句柄组合
|
||||||
|
input_combo = [txt, top_p, api_key, temperature, chatbot, history, system_prompt]
|
||||||
|
output_combo = [chatbot, history, status]
|
||||||
|
predict_args = dict(fn=predict, inputs=input_combo, outputs=output_combo)
|
||||||
|
empty_txt_args = dict(fn=lambda: "", inputs=[], outputs=[txt]) # 用于在提交后清空输入栏
|
||||||
|
# 提交按钮、重置按钮
|
||||||
|
cancel_handles.append(txt.submit(**predict_args)) #; txt.submit(**empty_txt_args) 在提交后清空输入栏
|
||||||
|
cancel_handles.append(submitBtn.click(**predict_args)) #; submitBtn.click(**empty_txt_args) 在提交后清空输入栏
|
||||||
|
resetBtn.click(lambda: ([], [], "已重置"), None, output_combo)
|
||||||
|
# 基础功能区的回调函数注册
|
||||||
|
for k in functional:
|
||||||
|
click_handle = functional[k]["Button"].click(predict, [*input_combo, gr.State(True), gr.State(k)], output_combo)
|
||||||
|
cancel_handles.append(click_handle)
|
||||||
|
# 文件上传区,接收文件后与chatbot的互动
|
||||||
|
file_upload.upload(on_file_uploaded, [file_upload, chatbot, txt], [chatbot, txt])
|
||||||
|
# 函数插件-固定按钮区
|
||||||
|
for k in crazy_fns:
|
||||||
|
if not crazy_fns[k].get("AsButton", True): continue
|
||||||
|
click_handle = crazy_fns[k]["Button"].click(crazy_fns[k]["Function"], [*input_combo, gr.State(PORT)], output_combo)
|
||||||
|
click_handle.then(on_report_generated, [file_upload, chatbot], [file_upload, chatbot])
|
||||||
|
cancel_handles.append(click_handle)
|
||||||
|
# 函数插件-下拉菜单与随变按钮的互动
|
||||||
|
def on_dropdown_changed(k):
|
||||||
|
variant = crazy_fns[k]["Color"] if "Color" in crazy_fns[k] else "secondary"
|
||||||
|
return {switchy_bt: gr.update(value=k, variant=variant)}
|
||||||
|
dropdown.select(on_dropdown_changed, [dropdown], [switchy_bt] )
|
||||||
|
# 随变按钮的回调函数注册
|
||||||
|
def route(k, *args, **kwargs):
|
||||||
|
if k in [r"打开插件列表", r"请先从插件列表中选择"]: return
|
||||||
|
yield from crazy_fns[k]["Function"](*args, **kwargs)
|
||||||
|
click_handle = switchy_bt.click(route,[switchy_bt, *input_combo, gr.State(PORT)], output_combo)
|
||||||
|
click_handle.then(on_report_generated, [file_upload, chatbot], [file_upload, chatbot])
|
||||||
|
# def expand_file_area(file_upload, area_file_up):
|
||||||
|
# if len(file_upload)>0: return {area_file_up: gr.update(open=True)}
|
||||||
|
# click_handle.then(expand_file_area, [file_upload, area_file_up], [area_file_up])
|
||||||
|
cancel_handles.append(click_handle)
|
||||||
|
# 终止按钮的回调函数注册
|
||||||
|
stopBtn.click(fn=None, inputs=None, outputs=None, cancels=cancel_handles)
|
||||||
|
|
||||||
|
# gradio的inbrowser触发不太稳定,回滚代码到原始的浏览器打开函数
|
||||||
|
def auto_opentab_delay():
|
||||||
|
import threading, webbrowser, time
|
||||||
|
print(f"如果浏览器没有自动打开,请复制并转到以下URL: http://localhost:{PORT}")
|
||||||
|
def open():
|
||||||
|
time.sleep(2)
|
||||||
|
webbrowser.open_new_tab(f"http://localhost:{PORT}")
|
||||||
|
threading.Thread(target=open, name="open-browser", daemon=True).start()
|
||||||
|
|
||||||
|
auto_opentab_delay()
|
||||||
|
demo.title = "ChatGPT 学术优化"
|
||||||
|
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", share=False)
|
||||||
@@ -28,7 +28,7 @@ CHATBOT_HEIGHT = 1115
|
|||||||
TIMEOUT_SECONDS = 25
|
TIMEOUT_SECONDS = 25
|
||||||
|
|
||||||
# 网页的端口, -1代表随机端口
|
# 网页的端口, -1代表随机端口
|
||||||
WEB_PORT = -1
|
WEB_PORT = 7860
|
||||||
|
|
||||||
# 如果OpenAI不响应(网络卡顿、代理失败、KEY失效),重试的次数限制
|
# 如果OpenAI不响应(网络卡顿、代理失败、KEY失效),重试的次数限制
|
||||||
MAX_RETRY = 2
|
MAX_RETRY = 2
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ def get_name(_url_):
|
|||||||
|
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 下载arxiv论文并翻译摘要(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def 下载arxiv论文并翻译摘要(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
|
|
||||||
CRAZY_FUNCTION_INFO = "下载arxiv论文并翻译摘要,函数插件作者[binary-husky]。正在提取摘要并下载PDF文档……"
|
CRAZY_FUNCTION_INFO = "下载arxiv论文并翻译摘要,函数插件作者[binary-husky]。正在提取摘要并下载PDF文档……"
|
||||||
import glob
|
import glob
|
||||||
@@ -172,7 +172,7 @@ def 下载arxiv论文并翻译摘要(txt, top_p, temperature, chatbot, history,
|
|||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
msg = '正常'
|
msg = '正常'
|
||||||
# ** gpt request **
|
# ** gpt request **
|
||||||
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, history=[]) # 带超时倒计时
|
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, api_key, temperature, history=[]) # 带超时倒计时
|
||||||
chatbot[-1] = (i_say_show_user, gpt_say)
|
chatbot[-1] = (i_say_show_user, gpt_say)
|
||||||
history.append(i_say_show_user); history.append(gpt_say)
|
history.append(i_say_show_user); history.append(gpt_say)
|
||||||
yield chatbot, history, msg
|
yield chatbot, history, msg
|
||||||
|
|||||||
+22
-115
@@ -1,126 +1,41 @@
|
|||||||
import threading
|
import threading
|
||||||
from predict import predict_no_ui_long_connection
|
from predict import predict_no_ui_long_connection
|
||||||
from toolbox import CatchException, write_results_to_file, report_execption
|
from toolbox import CatchException, write_results_to_file
|
||||||
|
|
||||||
def extract_code_block_carefully(txt):
|
|
||||||
splitted = txt.split('```')
|
|
||||||
n_code_block_seg = len(splitted) - 1
|
|
||||||
if n_code_block_seg <= 1: return txt
|
|
||||||
# 剩下的情况都开头除去 ``` 结尾除去一次 ```
|
|
||||||
txt_out = '```'.join(splitted[1:-1])
|
|
||||||
return txt_out
|
|
||||||
|
|
||||||
def breakdown_txt_to_satisfy_token_limit(txt, limit, must_break_at_empty_line=True):
|
|
||||||
from transformers import GPT2TokenizerFast
|
|
||||||
tokenizer = GPT2TokenizerFast.from_pretrained("gpt2")
|
|
||||||
get_token_cnt = lambda txt: len(tokenizer(txt)["input_ids"])
|
|
||||||
def cut(txt_tocut, must_break_at_empty_line): # 递归
|
|
||||||
if get_token_cnt(txt_tocut) <= limit:
|
|
||||||
return [txt_tocut]
|
|
||||||
else:
|
|
||||||
lines = txt_tocut.split('\n')
|
|
||||||
estimated_line_cut = limit / get_token_cnt(txt_tocut) * len(lines)
|
|
||||||
estimated_line_cut = int(estimated_line_cut)
|
|
||||||
for cnt in reversed(range(estimated_line_cut)):
|
|
||||||
if must_break_at_empty_line:
|
|
||||||
if lines[cnt] != "": continue
|
|
||||||
print(cnt)
|
|
||||||
prev = "\n".join(lines[:cnt])
|
|
||||||
post = "\n".join(lines[cnt:])
|
|
||||||
if get_token_cnt(prev) < limit: break
|
|
||||||
if cnt == 0:
|
|
||||||
print('what the f?')
|
|
||||||
raise RuntimeError("存在一行极长的文本!")
|
|
||||||
print(len(post))
|
|
||||||
# 列表递归接龙
|
|
||||||
result = [prev]
|
|
||||||
result.extend(cut(post, must_break_at_empty_line))
|
|
||||||
return result
|
|
||||||
try:
|
|
||||||
return cut(txt, must_break_at_empty_line=True)
|
|
||||||
except RuntimeError:
|
|
||||||
return cut(txt, must_break_at_empty_line=False)
|
|
||||||
|
|
||||||
|
|
||||||
def break_txt_into_half_at_some_linebreak(txt):
|
|
||||||
lines = txt.split('\n')
|
|
||||||
n_lines = len(lines)
|
|
||||||
pre = lines[:(n_lines//2)]
|
|
||||||
post = lines[(n_lines//2):]
|
|
||||||
return "\n".join(pre), "\n".join(post)
|
|
||||||
|
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 全项目切换英文(txt, top_p, temperature, chatbot, history, sys_prompt, WEB_PORT):
|
def 全项目切换英文(txt, top_p, api_key, temperature, chatbot, history, sys_prompt, WEB_PORT):
|
||||||
# 第1步:清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
history = []
|
# 集合文件
|
||||||
|
import time, glob, os
|
||||||
# 第2步:尝试导入依赖,如果缺少依赖,则给出安装建议
|
|
||||||
try:
|
|
||||||
import openai, transformers
|
|
||||||
except:
|
|
||||||
report_execption(chatbot, history,
|
|
||||||
a = f"解析项目: {txt}",
|
|
||||||
b = f"导入软件依赖失败。使用该模块需要额外依赖,安装方法```pip install --upgrade openai transformers```。")
|
|
||||||
yield chatbot, history, '正常'
|
|
||||||
return
|
|
||||||
|
|
||||||
# 第3步:集合文件
|
|
||||||
import time, glob, os, shutil, re, openai
|
|
||||||
os.makedirs('gpt_log/generated_english_version', exist_ok=True)
|
os.makedirs('gpt_log/generated_english_version', exist_ok=True)
|
||||||
os.makedirs('gpt_log/generated_english_version/crazy_functions', exist_ok=True)
|
os.makedirs('gpt_log/generated_english_version/crazy_functions', exist_ok=True)
|
||||||
file_manifest = [f for f in glob.glob('./*.py') if ('test_project' not in f) and ('gpt_log' not in f)] + \
|
file_manifest = [f for f in glob.glob('./*.py') if ('test_project' not in f) and ('gpt_log' not in f)] + \
|
||||||
[f for f in glob.glob('./crazy_functions/*.py') if ('test_project' not in f) and ('gpt_log' not in f)]
|
[f for f in glob.glob('./crazy_functions/*.py') if ('test_project' not in f) and ('gpt_log' not in f)]
|
||||||
# file_manifest = ['./toolbox.py']
|
|
||||||
i_say_show_user_buffer = []
|
i_say_show_user_buffer = []
|
||||||
|
|
||||||
# 第4步:随便显示点什么防止卡顿的感觉
|
# 随便显示点什么防止卡顿的感觉
|
||||||
for index, fp in enumerate(file_manifest):
|
for index, fp in enumerate(file_manifest):
|
||||||
# if 'test_project' in fp: continue
|
# if 'test_project' in fp: continue
|
||||||
with open(fp, 'r', encoding='utf-8') as f:
|
with open(fp, 'r', encoding='utf-8') as f:
|
||||||
file_content = f.read()
|
file_content = f.read()
|
||||||
i_say_show_user =f'[{index}/{len(file_manifest)}] 接下来请将以下代码中包含的所有中文转化为英文,只输出转化后的英文代码,请用代码块输出代码: {os.path.abspath(fp)}'
|
i_say_show_user =f'[{index}/{len(file_manifest)}] 接下来请将以下代码中包含的所有中文转化为英文,只输出代码: {os.path.abspath(fp)}'
|
||||||
i_say_show_user_buffer.append(i_say_show_user)
|
i_say_show_user_buffer.append(i_say_show_user)
|
||||||
chatbot.append((i_say_show_user, "[Local Message] 等待多线程操作,中间过程不予显示."))
|
chatbot.append((i_say_show_user, "[Local Message] 等待多线程操作,中间过程不予显示."))
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
|
|
||||||
|
# 任务函数
|
||||||
# 第5步:Token限制下的截断与处理
|
|
||||||
MAX_TOKEN = 2500
|
|
||||||
# from transformers import GPT2TokenizerFast
|
|
||||||
# print('加载tokenizer中')
|
|
||||||
# tokenizer = GPT2TokenizerFast.from_pretrained("gpt2")
|
|
||||||
# get_token_cnt = lambda txt: len(tokenizer(txt)["input_ids"])
|
|
||||||
# print('加载tokenizer结束')
|
|
||||||
|
|
||||||
|
|
||||||
# 第6步:任务函数
|
|
||||||
mutable_return = [None for _ in file_manifest]
|
mutable_return = [None for _ in file_manifest]
|
||||||
observe_window = [[""] for _ in file_manifest]
|
|
||||||
def thread_worker(fp,index):
|
def thread_worker(fp,index):
|
||||||
if index > 10:
|
|
||||||
time.sleep(60)
|
|
||||||
print('Openai 限制免费用户每分钟20次请求,降低请求频率中。')
|
|
||||||
with open(fp, 'r', encoding='utf-8') as f:
|
with open(fp, 'r', encoding='utf-8') as f:
|
||||||
file_content = f.read()
|
file_content = f.read()
|
||||||
i_say_template = lambda fp, file_content: f'接下来请将以下代码中包含的所有中文转化为英文,只输出代码,文件名是{fp},文件代码是 ```{file_content}```'
|
i_say = f'接下来请将以下代码中包含的所有中文转化为英文,只输出代码,文件名是{fp},文件代码是 ```{file_content}```'
|
||||||
try:
|
# ** gpt request **
|
||||||
gpt_say = ""
|
gpt_say = predict_no_ui_long_connection(inputs=i_say, top_p=top_p, api_key=api_key, temperature=temperature, history=history, sys_prompt=sys_prompt)
|
||||||
# 分解代码文件
|
mutable_return[index] = gpt_say
|
||||||
file_content_breakdown = breakdown_txt_to_satisfy_token_limit(file_content, MAX_TOKEN)
|
|
||||||
for file_content_partial in file_content_breakdown:
|
|
||||||
i_say = i_say_template(fp, file_content_partial)
|
|
||||||
# # ** gpt request **
|
|
||||||
gpt_say_partial = predict_no_ui_long_connection(inputs=i_say, top_p=top_p, temperature=temperature, history=[], sys_prompt=sys_prompt, observe_window=observe_window[index])
|
|
||||||
gpt_say_partial = extract_code_block_carefully(gpt_say_partial)
|
|
||||||
gpt_say += gpt_say_partial
|
|
||||||
mutable_return[index] = gpt_say
|
|
||||||
except ConnectionAbortedError as token_exceed_err:
|
|
||||||
print('至少一个线程任务Token溢出而失败', e)
|
|
||||||
except Exception as e:
|
|
||||||
print('至少一个线程任务意外失败', e)
|
|
||||||
|
|
||||||
# 第7步:所有线程同时开始执行任务函数
|
# 所有线程同时开始执行任务函数
|
||||||
handles = [threading.Thread(target=thread_worker, args=(fp,index)) for index, fp in enumerate(file_manifest)]
|
handles = [threading.Thread(target=thread_worker, args=(fp,index)) for index, fp in enumerate(file_manifest)]
|
||||||
for h in handles:
|
for h in handles:
|
||||||
h.daemon = True
|
h.daemon = True
|
||||||
@@ -128,23 +43,19 @@ def 全项目切换英文(txt, top_p, temperature, chatbot, history, sys_prompt,
|
|||||||
chatbot.append(('开始了吗?', f'多线程操作已经开始'))
|
chatbot.append(('开始了吗?', f'多线程操作已经开始'))
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
|
|
||||||
# 第8步:循环轮询各个线程是否执行完毕
|
# 循环轮询各个线程是否执行完毕
|
||||||
cnt = 0
|
cnt = 0
|
||||||
while True:
|
while True:
|
||||||
cnt += 1
|
time.sleep(1)
|
||||||
time.sleep(0.2)
|
|
||||||
th_alive = [h.is_alive() for h in handles]
|
th_alive = [h.is_alive() for h in handles]
|
||||||
if not any(th_alive): break
|
if not any(th_alive): break
|
||||||
# 更好的UI视觉效果
|
stat = ['执行中' if alive else '已完成' for alive in th_alive]
|
||||||
observe_win = []
|
stat_str = '|'.join(stat)
|
||||||
for thread_index, alive in enumerate(th_alive):
|
cnt += 1
|
||||||
observe_win.append("[ ..."+observe_window[thread_index][0][-60:].replace('\n','').replace('```','...').replace(' ','.').replace('<br/>','.....').replace('$','.')+"... ]")
|
chatbot[-1] = (chatbot[-1][0], f'多线程操作已经开始,完成情况: {stat_str}' + ''.join(['.']*(cnt%4)))
|
||||||
stat = [f'执行中: {obs}\n\n' if alive else '已完成\n\n' for alive, obs in zip(th_alive, observe_win)]
|
|
||||||
stat_str = ''.join(stat)
|
|
||||||
chatbot[-1] = (chatbot[-1][0], f'多线程操作已经开始,完成情况: \n\n{stat_str}' + ''.join(['.']*(cnt%10+1)))
|
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
|
|
||||||
# 第9步:把结果写入文件
|
# 把结果写入文件
|
||||||
for index, h in enumerate(handles):
|
for index, h in enumerate(handles):
|
||||||
h.join() # 这里其实不需要join了,肯定已经都结束了
|
h.join() # 这里其实不需要join了,肯定已经都结束了
|
||||||
fp = file_manifest[index]
|
fp = file_manifest[index]
|
||||||
@@ -152,17 +63,13 @@ def 全项目切换英文(txt, top_p, temperature, chatbot, history, sys_prompt,
|
|||||||
i_say_show_user = i_say_show_user_buffer[index]
|
i_say_show_user = i_say_show_user_buffer[index]
|
||||||
|
|
||||||
where_to_relocate = f'gpt_log/generated_english_version/{fp}'
|
where_to_relocate = f'gpt_log/generated_english_version/{fp}'
|
||||||
if gpt_say is not None:
|
with open(where_to_relocate, 'w+', encoding='utf-8') as f: f.write(gpt_say.lstrip('```').rstrip('```'))
|
||||||
with open(where_to_relocate, 'w+', encoding='utf-8') as f:
|
|
||||||
f.write(gpt_say)
|
|
||||||
else: # 失败
|
|
||||||
shutil.copyfile(file_manifest[index], where_to_relocate)
|
|
||||||
chatbot.append((i_say_show_user, f'[Local Message] 已完成{os.path.abspath(fp)}的转化,\n\n存入{os.path.abspath(where_to_relocate)}'))
|
chatbot.append((i_say_show_user, f'[Local Message] 已完成{os.path.abspath(fp)}的转化,\n\n存入{os.path.abspath(where_to_relocate)}'))
|
||||||
history.append(i_say_show_user); history.append(gpt_say)
|
history.append(i_say_show_user); history.append(gpt_say)
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
# 第10步:备份一个文件
|
# 备份一个文件
|
||||||
res = write_results_to_file(history)
|
res = write_results_to_file(history)
|
||||||
chatbot.append(("生成一份任务执行报告", res))
|
chatbot.append(("生成一份任务执行报告", res))
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from toolbox import CatchException, report_execption, write_results_to_file, pre
|
|||||||
fast_debug = False
|
fast_debug = False
|
||||||
|
|
||||||
|
|
||||||
def 解析docx(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt):
|
def 解析docx(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt):
|
||||||
import time, os
|
import time, os
|
||||||
# pip install python-docx 用于docx格式,跨平台
|
# pip install python-docx 用于docx格式,跨平台
|
||||||
# pip install pywin32 用于doc格式,仅支持Win平台
|
# pip install pywin32 用于doc格式,仅支持Win平台
|
||||||
@@ -40,7 +40,7 @@ def 解析docx(file_manifest, project_folder, top_p, temperature, chatbot, histo
|
|||||||
if not fast_debug:
|
if not fast_debug:
|
||||||
msg = '正常'
|
msg = '正常'
|
||||||
# ** gpt request **
|
# ** gpt request **
|
||||||
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature,
|
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, api_key, temperature,
|
||||||
history=[]) # 带超时倒计时
|
history=[]) # 带超时倒计时
|
||||||
chatbot[-1] = (i_say_show_user, gpt_say)
|
chatbot[-1] = (i_say_show_user, gpt_say)
|
||||||
history.append(i_say_show_user);
|
history.append(i_say_show_user);
|
||||||
@@ -66,7 +66,7 @@ def 解析docx(file_manifest, project_folder, top_p, temperature, chatbot, histo
|
|||||||
if not fast_debug:
|
if not fast_debug:
|
||||||
msg = '正常'
|
msg = '正常'
|
||||||
# ** gpt request **
|
# ** gpt request **
|
||||||
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, temperature,
|
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, api_key, temperature,
|
||||||
history=history) # 带超时倒计时
|
history=history) # 带超时倒计时
|
||||||
|
|
||||||
chatbot[-1] = (i_say, gpt_say)
|
chatbot[-1] = (i_say, gpt_say)
|
||||||
@@ -79,7 +79,7 @@ def 解析docx(file_manifest, project_folder, top_p, temperature, chatbot, histo
|
|||||||
|
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 总结word文档(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def 总结word文档(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
import glob, os
|
import glob, os
|
||||||
|
|
||||||
# 基本信息:功能、贡献者
|
# 基本信息:功能、贡献者
|
||||||
@@ -124,4 +124,4 @@ def 总结word文档(txt, top_p, temperature, chatbot, history, systemPromptTxt,
|
|||||||
return
|
return
|
||||||
|
|
||||||
# 开始正式执行任务
|
# 开始正式执行任务
|
||||||
yield from 解析docx(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
|
yield from 解析docx(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt)
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ def clean_text(raw_text):
|
|||||||
|
|
||||||
return final_text.strip()
|
return final_text.strip()
|
||||||
|
|
||||||
def 解析PDF(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt):
|
def 解析PDF(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt):
|
||||||
import time, glob, os, fitz
|
import time, glob, os, fitz
|
||||||
print('begin analysis on:', file_manifest)
|
print('begin analysis on:', file_manifest)
|
||||||
for index, fp in enumerate(file_manifest):
|
for index, fp in enumerate(file_manifest):
|
||||||
@@ -78,7 +78,7 @@ def 解析PDF(file_manifest, project_folder, top_p, temperature, chatbot, histor
|
|||||||
if not fast_debug:
|
if not fast_debug:
|
||||||
msg = '正常'
|
msg = '正常'
|
||||||
# ** gpt request **
|
# ** gpt request **
|
||||||
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, history=[]) # 带超时倒计时
|
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, api_key, temperature, history=[]) # 带超时倒计时
|
||||||
|
|
||||||
print('[2] end gpt req')
|
print('[2] end gpt req')
|
||||||
chatbot[-1] = (i_say_show_user, gpt_say)
|
chatbot[-1] = (i_say_show_user, gpt_say)
|
||||||
@@ -96,7 +96,7 @@ def 解析PDF(file_manifest, project_folder, top_p, temperature, chatbot, histor
|
|||||||
if not fast_debug:
|
if not fast_debug:
|
||||||
msg = '正常'
|
msg = '正常'
|
||||||
# ** gpt request **
|
# ** gpt request **
|
||||||
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, temperature, history=history) # 带超时倒计时
|
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, api_key, temperature, history=history) # 带超时倒计时
|
||||||
|
|
||||||
chatbot[-1] = (i_say, gpt_say)
|
chatbot[-1] = (i_say, gpt_say)
|
||||||
history.append(i_say); history.append(gpt_say)
|
history.append(i_say); history.append(gpt_say)
|
||||||
@@ -107,7 +107,7 @@ def 解析PDF(file_manifest, project_folder, top_p, temperature, chatbot, histor
|
|||||||
|
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 批量总结PDF文档(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def 批量总结PDF文档(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
import glob, os
|
import glob, os
|
||||||
|
|
||||||
# 基本信息:功能、贡献者
|
# 基本信息:功能、贡献者
|
||||||
@@ -151,4 +151,4 @@ def 批量总结PDF文档(txt, top_p, temperature, chatbot, history, systemPromp
|
|||||||
return
|
return
|
||||||
|
|
||||||
# 开始正式执行任务
|
# 开始正式执行任务
|
||||||
yield from 解析PDF(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
|
yield from 解析PDF(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ def readPdf(pdfPath):
|
|||||||
return outTextList
|
return outTextList
|
||||||
|
|
||||||
|
|
||||||
def 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt):
|
def 解析Paper(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt):
|
||||||
import time, glob, os
|
import time, glob, os
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
print('begin analysis on:', file_manifest)
|
print('begin analysis on:', file_manifest)
|
||||||
@@ -83,7 +83,7 @@ def 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, hist
|
|||||||
if not fast_debug:
|
if not fast_debug:
|
||||||
msg = '正常'
|
msg = '正常'
|
||||||
# ** gpt request **
|
# ** gpt request **
|
||||||
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, history=[]) # 带超时倒计时
|
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, api_key, temperature, history=[]) # 带超时倒计时
|
||||||
|
|
||||||
print('[2] end gpt req')
|
print('[2] end gpt req')
|
||||||
chatbot[-1] = (i_say_show_user, gpt_say)
|
chatbot[-1] = (i_say_show_user, gpt_say)
|
||||||
@@ -101,7 +101,7 @@ def 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, hist
|
|||||||
if not fast_debug:
|
if not fast_debug:
|
||||||
msg = '正常'
|
msg = '正常'
|
||||||
# ** gpt request **
|
# ** gpt request **
|
||||||
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, temperature, history=history) # 带超时倒计时
|
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, api_key, temperature, history=history) # 带超时倒计时
|
||||||
|
|
||||||
chatbot[-1] = (i_say, gpt_say)
|
chatbot[-1] = (i_say, gpt_say)
|
||||||
history.append(i_say); history.append(gpt_say)
|
history.append(i_say); history.append(gpt_say)
|
||||||
@@ -113,7 +113,7 @@ def 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, hist
|
|||||||
|
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 批量总结PDF文档pdfminer(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def 批量总结PDF文档pdfminer(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
history = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
import glob, os
|
import glob, os
|
||||||
|
|
||||||
@@ -147,5 +147,5 @@ def 批量总结PDF文档pdfminer(txt, top_p, temperature, chatbot, history, sys
|
|||||||
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.tex或pdf文件: {txt}")
|
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.tex或pdf文件: {txt}")
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
return
|
return
|
||||||
yield from 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
|
yield from 解析Paper(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from toolbox import CatchException, report_execption, write_results_to_file, pre
|
|||||||
fast_debug = False
|
fast_debug = False
|
||||||
|
|
||||||
|
|
||||||
def 生成函数注释(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt):
|
def 生成函数注释(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt):
|
||||||
import time, glob, os
|
import time, glob, os
|
||||||
print('begin analysis on:', file_manifest)
|
print('begin analysis on:', file_manifest)
|
||||||
for index, fp in enumerate(file_manifest):
|
for index, fp in enumerate(file_manifest):
|
||||||
@@ -19,7 +19,7 @@ def 生成函数注释(file_manifest, project_folder, top_p, temperature, chatbo
|
|||||||
if not fast_debug:
|
if not fast_debug:
|
||||||
msg = '正常'
|
msg = '正常'
|
||||||
# ** gpt request **
|
# ** gpt request **
|
||||||
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, history=[]) # 带超时倒计时
|
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, api_key, temperature, history=[]) # 带超时倒计时
|
||||||
|
|
||||||
print('[2] end gpt req')
|
print('[2] end gpt req')
|
||||||
chatbot[-1] = (i_say_show_user, gpt_say)
|
chatbot[-1] = (i_say_show_user, gpt_say)
|
||||||
@@ -37,7 +37,7 @@ def 生成函数注释(file_manifest, project_folder, top_p, temperature, chatbo
|
|||||||
|
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 批量生成函数注释(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def 批量生成函数注释(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
history = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
import glob, os
|
import glob, os
|
||||||
if os.path.exists(txt):
|
if os.path.exists(txt):
|
||||||
@@ -54,4 +54,4 @@ def 批量生成函数注释(txt, top_p, temperature, chatbot, history, systemPr
|
|||||||
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.tex文件: {txt}")
|
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.tex文件: {txt}")
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
return
|
return
|
||||||
yield from 生成函数注释(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
|
yield from 生成函数注释(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt)
|
||||||
|
|||||||
+22
-23
@@ -2,7 +2,7 @@ from predict import predict_no_ui
|
|||||||
from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down
|
from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down
|
||||||
fast_debug = False
|
fast_debug = False
|
||||||
|
|
||||||
def 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt):
|
def 解析源代码(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt):
|
||||||
import time, glob, os
|
import time, glob, os
|
||||||
print('begin analysis on:', file_manifest)
|
print('begin analysis on:', file_manifest)
|
||||||
for index, fp in enumerate(file_manifest):
|
for index, fp in enumerate(file_manifest):
|
||||||
@@ -19,7 +19,7 @@ def 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot,
|
|||||||
msg = '正常'
|
msg = '正常'
|
||||||
|
|
||||||
# ** gpt request **
|
# ** gpt request **
|
||||||
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, history=[]) # 带超时倒计时
|
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, api_key, temperature, history=[]) # 带超时倒计时
|
||||||
|
|
||||||
chatbot[-1] = (i_say_show_user, gpt_say)
|
chatbot[-1] = (i_say_show_user, gpt_say)
|
||||||
history.append(i_say_show_user); history.append(gpt_say)
|
history.append(i_say_show_user); history.append(gpt_say)
|
||||||
@@ -34,7 +34,7 @@ def 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot,
|
|||||||
if not fast_debug:
|
if not fast_debug:
|
||||||
msg = '正常'
|
msg = '正常'
|
||||||
# ** gpt request **
|
# ** gpt request **
|
||||||
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, temperature, history=history) # 带超时倒计时
|
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, api_key, temperature, history=history) # 带超时倒计时
|
||||||
|
|
||||||
chatbot[-1] = (i_say, gpt_say)
|
chatbot[-1] = (i_say, gpt_say)
|
||||||
history.append(i_say); history.append(gpt_say)
|
history.append(i_say); history.append(gpt_say)
|
||||||
@@ -47,7 +47,7 @@ def 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot,
|
|||||||
|
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 解析项目本身(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def 解析项目本身(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
history = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
import time, glob, os
|
import time, glob, os
|
||||||
file_manifest = [f for f in glob.glob('./*.py') if ('test_project' not in f) and ('gpt_log' not in f)] + \
|
file_manifest = [f for f in glob.glob('./*.py') if ('test_project' not in f) and ('gpt_log' not in f)] + \
|
||||||
@@ -65,8 +65,8 @@ def 解析项目本身(txt, top_p, temperature, chatbot, history, systemPromptTx
|
|||||||
|
|
||||||
if not fast_debug:
|
if not fast_debug:
|
||||||
# ** gpt request **
|
# ** gpt request **
|
||||||
# gpt_say = predict_no_ui(inputs=i_say, top_p=top_p, temperature=temperature)
|
# gpt_say = predict_no_ui(inputs=i_say, top_p=top_p, api_key=api_key, temperature=temperature)
|
||||||
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, history=[], long_connection=True) # 带超时倒计时
|
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, api_key, temperature, history=[], long_connection=True) # 带超时倒计时
|
||||||
|
|
||||||
chatbot[-1] = (i_say_show_user, gpt_say)
|
chatbot[-1] = (i_say_show_user, gpt_say)
|
||||||
history.append(i_say_show_user); history.append(gpt_say)
|
history.append(i_say_show_user); history.append(gpt_say)
|
||||||
@@ -79,8 +79,8 @@ def 解析项目本身(txt, top_p, temperature, chatbot, history, systemPromptTx
|
|||||||
|
|
||||||
if not fast_debug:
|
if not fast_debug:
|
||||||
# ** gpt request **
|
# ** gpt request **
|
||||||
# gpt_say = predict_no_ui(inputs=i_say, top_p=top_p, temperature=temperature, history=history)
|
# gpt_say = predict_no_ui(inputs=i_say, top_p=top_p, api_key=api_key, temperature=temperature, history=history)
|
||||||
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, temperature, history=history, long_connection=True) # 带超时倒计时
|
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, api_key, temperature, history=history, long_connection=True) # 带超时倒计时
|
||||||
|
|
||||||
chatbot[-1] = (i_say, gpt_say)
|
chatbot[-1] = (i_say, gpt_say)
|
||||||
history.append(i_say); history.append(gpt_say)
|
history.append(i_say); history.append(gpt_say)
|
||||||
@@ -90,7 +90,7 @@ def 解析项目本身(txt, top_p, temperature, chatbot, history, systemPromptTx
|
|||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 解析一个Python项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def 解析一个Python项目(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
history = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
import glob, os
|
import glob, os
|
||||||
if os.path.exists(txt):
|
if os.path.exists(txt):
|
||||||
@@ -105,11 +105,11 @@ def 解析一个Python项目(txt, top_p, temperature, chatbot, history, systemPr
|
|||||||
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何python文件: {txt}")
|
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何python文件: {txt}")
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
return
|
return
|
||||||
yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
|
yield from 解析源代码(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt)
|
||||||
|
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 解析一个C项目的头文件(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def 解析一个C项目的头文件(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
history = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
import glob, os
|
import glob, os
|
||||||
if os.path.exists(txt):
|
if os.path.exists(txt):
|
||||||
@@ -119,17 +119,17 @@ def 解析一个C项目的头文件(txt, top_p, temperature, chatbot, history, s
|
|||||||
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
|
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
return
|
return
|
||||||
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.h', recursive=True)] + \
|
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.h', recursive=True)] # + \
|
||||||
[f for f in glob.glob(f'{project_folder}/**/*.hpp', recursive=True)] #+ \
|
# [f for f in glob.glob(f'{project_folder}/**/*.cpp', recursive=True)] + \
|
||||||
# [f for f in glob.glob(f'{project_folder}/**/*.c', recursive=True)]
|
# [f for f in glob.glob(f'{project_folder}/**/*.c', recursive=True)]
|
||||||
if len(file_manifest) == 0:
|
if len(file_manifest) == 0:
|
||||||
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.h头文件: {txt}")
|
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.h头文件: {txt}")
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
return
|
return
|
||||||
yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
|
yield from 解析源代码(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt)
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 解析一个C项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def 解析一个C项目(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
history = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
import glob, os
|
import glob, os
|
||||||
if os.path.exists(txt):
|
if os.path.exists(txt):
|
||||||
@@ -141,17 +141,16 @@ def 解析一个C项目(txt, top_p, temperature, chatbot, history, systemPromptT
|
|||||||
return
|
return
|
||||||
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.h', recursive=True)] + \
|
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.h', recursive=True)] + \
|
||||||
[f for f in glob.glob(f'{project_folder}/**/*.cpp', recursive=True)] + \
|
[f for f in glob.glob(f'{project_folder}/**/*.cpp', recursive=True)] + \
|
||||||
[f for f in glob.glob(f'{project_folder}/**/*.hpp', recursive=True)] + \
|
|
||||||
[f for f in glob.glob(f'{project_folder}/**/*.c', recursive=True)]
|
[f for f in glob.glob(f'{project_folder}/**/*.c', recursive=True)]
|
||||||
if len(file_manifest) == 0:
|
if len(file_manifest) == 0:
|
||||||
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.h头文件: {txt}")
|
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.h头文件: {txt}")
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
return
|
return
|
||||||
yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
|
yield from 解析源代码(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt)
|
||||||
|
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 解析一个Java项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def 解析一个Java项目(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
history = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
import glob, os
|
import glob, os
|
||||||
if os.path.exists(txt):
|
if os.path.exists(txt):
|
||||||
@@ -169,11 +168,11 @@ def 解析一个Java项目(txt, top_p, temperature, chatbot, history, systemProm
|
|||||||
report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何java文件: {txt}")
|
report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何java文件: {txt}")
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
return
|
return
|
||||||
yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
|
yield from 解析源代码(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt)
|
||||||
|
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 解析一个Rect项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def 解析一个Rect项目(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
history = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
import glob, os
|
import glob, os
|
||||||
if os.path.exists(txt):
|
if os.path.exists(txt):
|
||||||
@@ -192,11 +191,11 @@ def 解析一个Rect项目(txt, top_p, temperature, chatbot, history, systemProm
|
|||||||
report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何Rect文件: {txt}")
|
report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何Rect文件: {txt}")
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
return
|
return
|
||||||
yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
|
yield from 解析源代码(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt)
|
||||||
|
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 解析一个Golang项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def 解析一个Golang项目(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
history = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
import glob, os
|
import glob, os
|
||||||
if os.path.exists(txt):
|
if os.path.exists(txt):
|
||||||
@@ -211,4 +210,4 @@ def 解析一个Golang项目(txt, top_p, temperature, chatbot, history, systemPr
|
|||||||
report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何golang文件: {txt}")
|
report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何golang文件: {txt}")
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
return
|
return
|
||||||
yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
|
yield from 解析源代码(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from toolbox import CatchException, report_execption, write_results_to_file, pre
|
|||||||
fast_debug = False
|
fast_debug = False
|
||||||
|
|
||||||
|
|
||||||
def 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt):
|
def 解析Paper(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt):
|
||||||
import time, glob, os
|
import time, glob, os
|
||||||
print('begin analysis on:', file_manifest)
|
print('begin analysis on:', file_manifest)
|
||||||
for index, fp in enumerate(file_manifest):
|
for index, fp in enumerate(file_manifest):
|
||||||
@@ -20,7 +20,7 @@ def 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, hist
|
|||||||
if not fast_debug:
|
if not fast_debug:
|
||||||
msg = '正常'
|
msg = '正常'
|
||||||
# ** gpt request **
|
# ** gpt request **
|
||||||
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, history=[]) # 带超时倒计时
|
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, api_key, temperature, history=[]) # 带超时倒计时
|
||||||
|
|
||||||
print('[2] end gpt req')
|
print('[2] end gpt req')
|
||||||
chatbot[-1] = (i_say_show_user, gpt_say)
|
chatbot[-1] = (i_say_show_user, gpt_say)
|
||||||
@@ -38,7 +38,7 @@ def 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, hist
|
|||||||
if not fast_debug:
|
if not fast_debug:
|
||||||
msg = '正常'
|
msg = '正常'
|
||||||
# ** gpt request **
|
# ** gpt request **
|
||||||
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, temperature, history=history) # 带超时倒计时
|
gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, api_key, temperature, history=history) # 带超时倒计时
|
||||||
|
|
||||||
chatbot[-1] = (i_say, gpt_say)
|
chatbot[-1] = (i_say, gpt_say)
|
||||||
history.append(i_say); history.append(gpt_say)
|
history.append(i_say); history.append(gpt_say)
|
||||||
@@ -50,7 +50,7 @@ def 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, hist
|
|||||||
|
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 读文章写摘要(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def 读文章写摘要(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
history = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
import glob, os
|
import glob, os
|
||||||
if os.path.exists(txt):
|
if os.path.exists(txt):
|
||||||
@@ -67,4 +67,4 @@ def 读文章写摘要(txt, top_p, temperature, chatbot, history, systemPromptTx
|
|||||||
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.tex文件: {txt}")
|
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.tex文件: {txt}")
|
||||||
yield chatbot, history, '正常'
|
yield chatbot, history, '正常'
|
||||||
return
|
return
|
||||||
yield from 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
|
yield from 解析Paper(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from toolbox import CatchException, report_execption, write_results_to_file
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 高阶功能模板函数(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def 高阶功能模板函数(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
history = [] # 清空历史,以免输入溢出
|
history = [] # 清空历史,以免输入溢出
|
||||||
chatbot.append(("这是什么功能?", "[Local Message] 请注意,您正在调用一个[函数插件]的模板,该函数面向希望实现更多有趣功能的开发者,它可以作为创建新功能函数的模板。为了做到简单易读,该函数只有25行代码,所以不会实时反馈文字流或心跳,请耐心等待程序输出完成。此外我们也提供可同步处理大量文件的多线程Demo供您参考。您若希望分享新的功能模组,请不吝PR!"))
|
chatbot.append(("这是什么功能?", "[Local Message] 请注意,您正在调用一个[函数插件]的模板,该函数面向希望实现更多有趣功能的开发者,它可以作为创建新功能函数的模板。为了做到简单易读,该函数只有25行代码,所以不会实时反馈文字流或心跳,请耐心等待程序输出完成。此外我们也提供可同步处理大量文件的多线程Demo供您参考。您若希望分享新的功能模组,请不吝PR!"))
|
||||||
yield chatbot, history, '正常' # 由于请求gpt需要一段时间,我们先及时地做一次状态显示
|
yield chatbot, history, '正常' # 由于请求gpt需要一段时间,我们先及时地做一次状态显示
|
||||||
@@ -17,7 +17,7 @@ def 高阶功能模板函数(txt, top_p, temperature, chatbot, history, systemPr
|
|||||||
|
|
||||||
# history = [] 每次询问不携带之前的询问历史
|
# history = [] 每次询问不携带之前的询问历史
|
||||||
gpt_say = predict_no_ui_long_connection(
|
gpt_say = predict_no_ui_long_connection(
|
||||||
inputs=i_say, top_p=top_p, temperature=temperature, history=[],
|
inputs=i_say, top_p=top_p, api_key=api_key, temperature=temperature, history=[],
|
||||||
sys_prompt="当你想发送一张照片时,请使用Markdown, 并且不要有反斜线, 不要用代码块。使用 Unsplash API (https://source.unsplash.com/1280x720/? < PUT_YOUR_QUERY_HERE >)。") # 请求gpt,需要一段时间
|
sys_prompt="当你想发送一张照片时,请使用Markdown, 并且不要有反斜线, 不要用代码块。使用 Unsplash API (https://source.unsplash.com/1280x720/? < PUT_YOUR_QUERY_HERE >)。") # 请求gpt,需要一段时间
|
||||||
|
|
||||||
chatbot[-1] = (i_say, gpt_say)
|
chatbot[-1] = (i_say, gpt_say)
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@ def get_crazy_functionals():
|
|||||||
"AsButton": False, # 加入下拉菜单中
|
"AsButton": False, # 加入下拉菜单中
|
||||||
"Function": 解析一个Java项目
|
"Function": 解析一个Java项目
|
||||||
},
|
},
|
||||||
"解析整个React项目": {
|
"解析整个Java项目": {
|
||||||
"Color": "stop", # 按钮颜色
|
"Color": "stop", # 按钮颜色
|
||||||
"AsButton": False, # 加入下拉菜单中
|
"AsButton": False, # 加入下拉菜单中
|
||||||
"Function": 解析一个Rect项目
|
"Function": 解析一个Rect项目
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 262 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 264 KiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 11 MiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 12 MiB |
@@ -1,3 +1,4 @@
|
|||||||
|
assert False, "Huggingface版请运行app.py"
|
||||||
import os; os.environ['no_proxy'] = '*' # 避免代理网络产生意外污染
|
import os; os.environ['no_proxy'] = '*' # 避免代理网络产生意外污染
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
from predict import predict
|
from predict import predict
|
||||||
@@ -40,6 +41,9 @@ set_theme = adjust_theme()
|
|||||||
cancel_handles = []
|
cancel_handles = []
|
||||||
with gr.Blocks(theme=set_theme, analytics_enabled=False, css=advanced_css) as demo:
|
with gr.Blocks(theme=set_theme, analytics_enabled=False, css=advanced_css) as demo:
|
||||||
gr.HTML(title_html)
|
gr.HTML(title_html)
|
||||||
|
# To add a Duplicate Space badge
|
||||||
|
gr.HTML('''<center><a href="https://huggingface.co/spaces/qingxu98/gpt-academic?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>请您打开此页面后务必点击上方的“复制空间”(Duplicate Space)按钮!<br/>切忌在“复制空间”(Duplicate Space)之前填入API_KEY或进行提问,否则您的API_KEY将极可能被空间所有者攫取!</center>''')
|
||||||
|
|
||||||
with gr.Row().style(equal_height=True):
|
with gr.Row().style(equal_height=True):
|
||||||
with gr.Column(scale=2):
|
with gr.Column(scale=2):
|
||||||
chatbot = gr.Chatbot()
|
chatbot = gr.Chatbot()
|
||||||
@@ -47,7 +51,9 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False, css=advanced_css) as de
|
|||||||
history = gr.State([])
|
history = gr.State([])
|
||||||
with gr.Column(scale=1):
|
with gr.Column(scale=1):
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
txt = gr.Textbox(show_label=False, placeholder="Input question here.").style(container=False)
|
api_key = gr.Textbox(show_label=False, placeholder="输入API_KEY,输入后自动生效.").style(container=False)
|
||||||
|
with gr.Row():
|
||||||
|
txt = gr.Textbox(show_label=False, placeholder="输入问题.").style(container=False)
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
submitBtn = gr.Button("提交", variant="primary")
|
submitBtn = gr.Button("提交", variant="primary")
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
@@ -93,7 +99,7 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False, css=advanced_css) as de
|
|||||||
return ret
|
return ret
|
||||||
checkboxes.select(fn_area_visibility, [checkboxes], [area_basic_fn, area_crazy_fn] )
|
checkboxes.select(fn_area_visibility, [checkboxes], [area_basic_fn, area_crazy_fn] )
|
||||||
# 整理反复出现的控件句柄组合
|
# 整理反复出现的控件句柄组合
|
||||||
input_combo = [txt, top_p, temperature, chatbot, history, system_prompt]
|
input_combo = [txt, top_p, api_key, temperature, chatbot, history, system_prompt]
|
||||||
output_combo = [chatbot, history, status]
|
output_combo = [chatbot, history, status]
|
||||||
predict_args = dict(fn=predict, inputs=input_combo, outputs=output_combo)
|
predict_args = dict(fn=predict, inputs=input_combo, outputs=output_combo)
|
||||||
empty_txt_args = dict(fn=lambda: "", inputs=[], outputs=[txt]) # 用于在提交后清空输入栏
|
empty_txt_args = dict(fn=lambda: "", inputs=[], outputs=[txt]) # 用于在提交后清空输入栏
|
||||||
@@ -134,14 +140,12 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False, css=advanced_css) as de
|
|||||||
# gradio的inbrowser触发不太稳定,回滚代码到原始的浏览器打开函数
|
# gradio的inbrowser触发不太稳定,回滚代码到原始的浏览器打开函数
|
||||||
def auto_opentab_delay():
|
def auto_opentab_delay():
|
||||||
import threading, webbrowser, time
|
import threading, webbrowser, time
|
||||||
print(f"如果浏览器没有自动打开,请复制并转到以下URL:")
|
print(f"如果浏览器没有自动打开,请复制并转到以下URL: http://localhost:{PORT}")
|
||||||
print(f"\t(亮色主体): http://localhost:{PORT}")
|
|
||||||
print(f"\t(暗色主体): http://localhost:{PORT}/?__dark-theme=true")
|
|
||||||
def open():
|
def open():
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
webbrowser.open_new_tab(f"http://localhost:{PORT}/?__dark-theme=true")
|
webbrowser.open_new_tab(f"http://localhost:{PORT}")
|
||||||
threading.Thread(target=open, name="open-browser", daemon=True).start()
|
threading.Thread(target=open, name="open-browser", daemon=True).start()
|
||||||
|
|
||||||
auto_opentab_delay()
|
auto_opentab_delay()
|
||||||
demo.title = "ChatGPT 学术优化"
|
demo.title = "ChatGPT 学术优化"
|
||||||
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", share=Flase, server_port=8080, auth=chunzhi233233)
|
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", share=False)
|
||||||
|
|||||||
+11
-15
@@ -38,18 +38,18 @@ def get_full_error(chunk, stream_response):
|
|||||||
break
|
break
|
||||||
return chunk
|
return chunk
|
||||||
|
|
||||||
def predict_no_ui(inputs, top_p, temperature, history=[], sys_prompt=""):
|
def predict_no_ui(inputs, top_p, api_key, temperature, history=[], sys_prompt=""):
|
||||||
"""
|
"""
|
||||||
发送至chatGPT,等待回复,一次性完成,不显示中间过程。
|
发送至chatGPT,等待回复,一次性完成,不显示中间过程。
|
||||||
predict函数的简化版。
|
predict函数的简化版。
|
||||||
用于payload比较大的情况,或者用于实现多线、带嵌套的复杂功能。
|
用于payload比较大的情况,或者用于实现多线、带嵌套的复杂功能。
|
||||||
|
|
||||||
inputs 是本次问询的输入
|
inputs 是本次问询的输入
|
||||||
top_p, temperature是chatGPT的内部调优参数
|
top_p, api_key, temperature是chatGPT的内部调优参数
|
||||||
history 是之前的对话列表
|
history 是之前的对话列表
|
||||||
(注意无论是inputs还是history,内容太长了都会触发token数量溢出的错误,然后raise ConnectionAbortedError)
|
(注意无论是inputs还是history,内容太长了都会触发token数量溢出的错误,然后raise ConnectionAbortedError)
|
||||||
"""
|
"""
|
||||||
headers, payload = generate_payload(inputs, top_p, temperature, history, system_prompt=sys_prompt, stream=False)
|
headers, payload = generate_payload(inputs, top_p, api_key, temperature, history, system_prompt=sys_prompt, stream=False)
|
||||||
|
|
||||||
retry = 0
|
retry = 0
|
||||||
while True:
|
while True:
|
||||||
@@ -71,12 +71,11 @@ def predict_no_ui(inputs, top_p, temperature, history=[], sys_prompt=""):
|
|||||||
raise ConnectionAbortedError("Json解析不合常规,可能是文本过长" + response.text)
|
raise ConnectionAbortedError("Json解析不合常规,可能是文本过长" + response.text)
|
||||||
|
|
||||||
|
|
||||||
def predict_no_ui_long_connection(inputs, top_p, temperature, history=[], sys_prompt="", observe_window=None):
|
def predict_no_ui_long_connection(inputs, top_p, api_key, temperature, history=[], sys_prompt=""):
|
||||||
"""
|
"""
|
||||||
发送至chatGPT,等待回复,一次性完成,不显示中间过程。但内部用stream的方法避免有人中途掐网线。
|
发送至chatGPT,等待回复,一次性完成,不显示中间过程。但内部用stream的方法避免有人中途掐网线。
|
||||||
observe_window:用于负责跨越线程传递已经输出的部分,大部分时候仅仅为了fancy的视觉效果,留空即可
|
|
||||||
"""
|
"""
|
||||||
headers, payload = generate_payload(inputs, top_p, temperature, history, system_prompt=sys_prompt, stream=True)
|
headers, payload = generate_payload(inputs, top_p, api_key, temperature, history, system_prompt=sys_prompt, stream=True)
|
||||||
|
|
||||||
retry = 0
|
retry = 0
|
||||||
while True:
|
while True:
|
||||||
@@ -106,23 +105,20 @@ def predict_no_ui_long_connection(inputs, top_p, temperature, history=[], sys_pr
|
|||||||
delta = json_data["delta"]
|
delta = json_data["delta"]
|
||||||
if len(delta) == 0: break
|
if len(delta) == 0: break
|
||||||
if "role" in delta: continue
|
if "role" in delta: continue
|
||||||
if "content" in delta:
|
if "content" in delta: result += delta["content"]; print(delta["content"], end='')
|
||||||
result += delta["content"]
|
|
||||||
print(delta["content"], end='')
|
|
||||||
if observe_window is not None: observe_window[0] += delta["content"]
|
|
||||||
else: raise RuntimeError("意外Json结构:"+delta)
|
else: raise RuntimeError("意外Json结构:"+delta)
|
||||||
if json_data['finish_reason'] == 'length':
|
if json_data['finish_reason'] == 'length':
|
||||||
raise ConnectionAbortedError("正常结束,但显示Token不足。")
|
raise ConnectionAbortedError("正常结束,但显示Token不足。")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def predict(inputs, top_p, temperature, chatbot=[], history=[], system_prompt='',
|
def predict(inputs, top_p, api_key, temperature, chatbot=[], history=[], system_prompt='',
|
||||||
stream = True, additional_fn=None):
|
stream = True, additional_fn=None):
|
||||||
"""
|
"""
|
||||||
发送至chatGPT,流式获取输出。
|
发送至chatGPT,流式获取输出。
|
||||||
用于基础的对话功能。
|
用于基础的对话功能。
|
||||||
inputs 是本次问询的输入
|
inputs 是本次问询的输入
|
||||||
top_p, temperature是chatGPT的内部调优参数
|
top_p, api_key, temperature是chatGPT的内部调优参数
|
||||||
history 是之前的对话列表(注意无论是inputs还是history,内容太长了都会触发token数量溢出的错误)
|
history 是之前的对话列表(注意无论是inputs还是history,内容太长了都会触发token数量溢出的错误)
|
||||||
chatbot 为WebUI中显示的对话列表,修改它,然后yeild出去,可以直接修改对话界面内容
|
chatbot 为WebUI中显示的对话列表,修改它,然后yeild出去,可以直接修改对话界面内容
|
||||||
additional_fn代表点击的哪个按钮,按钮见functional.py
|
additional_fn代表点击的哪个按钮,按钮见functional.py
|
||||||
@@ -140,7 +136,7 @@ def predict(inputs, top_p, temperature, chatbot=[], history=[], system_prompt=''
|
|||||||
chatbot.append((inputs, ""))
|
chatbot.append((inputs, ""))
|
||||||
yield chatbot, history, "等待响应"
|
yield chatbot, history, "等待响应"
|
||||||
|
|
||||||
headers, payload = generate_payload(inputs, top_p, temperature, history, system_prompt, stream)
|
headers, payload = generate_payload(inputs, top_p, api_key, temperature, history, system_prompt, stream)
|
||||||
history.append(inputs); history.append(" ")
|
history.append(inputs); history.append(" ")
|
||||||
|
|
||||||
retry = 0
|
retry = 0
|
||||||
@@ -202,13 +198,13 @@ def predict(inputs, top_p, temperature, chatbot=[], history=[], system_prompt=''
|
|||||||
yield chatbot, history, "Json异常" + error_msg
|
yield chatbot, history, "Json异常" + error_msg
|
||||||
return
|
return
|
||||||
|
|
||||||
def generate_payload(inputs, top_p, temperature, history, system_prompt, stream):
|
def generate_payload(inputs, top_p, api_key, temperature, history, system_prompt, stream):
|
||||||
"""
|
"""
|
||||||
整合所有信息,选择LLM模型,生成http请求,为发送请求做准备
|
整合所有信息,选择LLM模型,生成http请求,为发送请求做准备
|
||||||
"""
|
"""
|
||||||
headers = {
|
headers = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"Authorization": f"Bearer {API_KEY}"
|
"Authorization": f"Bearer {api_key}"
|
||||||
}
|
}
|
||||||
|
|
||||||
conversation_cnt = len(history) // 2
|
conversation_cnt = len(history) // 2
|
||||||
|
|||||||
@@ -90,12 +90,12 @@ async def run(context, max_token=512):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def predict_tgui(inputs, top_p, temperature, chatbot=[], history=[], system_prompt='', stream = True, additional_fn=None):
|
def predict_tgui(inputs, top_p, api_key, temperature, chatbot=[], history=[], system_prompt='', stream = True, additional_fn=None):
|
||||||
"""
|
"""
|
||||||
发送至chatGPT,流式获取输出。
|
发送至chatGPT,流式获取输出。
|
||||||
用于基础的对话功能。
|
用于基础的对话功能。
|
||||||
inputs 是本次问询的输入
|
inputs 是本次问询的输入
|
||||||
top_p, temperature是chatGPT的内部调优参数
|
top_p, api_key, temperature是chatGPT的内部调优参数
|
||||||
history 是之前的对话列表(注意无论是inputs还是history,内容太长了都会触发token数量溢出的错误)
|
history 是之前的对话列表(注意无论是inputs还是history,内容太长了都会触发token数量溢出的错误)
|
||||||
chatbot 为WebUI中显示的对话列表,修改它,然后yeild出去,可以直接修改对话界面内容
|
chatbot 为WebUI中显示的对话列表,修改它,然后yeild出去,可以直接修改对话界面内容
|
||||||
additional_fn代表点击的哪个按钮,按钮见functional.py
|
additional_fn代表点击的哪个按钮,按钮见functional.py
|
||||||
@@ -144,7 +144,7 @@ def predict_tgui(inputs, top_p, temperature, chatbot=[], history=[], system_prom
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def predict_tgui_no_ui(inputs, top_p, temperature, history=[], sys_prompt=""):
|
def predict_tgui_no_ui(inputs, top_p, api_key, temperature, history=[], sys_prompt=""):
|
||||||
raw_input = "What I would like to say is the following: " + inputs
|
raw_input = "What I would like to say is the following: " + inputs
|
||||||
prompt = inputs
|
prompt = inputs
|
||||||
tgui_say = ""
|
tgui_say = ""
|
||||||
|
|||||||
+4
-2
@@ -3,5 +3,7 @@ requests[socks]
|
|||||||
mdtex2html
|
mdtex2html
|
||||||
Markdown
|
Markdown
|
||||||
latex2mathml
|
latex2mathml
|
||||||
openai
|
pdfminer
|
||||||
transformers
|
beautifulsoup4
|
||||||
|
rarfile
|
||||||
|
py7zr
|
||||||
+5
-5
@@ -131,11 +131,11 @@
|
|||||||
|
|
||||||
这个程序文件中包含了几个函数,分别是:
|
这个程序文件中包含了几个函数,分别是:
|
||||||
|
|
||||||
1. `解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)`:通过输入文件路径列表对程序文件进行逐文件分析,根据分析结果做出整体功能和构架的概括,并生成包括每个文件功能的markdown表格。
|
1. `解析源代码(file_manifest, project_folder, top_p, api_key, temperature, chatbot, history, systemPromptTxt)`:通过输入文件路径列表对程序文件进行逐文件分析,根据分析结果做出整体功能和构架的概括,并生成包括每个文件功能的markdown表格。
|
||||||
2. `解析项目本身(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT)`:对当前文件夹下的所有Python文件及其子文件夹进行逐文件分析,并生成markdown表格。
|
2. `解析项目本身(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT)`:对当前文件夹下的所有Python文件及其子文件夹进行逐文件分析,并生成markdown表格。
|
||||||
3. `解析一个Python项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT)`:对指定路径下的所有Python文件及其子文件夹进行逐文件分析,并生成markdown表格。
|
3. `解析一个Python项目(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT)`:对指定路径下的所有Python文件及其子文件夹进行逐文件分析,并生成markdown表格。
|
||||||
4. `解析一个C项目的头文件(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT)`:对指定路径下的所有头文件进行逐文件分析,并生成markdown表格。
|
4. `解析一个C项目的头文件(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT)`:对指定路径下的所有头文件进行逐文件分析,并生成markdown表格。
|
||||||
5. `解析一个C项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT)`:对指定路径下的所有.h、.cpp、.c文件及其子文件夹进行逐文件分析,并生成markdown表格。
|
5. `解析一个C项目(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT)`:对指定路径下的所有.h、.cpp、.c文件及其子文件夹进行逐文件分析,并生成markdown表格。
|
||||||
|
|
||||||
程序中还包含了一些辅助函数和变量,如CatchException装饰器函数,report_execption函数、write_results_to_file函数等。在执行过程中还会调用其他模块中的函数,如toolbox模块的函数和predict模块的函数。
|
程序中还包含了一些辅助函数和变量,如CatchException装饰器函数,report_execption函数、write_results_to_file函数等。在执行过程中还会调用其他模块中的函数,如toolbox模块的函数和predict模块的函数。
|
||||||
|
|
||||||
|
|||||||
+15
-15
@@ -16,13 +16,13 @@ def get_reduce_token_percent(text):
|
|||||||
except:
|
except:
|
||||||
return 0.5, '不详'
|
return 0.5, '不详'
|
||||||
|
|
||||||
def predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, history=[], sys_prompt='', long_connection=True):
|
def predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, api_key, temperature, history=[], sys_prompt='', long_connection=True):
|
||||||
"""
|
"""
|
||||||
调用简单的predict_no_ui接口,但是依然保留了些许界面心跳功能,当对话太长时,会自动采用二分法截断
|
调用简单的predict_no_ui接口,但是依然保留了些许界面心跳功能,当对话太长时,会自动采用二分法截断
|
||||||
i_say: 当前输入
|
i_say: 当前输入
|
||||||
i_say_show_user: 显示到对话界面上的当前输入,例如,输入整个文件时,你绝对不想把文件的内容都糊到对话界面上
|
i_say_show_user: 显示到对话界面上的当前输入,例如,输入整个文件时,你绝对不想把文件的内容都糊到对话界面上
|
||||||
chatbot: 对话界面句柄
|
chatbot: 对话界面句柄
|
||||||
top_p, temperature: gpt参数
|
top_p, api_key, temperature: gpt参数
|
||||||
history: gpt参数 对话历史
|
history: gpt参数 对话历史
|
||||||
sys_prompt: gpt参数 sys_prompt
|
sys_prompt: gpt参数 sys_prompt
|
||||||
long_connection: 是否采用更稳定的连接方式(推荐)
|
long_connection: 是否采用更稳定的连接方式(推荐)
|
||||||
@@ -39,9 +39,9 @@ def predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temp
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
if long_connection:
|
if long_connection:
|
||||||
mutable[0] = predict_no_ui_long_connection(inputs=i_say, top_p=top_p, temperature=temperature, history=history, sys_prompt=sys_prompt)
|
mutable[0] = predict_no_ui_long_connection(inputs=i_say, top_p=top_p, api_key=api_key, temperature=temperature, history=history, sys_prompt=sys_prompt)
|
||||||
else:
|
else:
|
||||||
mutable[0] = predict_no_ui(inputs=i_say, top_p=top_p, temperature=temperature, history=history, sys_prompt=sys_prompt)
|
mutable[0] = predict_no_ui(inputs=i_say, top_p=top_p, api_key=api_key, temperature=temperature, history=history, sys_prompt=sys_prompt)
|
||||||
break
|
break
|
||||||
except ConnectionAbortedError as token_exceeded_error:
|
except ConnectionAbortedError as token_exceeded_error:
|
||||||
# 尝试计算比例,尽可能多地保留文本
|
# 尝试计算比例,尽可能多地保留文本
|
||||||
@@ -108,9 +108,9 @@ def CatchException(f):
|
|||||||
装饰器函数,捕捉函数f中的异常并封装到一个生成器中返回,并显示到聊天当中。
|
装饰器函数,捕捉函数f中的异常并封装到一个生成器中返回,并显示到聊天当中。
|
||||||
"""
|
"""
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def decorated(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
def decorated(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
||||||
try:
|
try:
|
||||||
yield from f(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT)
|
yield from f(txt, top_p, api_key, temperature, chatbot, history, systemPromptTxt, WEB_PORT)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
from check_proxy import check_proxy
|
from check_proxy import check_proxy
|
||||||
from toolbox import get_conf
|
from toolbox import get_conf
|
||||||
@@ -303,7 +303,7 @@ def on_file_uploaded(files, chatbot, txt):
|
|||||||
def on_report_generated(files, chatbot):
|
def on_report_generated(files, chatbot):
|
||||||
from toolbox import find_recent_files
|
from toolbox import find_recent_files
|
||||||
report_files = find_recent_files('gpt_log')
|
report_files = find_recent_files('gpt_log')
|
||||||
if len(report_files) == 0: return None, chatbot
|
if len(report_files) == 0: return files, chatbot
|
||||||
# files.extend(report_files)
|
# files.extend(report_files)
|
||||||
chatbot.append(['汇总报告如何远程获取?', '汇总报告已经添加到右侧“文件上传区”(可能处于折叠状态),请查收。'])
|
chatbot.append(['汇总报告如何远程获取?', '汇总报告已经添加到右侧“文件上传区”(可能处于折叠状态),请查收。'])
|
||||||
return report_files, chatbot
|
return report_files, chatbot
|
||||||
@@ -313,14 +313,14 @@ def read_single_conf_with_lru_cache(arg):
|
|||||||
try: r = getattr(importlib.import_module('config_private'), arg)
|
try: r = getattr(importlib.import_module('config_private'), arg)
|
||||||
except: r = getattr(importlib.import_module('config'), arg)
|
except: r = getattr(importlib.import_module('config'), arg)
|
||||||
# 在读取API_KEY时,检查一下是不是忘了改config
|
# 在读取API_KEY时,检查一下是不是忘了改config
|
||||||
if arg=='API_KEY':
|
# if arg=='API_KEY':
|
||||||
# 正确的 API_KEY 是 "sk-" + 48 位大小写字母数字的组合
|
# # 正确的 API_KEY 是 "sk-" + 48 位大小写字母数字的组合
|
||||||
API_MATCH = re.match(r"sk-[a-zA-Z0-9]{48}$", r)
|
# API_MATCH = re.match(r"sk-[a-zA-Z0-9]{48}$", r)
|
||||||
if API_MATCH:
|
# if API_MATCH:
|
||||||
print(f"[API_KEY] 您的 API_KEY 是: {r[:15]}*** API_KEY 导入成功")
|
# print(f"[API_KEY] 您的 API_KEY 是: {r[:15]}*** API_KEY 导入成功")
|
||||||
else:
|
# else:
|
||||||
assert False, "正确的 API_KEY 是 'sk-' + '48 位大小写字母数字' 的组合,请在config文件中修改API密钥, 添加海外代理之后再运行。" + \
|
# assert False, "正确的 API_KEY 是 'sk-' + '48 位大小写字母数字' 的组合,请在config文件中修改API密钥, 添加海外代理之后再运行。" + \
|
||||||
"(如果您刚更新过代码,请确保旧版config_private文件中没有遗留任何新增键值)"
|
# "(如果您刚更新过代码,请确保旧版config_private文件中没有遗留任何新增键值)"
|
||||||
if arg=='proxies':
|
if arg=='proxies':
|
||||||
if r is None:
|
if r is None:
|
||||||
print('[PROXY] 网络代理状态:未配置。无代理状态下很可能无法访问。建议:检查USE_PROXY选项是否修改。')
|
print('[PROXY] 网络代理状态:未配置。无代理状态下很可能无法访问。建议:检查USE_PROXY选项是否修改。')
|
||||||
|
|||||||
Reference in New Issue
Block a user