3v324v23 commited on
Commit
880be21
1 Parent(s): 559b3cd

Add test for juptyer notebook plugin

Browse files
.gitignore CHANGED
@@ -145,3 +145,4 @@ cradle*
145
  debug*
146
  private*
147
  crazy_functions/test_project/pdf_and_word
 
 
145
  debug*
146
  private*
147
  crazy_functions/test_project/pdf_and_word
148
+ crazy_functions/test_samples
crazy_functions/crazy_functions_test.py CHANGED
@@ -108,6 +108,13 @@ def test_联网回答问题():
108
  print("当前问答:", cb[-1][-1].replace("\n"," "))
109
  for i, it in enumerate(cb): print亮蓝(it[0]); print亮黄(it[1])
110
 
 
 
 
 
 
 
 
111
  # test_解析一个Python项目()
112
  # test_Latex英文润色()
113
  # test_Markdown中译英()
@@ -116,9 +123,8 @@ def test_联网回答问题():
116
  # test_总结word文档()
117
  # test_下载arxiv论文并翻译摘要()
118
  # test_解析一个Cpp项目()
119
-
120
- test_联网回答问题()
121
-
122
 
123
  input("程序完成,回车退出。")
124
  print("退出。")
 
108
  print("当前问答:", cb[-1][-1].replace("\n"," "))
109
  for i, it in enumerate(cb): print亮蓝(it[0]); print亮黄(it[1])
110
 
111
+ def test_解析ipynb文件():
112
+ from crazy_functions.解析JupyterNotebook import 解析ipynb文件
113
+ txt = "crazy_functions/test_samples"
114
+ for cookies, cb, hist, msg in 解析ipynb文件(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
115
+ print(cb)
116
+
117
+
118
  # test_解析一个Python项目()
119
  # test_Latex英文润色()
120
  # test_Markdown中译英()
 
123
  # test_总结word文档()
124
  # test_下载arxiv论文并翻译摘要()
125
  # test_解析一个Cpp项目()
126
+ # test_联网回答问题()
127
+ test_解析ipynb文件()
 
128
 
129
  input("程序完成,回车退出。")
130
  print("退出。")
crazy_functions/解析JupyterNotebook.py CHANGED
@@ -1,5 +1,5 @@
1
  from toolbox import update_ui
2
- from toolbox import CatchException, report_execption
3
  fast_debug = True
4
 
5
 
@@ -79,9 +79,9 @@ def ipynb解释(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbo
79
  pfg.run_file_split(max_token_limit=1024)
80
  n_split = len(pfg.sp_file_contents)
81
 
82
- inputs_array = [f"This is a Jupyter Notebook file, tell me about Each Block in Chinese. Focus Just On Code." +
83
- f"If a block starts with `Markdown` which means it's a markdown block in ipynbipynb. " +
84
- f"Start a new line for a block and block num use Chinese." +
85
  f"\n\n{frag}" for frag in pfg.sp_file_contents]
86
  inputs_show_user_array = [f"{f}的分析如下" for f in pfg.sp_file_tag]
87
  sys_prompt_array = ["You are a professional programmer."] * n_split
@@ -100,8 +100,13 @@ def ipynb解释(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbo
100
  # <-------- 整理结果,退出 ---------->
101
  block_result = " \n".join(gpt_response_collection)
102
  chatbot.append(("解析的结果如下", block_result))
 
103
  yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
104
 
 
 
 
 
105
 
106
  @CatchException
107
  def 解析ipynb文件(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
 
1
  from toolbox import update_ui
2
+ from toolbox import CatchException, report_execption, write_results_to_file
3
  fast_debug = True
4
 
5
 
 
79
  pfg.run_file_split(max_token_limit=1024)
80
  n_split = len(pfg.sp_file_contents)
81
 
82
+ inputs_array = [r"This is a Jupyter Notebook file, tell me about Each Block in Chinese. Focus Just On Code." +
83
+ r"If a block starts with `Markdown` which means it's a markdown block in ipynbipynb. " +
84
+ r"Start a new line for a block and block num use Chinese." +
85
  f"\n\n{frag}" for frag in pfg.sp_file_contents]
86
  inputs_show_user_array = [f"{f}的分析如下" for f in pfg.sp_file_tag]
87
  sys_prompt_array = ["You are a professional programmer."] * n_split
 
100
  # <-------- 整理结果,退出 ---------->
101
  block_result = " \n".join(gpt_response_collection)
102
  chatbot.append(("解析的结果如下", block_result))
103
+ history.extend(["解析的结果如下", block_result])
104
  yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
105
 
106
+ # <-------- 写入文件,退出 ---------->
107
+ res = write_results_to_file(history)
108
+ chatbot.append(("完成了吗?", res))
109
+ yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
110
 
111
  @CatchException
112
  def 解析ipynb文件(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):