browseruse_bench.utils.task_utils
任务处理相关的工具函数。导入
load_tasks
加载任务数据。str
必填
tasks JSON 文件路径
str
默认值:"None"
可选的 prompt 模板,格式如
"{task}\n...{url}..."。提供时会在任务字典中追加 prompt 字段。list of dict
任务列表,每项包含
task_id、task_text、url。若提供了 prompt_fmt,则还会包含 prompt。load_tasks_with_benchmark_support
加载任务,并支持不同 benchmark(包括 BrowseComp)。Path
必填
tasks JSON 文件路径
str
默认值:"None"
可选的 prompt 模板(BrowseComp 有自己的模板,此参数会被忽略)
filter_tasks
根据模式筛选任务。list of dict
必填
任务列表
str
必填
筛选模式:
single- 只跑第一个任务first_n- 跑前 N 个任务sample_n- 随机抽样 N 个任务specific- 跑指定 ID 的任务by_id- 按 ID 跑单个任务all- 跑全部任务
int
必填
first_n 或 sample_n 模式下的任务数量list of str
默认值:"None"
specific 模式下的任务 ID 列表str
默认值:"None"
by_id 模式下的单个任务 IDfilter_completed_tasks
过滤掉已完成的任务。list of dict
必填
任务列表
Path
必填
输出目录
function
必填
判断任务是否已完成的函数
tuple
(剩余任务列表, 被跳过的任务数量)
is_task_completed_by_result_json
通过result.json 判断任务是否已完成。
str
必填
任务 ID
Path
必填
输出目录路径
bool
result.json 存在且非空时返回 Trueresolve_tasks_json_path
解析 tasks JSON 文件路径。str
默认值:"None"
命令行传入的路径
Path
必填
默认路径
str
默认值:"'TASKS_JSON'"
环境变量名
print_task_summary
打印任务执行摘要。int
必填
任务总数
int
必填
本次运行的任务数量
int
必填
成功的任务数量
int
必填
失败的任务数量
Path
必填
输出目录路径