Merge branch 'master' of https://github.com/Okabe-Rintarou-0/chatgpt_academic into Okabe-Rintarou-0-master
This commit is contained in:
		
							parent
							
								
									23776b90b9
								
							
						
					
					
						commit
						c78254cd86
					
				@ -20,7 +20,7 @@ else:
 | 
				
			|||||||
    print('网络代理状态:未配置。无代理状态下很可能无法访问。')
 | 
					    print('网络代理状态:未配置。无代理状态下很可能无法访问。')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 发送请求到OpenAI后,等待多久判定为超时
 | 
					# 发送请求到OpenAI后,等待多久判定为超时
 | 
				
			||||||
TIMEOUT_SECONDS = 20
 | 
					TIMEOUT_SECONDS = 25
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 网页的端口, -1代表随机端口
 | 
					# 网页的端口, -1代表随机端口
 | 
				
			||||||
WEB_PORT = -1
 | 
					WEB_PORT = -1
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										11
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								main.py
									
									
									
									
									
								
							@ -36,6 +36,7 @@ gr.Chatbot.postprocess = format_io
 | 
				
			|||||||
from theme import adjust_theme
 | 
					from theme import adjust_theme
 | 
				
			||||||
set_theme = adjust_theme()
 | 
					set_theme = adjust_theme()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					can_cancel_events = []
 | 
				
			||||||
with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
 | 
					with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
 | 
				
			||||||
    gr.HTML(title_html)
 | 
					    gr.HTML(title_html)
 | 
				
			||||||
    with gr.Row():
 | 
					    with gr.Row():
 | 
				
			||||||
@ -52,6 +53,7 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
 | 
				
			|||||||
                    with gr.Row():
 | 
					                    with gr.Row():
 | 
				
			||||||
                        resetBtn = gr.Button("重置", variant="secondary")
 | 
					                        resetBtn = gr.Button("重置", variant="secondary")
 | 
				
			||||||
                        submitBtn = gr.Button("提交", variant="primary")
 | 
					                        submitBtn = gr.Button("提交", variant="primary")
 | 
				
			||||||
 | 
					                        stopBtn = gr.Button("停止", variant="stop")
 | 
				
			||||||
            with gr.Row():
 | 
					            with gr.Row():
 | 
				
			||||||
                from check_proxy import check_proxy
 | 
					                from check_proxy import check_proxy
 | 
				
			||||||
                statusDisplay = gr.Markdown(f"Tip: 按Enter提交, 按Shift+Enter换行. \nNetwork: {check_proxy(proxies)}\nModel: {LLM_MODEL}")
 | 
					                statusDisplay = gr.Markdown(f"Tip: 按Enter提交, 按Shift+Enter换行. \nNetwork: {check_proxy(proxies)}\nModel: {LLM_MODEL}")
 | 
				
			||||||
@ -77,14 +79,15 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
 | 
				
			|||||||
    predict_args = dict(fn=predict, inputs=[txt, top_p, temperature, chatbot, history, system_prompt], outputs=[chatbot, history, statusDisplay], show_progress=True)
 | 
					    predict_args = dict(fn=predict, inputs=[txt, top_p, temperature, chatbot, history, system_prompt], outputs=[chatbot, history, statusDisplay], show_progress=True)
 | 
				
			||||||
    empty_txt_args = dict(fn=lambda: "", inputs=[], outputs=[txt])
 | 
					    empty_txt_args = dict(fn=lambda: "", inputs=[], outputs=[txt])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    txt.submit(**predict_args)
 | 
					    can_cancel_events.append(txt.submit(**predict_args))
 | 
				
			||||||
    txt.submit(**empty_txt_args)
 | 
					    txt.submit(**empty_txt_args)
 | 
				
			||||||
    submitBtn.click(**predict_args)
 | 
					    can_cancel_events.append(submitBtn.click(**predict_args))
 | 
				
			||||||
    submitBtn.click(**empty_txt_args)
 | 
					    submitBtn.click(**empty_txt_args)
 | 
				
			||||||
    resetBtn.click(lambda: ([], [], "已重置"), None, [chatbot, history, statusDisplay])
 | 
					    resetBtn.click(lambda: ([], [], "已重置"), None, [chatbot, history, statusDisplay])
 | 
				
			||||||
    for k in functional:
 | 
					    for k in functional:
 | 
				
			||||||
        functional[k]["Button"].click(predict,
 | 
					        click_handle = functional[k]["Button"].click(predict,
 | 
				
			||||||
            [txt, top_p, temperature, chatbot, history, system_prompt, gr.State(True), gr.State(k)], [chatbot, history, statusDisplay], show_progress=True)
 | 
					            [txt, top_p, temperature, chatbot, history, system_prompt, gr.State(True), gr.State(k)], [chatbot, history, statusDisplay], show_progress=True)
 | 
				
			||||||
 | 
					        can_cancel_events.append(click_handle)
 | 
				
			||||||
    file_upload.upload(on_file_uploaded, [file_upload, chatbot, txt], [chatbot, txt])
 | 
					    file_upload.upload(on_file_uploaded, [file_upload, chatbot, txt], [chatbot, txt])
 | 
				
			||||||
    for k in crazy_functional:
 | 
					    for k in crazy_functional:
 | 
				
			||||||
        click_handle = crazy_functional[k]["Button"].click(crazy_functional[k]["Function"],
 | 
					        click_handle = crazy_functional[k]["Button"].click(crazy_functional[k]["Function"],
 | 
				
			||||||
@ -92,6 +95,8 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
        try: click_handle.then(on_report_generated, [file_upload, chatbot], [file_upload, chatbot])
 | 
					        try: click_handle.then(on_report_generated, [file_upload, chatbot], [file_upload, chatbot])
 | 
				
			||||||
        except: pass
 | 
					        except: pass
 | 
				
			||||||
 | 
					        can_cancel_events.append(click_handle)
 | 
				
			||||||
 | 
					    stopBtn.click(fn=None, inputs=None, outputs=None, cancels=can_cancel_events)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# gradio的inbrowser触发不太稳定,回滚代码到原始的浏览器打开函数
 | 
					# gradio的inbrowser触发不太稳定,回滚代码到原始的浏览器打开函数
 | 
				
			||||||
def auto_opentab_delay():
 | 
					def auto_opentab_delay():
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user