Merge branch 'dev' of github.com:binary-husky/chatgpt_academic into dev
This commit is contained in:
		
						commit
						a3952be1cb
					
				
							
								
								
									
										12
									
								
								toolbox.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								toolbox.py
									
									
									
									
									
								
							@ -1,6 +1,7 @@
 | 
				
			|||||||
import markdown, mdtex2html, threading, importlib, traceback, importlib, inspect
 | 
					import markdown, mdtex2html, threading, importlib, traceback, importlib, inspect
 | 
				
			||||||
from show_math import convert as convert_math
 | 
					from show_math import convert as convert_math
 | 
				
			||||||
from functools import wraps
 | 
					from functools import wraps
 | 
				
			||||||
 | 
					import re
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, history=[], sys_prompt=''):
 | 
					def predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, history=[], sys_prompt=''):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
@ -237,9 +238,14 @@ 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:
 | 
					        if arg=='API_KEY':
 | 
				
			||||||
            assert False, "正确的API_KEY密钥是51位,请在config文件中修改API密钥, 添加海外代理之后再运行。" + \
 | 
					            # 正确的 API_KEY 是 "sk-" + 48 位大小写字母数字的组合
 | 
				
			||||||
                        "(如果您刚更新过代码,请确保旧版config_private文件中没有遗留任何新增键值)"
 | 
					            API_MATCH = re.match(r"sk-[a-zA-Z0-9]{48}$", r)
 | 
				
			||||||
 | 
					            if API_MATCH:
 | 
				
			||||||
 | 
					                print("您的 API_KEY 是: ", r, "\nAPI_KEY 导入成功")
 | 
				
			||||||
 | 
					            else:
 | 
				
			||||||
 | 
					                assert False, "正确的 API_KEY 是 'sk-' + '48 位大小写字母数字' 的组合,请在config文件中修改API密钥, 添加海外代理之后再运行。" + \
 | 
				
			||||||
 | 
					                            "(如果您刚更新过代码,请确保旧版config_private文件中没有遗留任何新增键值)"
 | 
				
			||||||
    return res
 | 
					    return res
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def clear_line_break(txt):
 | 
					def clear_line_break(txt):
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user