-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent_battery.ps1
More file actions
72 lines (60 loc) · 2.26 KB
/
Copy pathagent_battery.ps1
File metadata and controls
72 lines (60 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
param(
[string]$ApiUrl = "http://127.0.0.1:8010/chat",
[string]$ApiKey = $env:DEMO_KEY,
[int] $MaxNewTokens = 110,
[int] $MaxSteps = 5,
[string]$TasksFile = "$PSScriptRoot\benchmarks\golden_prompts.json"
)
# --- Mostrar config
Write-Host "Tokens $MaxNewTokens -MaxSteps $MaxSteps"
Write-Host "[agent_battery] RepoRoot: $PSScriptRoot"
Write-Host "[agent_battery] API: $ApiUrl"
# --- API key al entorno (si viene por parámetro)
if ($ApiKey) {
$env:DEMO_KEY = $ApiKey
Write-Host "[agent_battery] Using X-API-Key from env: True"
} else {
Write-Host "[agent_battery] Using X-API-Key from env: " -NoNewline
Write-Host ([bool]$env:DEMO_KEY)
}
# --- Rutas
$repoRoot = $PSScriptRoot
$benchPy = Join-Path $repoRoot "benchmarks\benchmark_agent.py"
if (-not (Test-Path $benchPy)) { throw "No se encontró $benchPy" }
if (-not (Test-Path $TasksFile)) {
$TasksFile = Join-Path $repoRoot "benchmarks\golden_prompts.json"
if (-not (Test-Path $TasksFile)) { throw "No se encontró $TasksFile" }
}
$outDir = Join-Path $repoRoot "logs\benchmarks"
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
# --- Ejecutar benchmark_agent.py con flags nuevos
$pyArgs = @(
$benchPy,
"--api-url", $ApiUrl,
"--api-key", $env:DEMO_KEY,
"--tasks-file", $TasksFile,
"--max-new-tokens", $MaxNewTokens,
"--max-steps", $MaxSteps
)
Write-Host "[Benchmark] Tareas: $(Get-Content $TasksFile -Raw | Measure-Object -Line).Lines | API: $ApiUrl | Out: $outDir"
# Asegura Unicode limpio en consola
$env:PYTHONIOENCODING = "utf-8"
# Lanza Python
& python @pyArgs
if ($LASTEXITCODE -ne 0) { Write-Warning "benchmark_agent.py devolvió código $LASTEXITCODE" }
# --- Mostrar último results.csv (resumen)
$lastRun = Get-ChildItem (Join-Path $outDir "agent_run_*") -Directory |
Sort-Object LastWriteTime -Descending | Select-Object -First 1
if ($lastRun) {
$resCsv = Join-Path $lastRun.FullName "results.csv"
$infCsv = Join-Path $lastRun.FullName "infer_metrics.csv"
if (Test-Path $resCsv) {
Write-Host "`n[Benchmark] PASS summary:`n"
Import-Csv $resCsv |
Select-Object task_id, goal, pass, status, lat_ms |
Format-Table -AutoSize
}
Write-Host "`n[Benchmark] CSVs:"
Write-Host " - $resCsv"
Write-Host " - $infCsv"
}