Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	Merge branch 'master' of https://github.com/Okabe-Rintarou-0/chatgpt_academic into Okabe-Rintarou-0-master
Browse files
    	
        config.py
    CHANGED
    
    | @@ -20,7 +20,7 @@ else: | |
| 20 | 
             
                print('网络代理状态:未配置。无代理状态下很可能无法访问。')
         | 
| 21 |  | 
| 22 | 
             
            # 发送请求到OpenAI后,等待多久判定为超时
         | 
| 23 | 
            -
            TIMEOUT_SECONDS =  | 
| 24 |  | 
| 25 | 
             
            # 网页的端口, -1代表随机端口
         | 
| 26 | 
             
            WEB_PORT = -1
         | 
|  | |
| 20 | 
             
                print('网络代理状态:未配置。无代理状态下很可能无法访问。')
         | 
| 21 |  | 
| 22 | 
             
            # 发送请求到OpenAI后,等待多久判定为超时
         | 
| 23 | 
            +
            TIMEOUT_SECONDS = 25
         | 
| 24 |  | 
| 25 | 
             
            # 网页的端口, -1代表随机端口
         | 
| 26 | 
             
            WEB_PORT = -1
         | 
    	
        main.py
    CHANGED
    
    | @@ -36,6 +36,7 @@ gr.Chatbot.postprocess = format_io | |
| 36 | 
             
            from theme import adjust_theme
         | 
| 37 | 
             
            set_theme = adjust_theme()
         | 
| 38 |  | 
|  | |
| 39 | 
             
            with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
         | 
| 40 | 
             
                gr.HTML(title_html)
         | 
| 41 | 
             
                with gr.Row():
         | 
| @@ -52,6 +53,7 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo: | |
| 52 | 
             
                                with gr.Row():
         | 
| 53 | 
             
                                    resetBtn = gr.Button("重置", variant="secondary")
         | 
| 54 | 
             
                                    submitBtn = gr.Button("提交", variant="primary")
         | 
|  | |
| 55 | 
             
                        with gr.Row():
         | 
| 56 | 
             
                            from check_proxy import check_proxy
         | 
| 57 | 
             
                            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: | |
| 77 | 
             
                predict_args = dict(fn=predict, inputs=[txt, top_p, temperature, chatbot, history, system_prompt], outputs=[chatbot, history, statusDisplay], show_progress=True)
         | 
| 78 | 
             
                empty_txt_args = dict(fn=lambda: "", inputs=[], outputs=[txt])
         | 
| 79 |  | 
| 80 | 
            -
                txt.submit(**predict_args)
         | 
| 81 | 
             
                txt.submit(**empty_txt_args)
         | 
| 82 | 
            -
                submitBtn.click(**predict_args)
         | 
| 83 | 
             
                submitBtn.click(**empty_txt_args)
         | 
| 84 | 
             
                resetBtn.click(lambda: ([], [], "已重置"), None, [chatbot, history, statusDisplay])
         | 
| 85 | 
             
                for k in functional:
         | 
| 86 | 
            -
                    functional[k]["Button"].click(predict,
         | 
| 87 | 
             
                        [txt, top_p, temperature, chatbot, history, system_prompt, gr.State(True), gr.State(k)], [chatbot, history, statusDisplay], show_progress=True)
         | 
|  | |
| 88 | 
             
                file_upload.upload(on_file_uploaded, [file_upload, chatbot, txt], [chatbot, txt])
         | 
| 89 | 
             
                for k in crazy_functional:
         | 
| 90 | 
             
                    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: | |
| 92 | 
             
                    )
         | 
| 93 | 
             
                    try: click_handle.then(on_report_generated, [file_upload, chatbot], [file_upload, chatbot])
         | 
| 94 | 
             
                    except: pass
         | 
|  | |
|  | |
| 95 |  | 
| 96 | 
             
            # gradio的inbrowser触发不太稳定,回滚代码到原始的浏览器打开函数
         | 
| 97 | 
             
            def auto_opentab_delay():
         | 
|  | |
| 36 | 
             
            from theme import adjust_theme
         | 
| 37 | 
             
            set_theme = adjust_theme()
         | 
| 38 |  | 
| 39 | 
            +
            can_cancel_events = []
         | 
| 40 | 
             
            with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
         | 
| 41 | 
             
                gr.HTML(title_html)
         | 
| 42 | 
             
                with gr.Row():
         | 
|  | |
| 53 | 
             
                                with gr.Row():
         | 
| 54 | 
             
                                    resetBtn = gr.Button("重置", variant="secondary")
         | 
| 55 | 
             
                                    submitBtn = gr.Button("提交", variant="primary")
         | 
| 56 | 
            +
                                    stopBtn = gr.Button("停止", variant="stop")
         | 
| 57 | 
             
                        with gr.Row():
         | 
| 58 | 
             
                            from check_proxy import check_proxy
         | 
| 59 | 
             
                            statusDisplay = gr.Markdown(f"Tip: 按Enter提交, 按Shift+Enter换行. \nNetwork: {check_proxy(proxies)}\nModel: {LLM_MODEL}")
         | 
|  | |
| 79 | 
             
                predict_args = dict(fn=predict, inputs=[txt, top_p, temperature, chatbot, history, system_prompt], outputs=[chatbot, history, statusDisplay], show_progress=True)
         | 
| 80 | 
             
                empty_txt_args = dict(fn=lambda: "", inputs=[], outputs=[txt])
         | 
| 81 |  | 
| 82 | 
            +
                can_cancel_events.append(txt.submit(**predict_args))
         | 
| 83 | 
             
                txt.submit(**empty_txt_args)
         | 
| 84 | 
            +
                can_cancel_events.append(submitBtn.click(**predict_args))
         | 
| 85 | 
             
                submitBtn.click(**empty_txt_args)
         | 
| 86 | 
             
                resetBtn.click(lambda: ([], [], "已重置"), None, [chatbot, history, statusDisplay])
         | 
| 87 | 
             
                for k in functional:
         | 
| 88 | 
            +
                    click_handle = functional[k]["Button"].click(predict,
         | 
| 89 | 
             
                        [txt, top_p, temperature, chatbot, history, system_prompt, gr.State(True), gr.State(k)], [chatbot, history, statusDisplay], show_progress=True)
         | 
| 90 | 
            +
                    can_cancel_events.append(click_handle)
         | 
| 91 | 
             
                file_upload.upload(on_file_uploaded, [file_upload, chatbot, txt], [chatbot, txt])
         | 
| 92 | 
             
                for k in crazy_functional:
         | 
| 93 | 
             
                    click_handle = crazy_functional[k]["Button"].click(crazy_functional[k]["Function"],
         | 
|  | |
| 95 | 
             
                    )
         | 
| 96 | 
             
                    try: click_handle.then(on_report_generated, [file_upload, chatbot], [file_upload, chatbot])
         | 
| 97 | 
             
                    except: pass
         | 
| 98 | 
            +
                    can_cancel_events.append(click_handle)
         | 
| 99 | 
            +
                stopBtn.click(fn=None, inputs=None, outputs=None, cancels=can_cancel_events)
         | 
| 100 |  | 
| 101 | 
             
            # gradio的inbrowser触发不太稳定,回滚代码到原始的浏览器打开函数
         | 
| 102 | 
             
            def auto_opentab_delay():
         |