adding: OUTPUT_FILENAME_PATTERN

This commit is contained in:
2026-09-09 19:05:12 -03:00
parent b2a368d71a
commit b0613d54ab
104 changed files with 71 additions and 5 deletions

View File

27
evaluator/output/legacy_exporter.py Normal file → Executable file
View File

@@ -106,11 +106,36 @@ def _session_loop_map(rows) -> dict[str, int]:
return {sid: max_consecutive_intent_streak(items) for sid, items in grouped.items()}
def build_output_filename(
agent_id: str,
run_id: str,
now_brt: datetime,
pattern: str | None = None,
) -> str:
"""Build the export filename from the environment-configurable template."""
template = pattern or settings.output_filename_pattern
try:
filename = template.format(
agent_id=agent_id,
run_id=run_id,
timestamp=now_brt.strftime("%Y%m%d_%H%M%S"),
)
except KeyError as exc:
raise ValueError(
f"Unknown placeholder {exc} in OUTPUT_FILENAME_PATTERN. "
"Supported placeholders: {agent_id}, {run_id}, {timestamp}."
) from exc
if not filename or Path(filename).name != filename or filename in {".", ".."}:
raise ValueError("OUTPUT_FILENAME_PATTERN must produce a filename without directories")
return filename
def export_legacy_txt_gz(repo: EvaluationRepository, run_id: str, agent_id: str) -> Path:
output_dir = settings.path(settings.output_dir)
output_dir.mkdir(parents=True, exist_ok=True)
now_brt = datetime.now(ZoneInfo("America/Sao_Paulo"))
path = output_dir / f"AGENTE_{agent_id}_LLM_JUDGE_{now_brt.strftime('%Y%m%d_%H%M%S')}.TXT.GZ"
path = output_dir / build_output_filename(agent_id, run_id, now_brt)
with repo.store.connect() as conn:
cur = conn.cursor()