3v324v23 commited on
Commit
32f36a6
1 Parent(s): 93c13aa

生成文本报告

Browse files
.gitignore CHANGED
@@ -135,3 +135,4 @@ history
135
  ssr_conf
136
  config_private.py
137
  gpt_log
 
 
135
  ssr_conf
136
  config_private.py
137
  gpt_log
138
+ private.md
crazy_functions/读文章写摘要.py CHANGED
@@ -1,5 +1,5 @@
1
  from predict import predict_no_ui
2
- from toolbox import CatchException, report_execption
3
  fast_debug = False
4
 
5
 
@@ -56,7 +56,9 @@ def 解析Paper(file_manifest, project_folder, top_p, temperature, chatbot, hist
56
  chatbot[-1] = (i_say, gpt_say)
57
  history.append(i_say); history.append(gpt_say)
58
  yield chatbot, history, msg
59
-
 
 
60
 
61
 
62
 
 
1
  from predict import predict_no_ui
2
+ from toolbox import CatchException, report_execption, write_results_to_file
3
  fast_debug = False
4
 
5
 
 
56
  chatbot[-1] = (i_say, gpt_say)
57
  history.append(i_say); history.append(gpt_say)
58
  yield chatbot, history, msg
59
+ res = write_results_to_file(history)
60
+ chatbot.append(("完成了吗?", res))
61
+ yield chatbot, history, msg
62
 
63
 
64
 
functional_crazy.py CHANGED
@@ -1,5 +1,5 @@
1
  from predict import predict_no_ui
2
- from toolbox import CatchException, report_execption
3
  fast_debug = False
4
 
5
 
@@ -110,7 +110,9 @@ def 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot,
110
  chatbot[-1] = (i_say, gpt_say)
111
  history.append(i_say); history.append(gpt_say)
112
  yield chatbot, history, msg
113
-
 
 
114
 
115
 
116
  @CatchException
 
1
  from predict import predict_no_ui
2
+ from toolbox import CatchException, report_execption, write_results_to_file
3
  fast_debug = False
4
 
5
 
 
110
  chatbot[-1] = (i_say, gpt_say)
111
  history.append(i_say); history.append(gpt_say)
112
  yield chatbot, history, msg
113
+ res = write_results_to_file(history)
114
+ chatbot.append(("完成了吗?", res))
115
+ yield chatbot, history, msg
116
 
117
 
118
  @CatchException
toolbox.py CHANGED
@@ -2,6 +2,20 @@ import markdown, mdtex2html
2
  from show_math import convert as convert_math
3
  from functools import wraps
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  def regular_txt_to_markdown(text):
7
  text = text.replace('\n', '\n\n')
 
2
  from show_math import convert as convert_math
3
  from functools import wraps
4
 
5
+ def write_results_to_file(history, file_name=None):
6
+ import os, time
7
+ if file_name is None:
8
+ file_name = time.strftime("chatGPT分析报告%Y-%m-%d-%H-%M-%S", time.localtime()) + '.md'
9
+ os.makedirs('./gpt_log/', exist_ok=True)
10
+ with open(f'./gpt_log/{file_name}', 'w') as f:
11
+ f.write('# chatGPT 分析报告\n')
12
+ for i, content in enumerate(history):
13
+ if i%2==0: f.write('## ')
14
+ f.write(content)
15
+ f.write('\n\n')
16
+ res ='以上材料已经被写入', f'./gpt_log/{file_name}'
17
+ print(res)
18
+ return res
19
 
20
  def regular_txt_to_markdown(text):
21
  text = text.replace('\n', '\n\n')