Merge branch 'enhance-chataca' of https://github.com/fulyaec/chatgpt_academic into fulyaec-enhance-chataca
This commit is contained in:
		
						commit
						b655feedde
					
				
							
								
								
									
										5
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								main.py
									
									
									
									
									
								
							@ -10,7 +10,7 @@ proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION = \
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# 如果WEB_PORT是-1, 则随机选取WEB端口
 | 
					# 如果WEB_PORT是-1, 则随机选取WEB端口
 | 
				
			||||||
PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT
 | 
					PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT
 | 
				
			||||||
AUTHENTICATION = None if AUTHENTICATION == [] else AUTHENTICATION
 | 
					if not AUTHENTICATION: AUTHENTICATION = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
initial_prompt = "Serve me as a writing and programming assistant."
 | 
					initial_prompt = "Serve me as a writing and programming assistant."
 | 
				
			||||||
title_html = """<h1 align="center">ChatGPT 学术优化</h1>"""
 | 
					title_html = """<h1 align="center">ChatGPT 学术优化</h1>"""
 | 
				
			||||||
@ -105,8 +105,7 @@ def auto_opentab_delay():
 | 
				
			|||||||
    def open(): 
 | 
					    def open(): 
 | 
				
			||||||
        time.sleep(2)
 | 
					        time.sleep(2)
 | 
				
			||||||
        webbrowser.open_new_tab(f'http://localhost:{PORT}')
 | 
					        webbrowser.open_new_tab(f'http://localhost:{PORT}')
 | 
				
			||||||
    t = threading.Thread(target=open)
 | 
					    threading.Thread(target=open, name="open-browser", daemon=True).start()
 | 
				
			||||||
    t.daemon = True; t.start()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
auto_opentab_delay()
 | 
					auto_opentab_delay()
 | 
				
			||||||
demo.title = "ChatGPT 学术优化"
 | 
					demo.title = "ChatGPT 学术优化"
 | 
				
			||||||
 | 
				
			|||||||
@ -237,13 +237,10 @@ def get_conf(*args):
 | 
				
			|||||||
        except: r = getattr(importlib.import_module('config'), arg)
 | 
					        except: r = getattr(importlib.import_module('config'), arg)
 | 
				
			||||||
        res.append(r)
 | 
					        res.append(r)
 | 
				
			||||||
        # 在读取API_KEY时,检查一下是不是忘了改config
 | 
					        # 在读取API_KEY时,检查一下是不是忘了改config
 | 
				
			||||||
        if arg=='API_KEY' and len(r) != 51:
 | 
					        assert arg != 'API_KEY' or len(r) == 51, "正确的API_KEY密钥是51位,请在config文件中修改API密钥, 添加海外代理之后再运行。" \
 | 
				
			||||||
            assert False, "正确的API_KEY密钥是51位,请在config文件中修改API密钥, 添加海外代理之后再运行。" + \
 | 
					 | 
				
			||||||
                        "(如果您刚更新过代码,请确保旧版config_private文件中没有遗留任何新增键值)"
 | 
					                        "(如果您刚更新过代码,请确保旧版config_private文件中没有遗留任何新增键值)"
 | 
				
			||||||
    return res
 | 
					    return res
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def clear_line_break(txt):
 | 
					def clear_line_break(txt):
 | 
				
			||||||
    txt = txt.replace('\n', ' ')
 | 
					    import re
 | 
				
			||||||
    txt = txt.replace('  ', ' ')
 | 
					    return re.sub(r"\s+", " ", txt)
 | 
				
			||||||
    txt = txt.replace('  ', ' ')
 | 
					 | 
				
			||||||
    return txt
 | 
					 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user