From 7697fa1ae9ecd5ea44c0400b1d891f1657c35e4e Mon Sep 17 00:00:00 2001 From: RonghaiHe Date: Thu, 26 Sep 2024 14:21:43 +0800 Subject: [PATCH] Conclude codes based on dir --- crazy_functions/SourceCode_Analyse.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crazy_functions/SourceCode_Analyse.py b/crazy_functions/SourceCode_Analyse.py index ea071ed3..12006179 100644 --- a/crazy_functions/SourceCode_Analyse.py +++ b/crazy_functions/SourceCode_Analyse.py @@ -50,12 +50,18 @@ def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, yield from update_ui(chatbot=chatbot, history=history_to_return) # 刷新界面 ############################## <第二步,综合,单线程,分组+迭代处理> ################################## - batchsize = 16 # 10个文件为一组 report_part_2 = [] previous_iteration_files = [] last_iteration_result = "" while True: if len(file_manifest) == 0: break + batchsize = 16 # 每次最多处理的文件数量 + if len(file_manifest) < batchsize: batchsize = len(file_manifest) + file_dir = os.path.dirname(file_manifest[0]) + for num_file_manifest in range(batchsize): + if os.path.dirname(file_manifest[num_file_manifest]) != file_dir: + batchsize = num_file_manifest + break this_iteration_file_manifest = file_manifest[:batchsize] this_iteration_gpt_response_collection = gpt_response_collection[:batchsize*2] file_rel_path = [os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)]