Spaces:
Sleeping
Sleeping
改善功能
Browse files- crazy_functions/解析项目源代码.py +6 -3
- main.py +0 -3
crazy_functions/解析项目源代码.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from toolbox import update_ui
|
2 |
from toolbox import CatchException, report_execption, write_results_to_file
|
|
|
3 |
|
4 |
def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt):
|
5 |
import os, copy
|
@@ -61,13 +62,15 @@ def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
|
|
61 |
previous_iteration_files.extend([os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)])
|
62 |
previous_iteration_files_string = ', '.join(previous_iteration_files)
|
63 |
current_iteration_focus = ', '.join([os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)])
|
64 |
-
i_say = f'
|
65 |
inputs_show_user = f'根据以上分析,对程序的整体功能和构架重新做出概括,由于输入长度限制,可能需要分组处理,本组文件为 {current_iteration_focus} + 已经汇总的文件组。'
|
66 |
this_iteration_history = copy.deepcopy(this_iteration_gpt_response_collection)
|
67 |
this_iteration_history.append(last_iteration_result)
|
|
|
|
|
68 |
result = yield from request_gpt_model_in_new_thread_with_ui_alive(
|
69 |
-
inputs=
|
70 |
-
history=
|
71 |
sys_prompt="你是一个程序架构分析师,正在分析一个项目的源代码。")
|
72 |
report_part_2.extend([i_say, result])
|
73 |
last_iteration_result = result
|
|
|
1 |
from toolbox import update_ui
|
2 |
from toolbox import CatchException, report_execption, write_results_to_file
|
3 |
+
from .crazy_utils import input_clipping
|
4 |
|
5 |
def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt):
|
6 |
import os, copy
|
|
|
62 |
previous_iteration_files.extend([os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)])
|
63 |
previous_iteration_files_string = ', '.join(previous_iteration_files)
|
64 |
current_iteration_focus = ', '.join([os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)])
|
65 |
+
i_say = f'用一张Markdown表格简要描述以下文件的功能:{previous_iteration_files_string}。根据以上分析,用一句话概括程序的整体功能。'
|
66 |
inputs_show_user = f'根据以上分析,对程序的整体功能和构架重新做出概括,由于输入长度限制,可能需要分组处理,本组文件为 {current_iteration_focus} + 已经汇总的文件组。'
|
67 |
this_iteration_history = copy.deepcopy(this_iteration_gpt_response_collection)
|
68 |
this_iteration_history.append(last_iteration_result)
|
69 |
+
# 裁剪input
|
70 |
+
inputs, this_iteration_history_feed = input_clipping(inputs=i_say, history=this_iteration_history, max_token_limit=2560)
|
71 |
result = yield from request_gpt_model_in_new_thread_with_ui_alive(
|
72 |
+
inputs=inputs, inputs_show_user=inputs_show_user, llm_kwargs=llm_kwargs, chatbot=chatbot,
|
73 |
+
history=this_iteration_history_feed, # 迭代之前的分析
|
74 |
sys_prompt="你是一个程序架构分析师,正在分析一个项目的源代码。")
|
75 |
report_part_2.extend([i_say, result])
|
76 |
last_iteration_result = result
|
main.py
CHANGED
@@ -173,9 +173,6 @@ def main():
|
|
173 |
yield from ArgsGeneralWrapper(crazy_fns[k]["Function"])(*args, **kwargs)
|
174 |
click_handle = switchy_bt.click(route,[switchy_bt, *input_combo, gr.State(PORT)], output_combo)
|
175 |
click_handle.then(on_report_generated, [file_upload, chatbot], [file_upload, chatbot])
|
176 |
-
# def expand_file_area(file_upload, area_file_up):
|
177 |
-
# if len(file_upload)>0: return {area_file_up: gr.update(open=True)}
|
178 |
-
# click_handle.then(expand_file_area, [file_upload, area_file_up], [area_file_up])
|
179 |
cancel_handles.append(click_handle)
|
180 |
# 终止按钮的回调函数注册
|
181 |
stopBtn.click(fn=None, inputs=None, outputs=None, cancels=cancel_handles)
|
|
|
173 |
yield from ArgsGeneralWrapper(crazy_fns[k]["Function"])(*args, **kwargs)
|
174 |
click_handle = switchy_bt.click(route,[switchy_bt, *input_combo, gr.State(PORT)], output_combo)
|
175 |
click_handle.then(on_report_generated, [file_upload, chatbot], [file_upload, chatbot])
|
|
|
|
|
|
|
176 |
cancel_handles.append(click_handle)
|
177 |
# 终止按钮的回调函数注册
|
178 |
stopBtn.click(fn=None, inputs=None, outputs=None, cancels=cancel_handles)
|