镜像自地址
https://github.com/binary-husky/gpt_academic.git
已同步 2025-12-06 06:26:47 +00:00
模块化封装
这个提交包含在:
22
toolbox.py
22
toolbox.py
@@ -1,7 +1,27 @@
|
||||
import markdown, mdtex2html
|
||||
import markdown, mdtex2html, threading
|
||||
from show_math import convert as convert_math
|
||||
from functools import wraps
|
||||
|
||||
def predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, history=[]):
|
||||
"""
|
||||
调用简单的predict_no_ui接口,但是依然保留了些许界面心跳功能
|
||||
"""
|
||||
import time
|
||||
try: from config_private import TIMEOUT_SECONDS
|
||||
except: from config import TIMEOUT_SECONDS
|
||||
from predict import predict_no_ui
|
||||
mutable = [None]
|
||||
def mt(): mutable[0] = predict_no_ui(inputs=i_say, top_p=top_p, temperature=temperature, history=history)
|
||||
thread_name = threading.Thread(target=mt); thread_name.start()
|
||||
cnt = 0
|
||||
while thread_name.is_alive():
|
||||
cnt += 1
|
||||
chatbot[-1] = (i_say_show_user, f"[Local Message] waiting gpt response {cnt}/{TIMEOUT_SECONDS*2}"+''.join(['.']*(cnt%4)))
|
||||
yield chatbot, history, '正常'
|
||||
time.sleep(1)
|
||||
gpt_say = mutable[0]
|
||||
return gpt_say
|
||||
|
||||
def write_results_to_file(history, file_name=None):
|
||||
"""
|
||||
将对话记录history以Markdown格式写入文件中。如果没有指定文件名,则使用当前时间生成文件名。
|
||||
|
||||
在新工单中引用
屏蔽一个用户