生成文本报告
This commit is contained in:
parent
93c13aa97a
commit
32f36a609e
1
.gitignore
vendored
1
.gitignore
vendored
@ -135,3 +135,4 @@ history
|
|||||||
ssr_conf
|
ssr_conf
|
||||||
config_private.py
|
config_private.py
|
||||||
gpt_log
|
gpt_log
|
||||||
|
private.md
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from predict import predict_no_ui
|
from predict import predict_no_ui
|
||||||
from toolbox import CatchException, report_execption
|
from toolbox import CatchException, report_execption, write_results_to_file
|
||||||
fast_debug = False
|
fast_debug = False
|
||||||
|
|
||||||
|
|
||||||
@ -56,7 +56,9 @@ def 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, hist
|
|||||||
chatbot[-1] = (i_say, gpt_say)
|
chatbot[-1] = (i_say, gpt_say)
|
||||||
history.append(i_say); history.append(gpt_say)
|
history.append(i_say); history.append(gpt_say)
|
||||||
yield chatbot, history, msg
|
yield chatbot, history, msg
|
||||||
|
res = write_results_to_file(history)
|
||||||
|
chatbot.append(("完成了吗?", res))
|
||||||
|
yield chatbot, history, msg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from predict import predict_no_ui
|
from predict import predict_no_ui
|
||||||
from toolbox import CatchException, report_execption
|
from toolbox import CatchException, report_execption, write_results_to_file
|
||||||
fast_debug = False
|
fast_debug = False
|
||||||
|
|
||||||
|
|
||||||
@ -110,7 +110,9 @@ def 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot,
|
|||||||
chatbot[-1] = (i_say, gpt_say)
|
chatbot[-1] = (i_say, gpt_say)
|
||||||
history.append(i_say); history.append(gpt_say)
|
history.append(i_say); history.append(gpt_say)
|
||||||
yield chatbot, history, msg
|
yield chatbot, history, msg
|
||||||
|
res = write_results_to_file(history)
|
||||||
|
chatbot.append(("完成了吗?", res))
|
||||||
|
yield chatbot, history, msg
|
||||||
|
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
|
14
toolbox.py
14
toolbox.py
@ -2,6 +2,20 @@ import markdown, mdtex2html
|
|||||||
from show_math import convert as convert_math
|
from show_math import convert as convert_math
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
def write_results_to_file(history, file_name=None):
|
||||||
|
import os, time
|
||||||
|
if file_name is None:
|
||||||
|
file_name = time.strftime("chatGPT分析报告%Y-%m-%d-%H-%M-%S", time.localtime()) + '.md'
|
||||||
|
os.makedirs('./gpt_log/', exist_ok=True)
|
||||||
|
with open(f'./gpt_log/{file_name}', 'w') as f:
|
||||||
|
f.write('# chatGPT 分析报告\n')
|
||||||
|
for i, content in enumerate(history):
|
||||||
|
if i%2==0: f.write('## ')
|
||||||
|
f.write(content)
|
||||||
|
f.write('\n\n')
|
||||||
|
res ='以上材料已经被写入', f'./gpt_log/{file_name}'
|
||||||
|
print(res)
|
||||||
|
return res
|
||||||
|
|
||||||
def regular_txt_to_markdown(text):
|
def regular_txt_to_markdown(text):
|
||||||
text = text.replace('\n', '\n\n')
|
text = text.replace('\n', '\n\n')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user