Spaces:
Running
Running
更正bug
Browse files- crazy_functions/crazy_utils.py +1 -1
- crazy_functions/解析项目源代码.py +18 -2
crazy_functions/crazy_utils.py
CHANGED
|
@@ -76,7 +76,7 @@ def request_gpt_model_in_new_thread_with_ui_alive(
|
|
| 76 |
try:
|
| 77 |
# 【第一种情况】:顺利完成
|
| 78 |
result = predict_no_ui_long_connection(
|
| 79 |
-
inputs=inputs, llm_kwargs=llm_kwargs,
|
| 80 |
history=history, sys_prompt=sys_prompt, observe_window=mutable)
|
| 81 |
return result
|
| 82 |
except ConnectionAbortedError as token_exceeded_error:
|
|
|
|
| 76 |
try:
|
| 77 |
# 【第一种情况】:顺利完成
|
| 78 |
result = predict_no_ui_long_connection(
|
| 79 |
+
inputs=inputs, llm_kwargs=llm_kwargs,
|
| 80 |
history=history, sys_prompt=sys_prompt, observe_window=mutable)
|
| 81 |
return result
|
| 82 |
except ConnectionAbortedError as token_exceeded_error:
|
crazy_functions/解析项目源代码.py
CHANGED
|
@@ -41,6 +41,22 @@ def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
|
|
| 41 |
chatbot.append(("完成?", "逐个文件分析已完成。" + res + "\n\n正在开始汇总。"))
|
| 42 |
yield from update_ui(chatbot=chatbot, history=history_to_return) # 刷新界面
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
############################## <第二步,综合,单线程,分组+迭代处理> ##################################
|
| 45 |
batchsize = 16 # 10个文件为一组
|
| 46 |
report_part_2 = []
|
|
@@ -53,14 +69,14 @@ def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
|
|
| 53 |
file_rel_path = [os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)]
|
| 54 |
# 把“请对下面的程序文件做一个概述” 替换成 精简的 "文件名:{all_file[index]}"
|
| 55 |
for index, content in enumerate(this_iteration_gpt_response_collection):
|
| 56 |
-
if index%2==0: this_iteration_gpt_response_collection[index] = f"
|
| 57 |
previous_iteration_files.extend([os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)])
|
| 58 |
previous_iteration_files_string = ', '.join(previous_iteration_files)
|
| 59 |
current_iteration_focus = ', '.join([os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)])
|
| 60 |
i_say = f'根据以上分析,对程序的整体功能和构架重新做出概括。然后用一张markdown表格整理每个文件的功能(包括{previous_iteration_files_string})。'
|
| 61 |
inputs_show_user = f'根据以上分析,对程序的整体功能和构架重新做出概括,由于输入长度限制,可能需要分组处理,本组文件为 {current_iteration_focus} + 已经汇总的文件组。'
|
| 62 |
this_iteration_history = copy.deepcopy(this_iteration_gpt_response_collection)
|
| 63 |
-
this_iteration_history.
|
| 64 |
result = yield from request_gpt_model_in_new_thread_with_ui_alive(
|
| 65 |
inputs=i_say, inputs_show_user=inputs_show_user, llm_kwargs=llm_kwargs, chatbot=chatbot,
|
| 66 |
history=this_iteration_history, # 迭代之前的分析
|
|
|
|
| 41 |
chatbot.append(("完成?", "逐个文件分析已完成。" + res + "\n\n正在开始汇总。"))
|
| 42 |
yield from update_ui(chatbot=chatbot, history=history_to_return) # 刷新界面
|
| 43 |
|
| 44 |
+
############################## <存储中间数据进行调试> ##################################
|
| 45 |
+
|
| 46 |
+
# def objdump(obj):
|
| 47 |
+
# import pickle
|
| 48 |
+
# with open('objdump.tmp', 'wb+') as f:
|
| 49 |
+
# pickle.dump(obj, f)
|
| 50 |
+
# return
|
| 51 |
+
|
| 52 |
+
# def objload():
|
| 53 |
+
# import pickle, os
|
| 54 |
+
# if not os.path.exists('objdump.tmp'):
|
| 55 |
+
# return
|
| 56 |
+
# with open('objdump.tmp', 'rb') as f:
|
| 57 |
+
# return pickle.load(f)
|
| 58 |
+
# objdump([report_part_1, gpt_response_collection, history_to_return, file_manifest, project_folder, fp, llm_kwargs, chatbot])
|
| 59 |
+
|
| 60 |
############################## <第二步,综合,单线程,分组+迭代处理> ##################################
|
| 61 |
batchsize = 16 # 10个文件为一组
|
| 62 |
report_part_2 = []
|
|
|
|
| 69 |
file_rel_path = [os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)]
|
| 70 |
# 把“请对下面的程序文件做一个概述” 替换成 精简的 "文件名:{all_file[index]}"
|
| 71 |
for index, content in enumerate(this_iteration_gpt_response_collection):
|
| 72 |
+
if index%2==0: this_iteration_gpt_response_collection[index] = f"{file_rel_path[index//2]}" # 只保留文件名节省token
|
| 73 |
previous_iteration_files.extend([os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)])
|
| 74 |
previous_iteration_files_string = ', '.join(previous_iteration_files)
|
| 75 |
current_iteration_focus = ', '.join([os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)])
|
| 76 |
i_say = f'根据以上分析,对程序的整体功能和构架重新做出概括。然后用一张markdown表格整理每个文件的功能(包括{previous_iteration_files_string})。'
|
| 77 |
inputs_show_user = f'根据以上分析,对程序的整体功能和构架重新做出概括,由于输入长度限制,可能需要分组处理,本组文件为 {current_iteration_focus} + 已经汇总的文件组。'
|
| 78 |
this_iteration_history = copy.deepcopy(this_iteration_gpt_response_collection)
|
| 79 |
+
this_iteration_history.append(last_iteration_result)
|
| 80 |
result = yield from request_gpt_model_in_new_thread_with_ui_alive(
|
| 81 |
inputs=i_say, inputs_show_user=inputs_show_user, llm_kwargs=llm_kwargs, chatbot=chatbot,
|
| 82 |
history=this_iteration_history, # 迭代之前的分析
|