in project/paperbench/paperbench/judge/judge.py [0:0]
def _prepare_relevant_files_strings(self, task_category: str):
"""
Prepares the relevant file strings necessary for judging specific task categories.
Automatically limits file depth if necessary.
Automatically truncates to the model context window if necessary.
"""
available_context = self.avail_context_lens[task_category]
# 1st try without limiting depth
attempt_outcome = self._attempt_preparing_files_strings(
task_category, available_context, max_file_depth=None
)
# 2nd attempt: limit depth to 4
if not attempt_outcome.success:
attempt_outcome = self._attempt_preparing_files_strings(
task_category, available_context, max_file_depth=4
)
# 3rd attempt: simply truncate the file strings, forcing 'success'
if not attempt_outcome.success:
files_content_data = attempt_outcome.files_content_data
all_files_content = files_content_data.all_files_content # irrelevant here
all_file_names, tree_structure = self._truncate_files(
files_content_data.tree_structure,
files_content_data.all_file_names,
available_context,
)
attempt_outcome = FilesPreparationOutcome(
success=True,
all_files_fit=False,
files_content_data=FilesContentData(
all_files_content=all_files_content,
tree_structure=tree_structure,
all_file_names=all_file_names,
),
)
return attempt_outcome