chatgpt_academic/crazy_functions/高级功能函数模板.py
2023-03-24 18:04:59 +08:00

17 lines
908 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from predict import predict_no_ui
from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down
fast_debug = False
@CatchException
def 高阶功能模板函数(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
history = [] # 清空历史,以免输入溢出
for i in range(5):
i_say = f'我给出一个数字,你给出该数字的平方。我给出数字:{i}'
chatbot.append((i_say, "[Local Message] waiting gpt response."))
yield chatbot, history, '正常' # 由于请求gpt需要一段时间我们先及时地做一次状态显示
gpt_say = predict_no_ui(inputs=i_say, top_p=top_p, temperature=temperature) # 请求gpt需要一段时间
chatbot[-1] = (i_say, gpt_say)
history.append(i_say);history.append(gpt_say)
yield chatbot, history, '正常' # 显示