Commit 96c9a464 by ccran

feat: update optimize;

parent 7bf4fe70
......@@ -99,7 +99,7 @@ def process_single_file(
)
model = "Qwen2-72B-Instruct"
# 合同审核Excel工作流处理
logger.info(" 第{}个文件,处理文件: {}".format(counter, original_file))
# logger.info(" 第{}个文件,处理文件: {}".format(counter, original_file))
result = fastgpt_openai_chat(
url,
......@@ -124,9 +124,9 @@ def process_single_file(
),
des_doc_file,
)
logger.info(
f"第{counter}个文件下载:{excel_url}到{des_excel_file} {des_doc_file}"
)
# logger.info(
# f"第{counter}个文件下载:{excel_url}到{des_excel_file} {des_doc_file}"
# )
except Exception as e:
logger.error(f"{original_file} 处理异常 第{counter}个文件: {e}")
logger.error(traceback.print_exc())
......
......@@ -514,6 +514,7 @@ def parse_args() -> argparse.Namespace:
parser.add_argument(
"--batch-output",
type=Path,
# default='/data/home/htsc/jp-contract/data/benchmark/results/jp-output-20260618-163339-976082',
help="Use an existing batch output dir for the first round instead of running batch.py.",
)
parser.add_argument(
......@@ -537,7 +538,7 @@ def main() -> int:
if not args.skip_app_restart:
restart_app(args.app_session, args.app_command)
batch_output_dir = run_batch()
print(f'round={round_idx} 完成批处理任务={batch_output_dir}', flush=True)
# 2. 测评结果分析,生成优化建议,写回规则文件,记录优化报告
eval_excel = run_eval(batch_output_dir)
eval_items = read_eval_items(
......@@ -546,15 +547,16 @@ def main() -> int:
f1_threshold=args.f1_threshold,
example_limit=args.example_limit,
)
print(f'round={round_idx} 解析评测结果,待优化审查项数量={len(eval_items)}', flush=True)
rule_tasks = build_rule_tasks(eval_items)
optimizations = asyncio.run(optimize_rule_tasks(rule_tasks, max_workers=args.max_workers))
print(f'round={round_idx} 完成LLM优化建议生成,优化建议数量={len(optimizations)}', flush=True)
backup_file: Path | None = None
applied: list[dict[str, Any]] = []
if optimizations and not args.dry_run:
backup_file = backup_rules(rules_file, report_file.parent / "rule_backups", round_idx)
applied = update_rules_file(rules_file, optimizations)
#
append_round_report(
report_file=report_file,
round_idx=round_idx,
......@@ -566,13 +568,7 @@ def main() -> int:
applied=applied,
f1_threshold=args.f1_threshold,
)
print(
f"round={round_idx} batch_output={batch_output_dir} eval_excel={eval_excel} "
f"optimized_items={len(eval_items)} optimized_rules={len(rule_tasks)} "
f"applied_updates={len(applied)} report={report_file}",
flush=True,
)
print('*' * 80, flush=True)
if not eval_items:
break
......
No preview for this file type
......@@ -116,7 +116,7 @@ def download_file(url, path, input_url_to_inner=True):
if not url.startswith("http:") and not url.startswith("https:"):
url = base_fastgpt_url + url
url = url.replace(outer_backend_url, base_backend_url)
logger.info(f"url准备下载:{url}")
# logger.info(f"url准备下载:{url}")
# 发送一个HTTP请求到URL
response = requests.get(url)
# 确保请求成功
......@@ -131,10 +131,10 @@ def download_file(url, path, input_url_to_inner=True):
with open(target_path, "wb") as f:
# 写入响应的内容
f.write(response.content)
logger.info(f"{url}文件下载成功,保存到{target_path}")
# logger.info(f"{url}文件下载成功,保存到{target_path}")
return str(target_path)
else:
logger.error(f"{url}文件下载失败. HTTP Status Code: {response.status_code}")
# logger.error(f"{url}文件下载失败. HTTP Status Code: {response.status_code}")
return None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment