tuieval 0.2.0.dev164__py3-none-any.whl → 0.3.0.dev2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tuieval/_version.py +2 -2
- tuieval/adapters/__init__.py +1 -0
- tuieval/adapters/pi.py +352 -0
- tuieval/agents.py +14 -4
- tuieval/builtin.toml +12 -2
- tuieval/compare.py +10 -1
- tuieval/engine.py +6 -3
- tuieval/insights.py +20 -11
- tuieval/packs.py +9 -2
- tuieval/tui.py +52 -13
- tuieval/verdict.py +20 -2
- {tuieval-0.2.0.dev164.dist-info → tuieval-0.3.0.dev2.dist-info}/METADATA +1 -1
- {tuieval-0.2.0.dev164.dist-info → tuieval-0.3.0.dev2.dist-info}/RECORD +16 -14
- {tuieval-0.2.0.dev164.dist-info → tuieval-0.3.0.dev2.dist-info}/WHEEL +0 -0
- {tuieval-0.2.0.dev164.dist-info → tuieval-0.3.0.dev2.dist-info}/entry_points.txt +0 -0
- {tuieval-0.2.0.dev164.dist-info → tuieval-0.3.0.dev2.dist-info}/licenses/LICENSE +0 -0
tuieval/_version.py
CHANGED
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.
|
|
22
|
-
__version_tuple__ = version_tuple = (0,
|
|
21
|
+
__version__ = version = '0.3.0.dev2'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 3, 0, 'dev2')
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Adapters that run command-line agents for agent packs (docs/agent-packs.md)."""
|
tuieval/adapters/pi.py
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
"""The built-in adapter for pi (https://github.com/earendil-works/pi), for agent packs: runs bare pi on the
|
|
2
|
+
model tuieval serves.
|
|
3
|
+
|
|
4
|
+
[agents.pi] cmd = ["{tuieval_python}", "-m", "tuieval.adapters.pi"] (built in)
|
|
5
|
+
[agents.pi-scouts] cmd = ["{tuieval_python}", "-m", "tuieval.adapters.pi", "--scouts"] (built in)
|
|
6
|
+
|
|
7
|
+
pi gets a scratch config folder with one provider, "tuieval", pointing at TUIEVAL_BASE_URL (context size and
|
|
8
|
+
sampling from tuieval), and runs with no extensions, skills, context files, prompt templates, themes, MCP or saved
|
|
9
|
+
session, so your own pi setup never changes a result. One line per turn and tool call is printed for the live
|
|
10
|
+
view; the stats go to TUIEVAL_STATS_FILE.
|
|
11
|
+
|
|
12
|
+
On macOS pi runs inside a sandbox (sandbox-exec, see sandbox_profile): it can't read your home folder or the temp
|
|
13
|
+
folders, apart from the task's work folder, the adapter's own scratch folder and the pack's Python, and it can
|
|
14
|
+
write only those two folders. So a model can't look up hidden tests or reference fixes, or leave notes for the
|
|
15
|
+
next model. HOME and TMPDIR point into the scratch folder. TUIEVAL_NO_SANDBOX=1 turns the sandbox off (the run
|
|
16
|
+
line then says "sandbox OFF"); without sandbox-exec (other systems) there is none.
|
|
17
|
+
|
|
18
|
+
--scouts adds pi's example subagent extension (the one explicit -e; everything else stays off) and one agent,
|
|
19
|
+
"scout": read-only tools (read, grep, find, ls), the model tuieval serves at thinking "low", and SCOUT_PROMPT.
|
|
20
|
+
The lead gets one appended system line saying the tool exists (SCOUT_HINT); the task text is unchanged, and
|
|
21
|
+
whether to delegate is the lead's own choice. Scouts are child pi processes of the sandboxed pi, so the sandbox
|
|
22
|
+
covers them too, and they use the same scratch config. Their turns and tokens are added to the run's totals and
|
|
23
|
+
also written as subagent_* stats; the turn limit counts the lead's turns only.
|
|
24
|
+
|
|
25
|
+
Standard library only: it runs with tuieval's own Python, whatever the pack's Python is.
|
|
26
|
+
"""
|
|
27
|
+
import json
|
|
28
|
+
import os
|
|
29
|
+
import shutil
|
|
30
|
+
import signal
|
|
31
|
+
import subprocess
|
|
32
|
+
import sys
|
|
33
|
+
import tempfile
|
|
34
|
+
|
|
35
|
+
PI_LEVELS = ("off", "minimal", "low", "medium", "high", "xhigh", "max")
|
|
36
|
+
SAMPLING_KEYS = ("temperature", "top_p", "top_k", "min_p", "presence_penalty", "repeat_penalty")
|
|
37
|
+
# provider errors that are the server's fault, not the model's (tuieval asks the task again)
|
|
38
|
+
SERVER_ERRORS = ("ECONNREFUSED", "ECONNRESET", "socket hang up", "fetch failed", "502", "503",
|
|
39
|
+
"Internal Server Error", "Service Unavailable", "Bad Gateway")
|
|
40
|
+
SUBAGENT_STATS = ("subagent_calls", "subagent_tasks", "subagent_failed", "subagent_turns", "subagent_input_tokens",
|
|
41
|
+
"subagent_output_tokens")
|
|
42
|
+
|
|
43
|
+
SCOUT_HINT = ("You have a `subagent` tool with a read-only `scout` agent (read, grep, find, ls). When a task needs "
|
|
44
|
+
"context from several independent parts of the code, you can send scouts in parallel to gather it "
|
|
45
|
+
"first; edits, commands and tests stay with you.")
|
|
46
|
+
SCOUT_PROMPT = """You are a scout. Quickly investigate a codebase and return structured findings that another agent can use without re-reading everything.
|
|
47
|
+
|
|
48
|
+
Your output will be passed to an agent who has NOT seen the files you explored.
|
|
49
|
+
|
|
50
|
+
Thoroughness (infer from task, default medium):
|
|
51
|
+
- Quick: Targeted lookups, key files only
|
|
52
|
+
- Medium: Follow imports, read critical sections
|
|
53
|
+
- Thorough: Trace all dependencies, check tests/types
|
|
54
|
+
|
|
55
|
+
Strategy:
|
|
56
|
+
1. grep/find to locate relevant code
|
|
57
|
+
2. Read key sections (not entire files)
|
|
58
|
+
3. Identify types, interfaces, key functions
|
|
59
|
+
4. Note dependencies between files
|
|
60
|
+
|
|
61
|
+
Output format:
|
|
62
|
+
|
|
63
|
+
## Files Retrieved
|
|
64
|
+
List with exact line ranges:
|
|
65
|
+
1. `path/to/file.ts` (lines 10-50) - Description of what's here
|
|
66
|
+
2. `path/to/other.ts` (lines 100-150) - Description
|
|
67
|
+
3. ...
|
|
68
|
+
|
|
69
|
+
## Key Code
|
|
70
|
+
Critical types, interfaces, or functions:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
interface Example {
|
|
74
|
+
// actual code from the files
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
function keyFunction() {
|
|
80
|
+
// actual implementation
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Architecture
|
|
85
|
+
Brief explanation of how the pieces connect.
|
|
86
|
+
|
|
87
|
+
## Start Here
|
|
88
|
+
Which file to look at first and why.
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def pi_version():
|
|
93
|
+
try:
|
|
94
|
+
out = subprocess.run(["pi", "--version"], capture_output=True, text=True, timeout=30).stdout.strip()
|
|
95
|
+
return f"pi {out}" if out else "pi"
|
|
96
|
+
except (OSError, subprocess.TimeoutExpired):
|
|
97
|
+
return "pi"
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def subagent_extension():
|
|
101
|
+
"""pi's example subagent extension, found from the pi on PATH (its package root holds examples/)."""
|
|
102
|
+
d = os.path.dirname(os.path.realpath(shutil.which("pi") or "pi"))
|
|
103
|
+
while d != os.path.dirname(d):
|
|
104
|
+
pkg = os.path.join(d, "package.json")
|
|
105
|
+
if os.path.isfile(pkg):
|
|
106
|
+
try:
|
|
107
|
+
name = json.load(open(pkg)).get("name", "")
|
|
108
|
+
except ValueError:
|
|
109
|
+
name = ""
|
|
110
|
+
if name.endswith("/pi-coding-agent"):
|
|
111
|
+
ext = os.path.join(d, "examples", "extensions", "subagent", "index.ts")
|
|
112
|
+
if os.path.isfile(ext):
|
|
113
|
+
return ext
|
|
114
|
+
break
|
|
115
|
+
d = os.path.dirname(d)
|
|
116
|
+
return None
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def config(dest, sampling, model_id, scouts=False):
|
|
120
|
+
"""A pi config folder with one provider, "tuieval", serving model_id (and, for scouts, the scout agent)."""
|
|
121
|
+
ctx = int(os.environ.get("TUIEVAL_CONTEXT") or 32768)
|
|
122
|
+
params = {k: sampling[k] for k in SAMPLING_KEYS if k in sampling}
|
|
123
|
+
if "enable_thinking" in sampling:
|
|
124
|
+
params["chat_template_kwargs"] = {"enable_thinking": bool(sampling["enable_thinking"])}
|
|
125
|
+
model = {"id": model_id, "name": model_id, "reasoning": True, "input": ["text"], "contextWindow": ctx,
|
|
126
|
+
"maxTokens": min(int(sampling.get("max_tokens") or 16384), ctx), "samplingParams": params,
|
|
127
|
+
# requests like tuieval's own: max_tokens (not max_completion_tokens), and reasoning_effort only
|
|
128
|
+
# when the model sets one (pi would otherwise send its default level)
|
|
129
|
+
"compat": {"maxTokensField": "max_tokens",
|
|
130
|
+
**({} if sampling.get("reasoning_effort") else {"supportsReasoningEffort": False})}}
|
|
131
|
+
providers = {"tuieval": {"baseUrl": os.environ["TUIEVAL_BASE_URL"], "api": "openai-completions",
|
|
132
|
+
"apiKey": os.environ.get("TUIEVAL_API_KEY") or "none", "models": [model]}}
|
|
133
|
+
os.makedirs(dest, mode=0o700, exist_ok=True)
|
|
134
|
+
with open(os.path.join(dest, "models.json"), "w") as f:
|
|
135
|
+
json.dump({"providers": providers}, f, indent=1)
|
|
136
|
+
with open(os.path.join(dest, "settings.json"), "w") as f:
|
|
137
|
+
json.dump({"quietStartup": True}, f)
|
|
138
|
+
if scouts:
|
|
139
|
+
os.makedirs(os.path.join(dest, "agents"), exist_ok=True)
|
|
140
|
+
with open(os.path.join(dest, "agents", "scout.md"), "w") as f:
|
|
141
|
+
f.write("---\nname: scout\ndescription: Fast codebase recon that returns compressed context for handoff "
|
|
142
|
+
f"to other agents\ntools: read, grep, find, ls\nmodel: tuieval/{model_id}:low\n---\n\n"
|
|
143
|
+
+ SCOUT_PROMPT)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def sandbox_profile(work, scratch, python_dirs):
|
|
147
|
+
"""A macOS sandbox (sandbox-exec) profile for pi and everything it runs, so a model can't look up answers
|
|
148
|
+
or leave notes for the next model:
|
|
149
|
+
reads nothing in your home folder, the temp folders or /Volumes, except the task's work folder, the
|
|
150
|
+
adapter's own scratch folder (pi config, HOME, TMPDIR) and the pack's Python
|
|
151
|
+
writes only the work folder, the scratch folder and /dev
|
|
152
|
+
escapes no Apple Events (Office, Terminal, System Events…), no LaunchServices (`open -a …`), no
|
|
153
|
+
launchctl/at/crontab, no ssh to this Mac: each would run code outside the sandbox
|
|
154
|
+
Everything else (the pi install, system libraries, the network to the model server) is allowed."""
|
|
155
|
+
q = lambda p: json.dumps(os.path.realpath(p)) # SBPL strings use the same escapes as JSON
|
|
156
|
+
home = os.path.realpath(os.path.expanduser("~"))
|
|
157
|
+
hidden = [home, "/private/tmp", "/private/var/tmp", "/private/var/folders"]
|
|
158
|
+
hidden += [p for p in ("/Volumes",) if os.path.isdir(p)]
|
|
159
|
+
ok_rw = [work, scratch]
|
|
160
|
+
rules = ["(version 1)", "(allow default)",
|
|
161
|
+
"(deny file-read* " + " ".join(f"(subpath {q(p)})" for p in hidden) + ")",
|
|
162
|
+
"(allow file-read* " + " ".join(f"(subpath {q(p)})" for p in ok_rw + python_dirs) + ")",
|
|
163
|
+
"(allow file-read-metadata)", # stat() on parent folders, which path lookups need; no contents
|
|
164
|
+
"(deny file-write* (require-not (require-any "
|
|
165
|
+
+ " ".join(f"(subpath {q(p)})" for p in ok_rw) + ' (subpath "/dev"))))',
|
|
166
|
+
"(deny appleevent-send)",
|
|
167
|
+
'(deny mach-lookup (global-name "com.apple.coreservices.launchservicesd")'
|
|
168
|
+
' (global-name "com.apple.coreservices.quarantine-resolver"))',
|
|
169
|
+
'(deny process-exec (literal "/bin/launchctl") (literal "/usr/bin/at") (literal "/usr/bin/crontab")'
|
|
170
|
+
' (literal "/usr/bin/open") (literal "/usr/bin/ssh") (literal "/usr/bin/osascript")'
|
|
171
|
+
' (literal "/usr/bin/shortcuts") (literal "/usr/bin/automator"))',
|
|
172
|
+
'(deny network-outbound (remote tcp "localhost:22"))']
|
|
173
|
+
return "\n".join(rules)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def python_dirs():
|
|
177
|
+
"""Folders the pack's Python needs to read: its venv (first on PATH, put there by tuieval) and the base
|
|
178
|
+
install the venv points at."""
|
|
179
|
+
dirs = []
|
|
180
|
+
first = (os.environ.get("PATH") or "").split(os.pathsep)[0]
|
|
181
|
+
venv = os.path.dirname(first)
|
|
182
|
+
cfg = os.path.join(venv, "pyvenv.cfg")
|
|
183
|
+
if os.path.isfile(cfg):
|
|
184
|
+
dirs.append(venv)
|
|
185
|
+
for line in open(cfg):
|
|
186
|
+
k, _, v = line.partition("=")
|
|
187
|
+
if k.strip() == "home" and v.strip():
|
|
188
|
+
dirs.append(os.path.dirname(os.path.realpath(v.strip()))) # …/bin -> the install
|
|
189
|
+
return dirs
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def thinking(sampling):
|
|
193
|
+
if sampling.get("enable_thinking") is False:
|
|
194
|
+
return "off"
|
|
195
|
+
effort = sampling.get("reasoning_effort")
|
|
196
|
+
return effort if effort in PI_LEVELS else None
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def short(v, n=140):
|
|
200
|
+
v = " ".join(str(v).split())
|
|
201
|
+
return v if len(v) <= n else v[:n - 1] + "…"
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def add_subagents(stats, ev):
|
|
205
|
+
"""Count a finished subagent tool call (pi's example extension) into stats; returns its summary line."""
|
|
206
|
+
rs = ((ev.get("result") or {}).get("details") or {}).get("results") or []
|
|
207
|
+
stats["subagent_calls"] += 1
|
|
208
|
+
turns = out = 0
|
|
209
|
+
for r in rs:
|
|
210
|
+
u = r.get("usage") or {}
|
|
211
|
+
stats["subagent_tasks"] += 1
|
|
212
|
+
stats["subagent_failed"] += int(r.get("exitCode") not in (0, None) or r.get("status") == "failed")
|
|
213
|
+
tokens_in = (u.get("input") or 0) + (u.get("cacheRead") or 0)
|
|
214
|
+
stats["subagent_turns"] += u.get("turns") or 0
|
|
215
|
+
stats["subagent_input_tokens"] += tokens_in
|
|
216
|
+
stats["subagent_output_tokens"] += u.get("output") or 0
|
|
217
|
+
stats["input_tokens"] += tokens_in
|
|
218
|
+
stats["output_tokens"] += u.get("output") or 0
|
|
219
|
+
turns += u.get("turns") or 0
|
|
220
|
+
out += u.get("output") or 0
|
|
221
|
+
if ev.get("isError"):
|
|
222
|
+
stats["tool_errors"] += 1
|
|
223
|
+
return f" subagents: {len(rs)} task(s), {turns} turns, {out} output tokens" + (" [error]" if ev.get("isError") else "")
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def build_command(model_id, sampling, prompt, scouts, extension):
|
|
227
|
+
cmd = ["pi", "--mode", "json", "--no-session", "--no-extensions", "--no-skills", "--no-context-files",
|
|
228
|
+
"--no-prompt-templates", "--no-themes", "--no-mcp", "--no-approve", "--offline",
|
|
229
|
+
"--model", "tuieval/" + model_id]
|
|
230
|
+
if scouts:
|
|
231
|
+
cmd += ["-e", extension, "--append-system-prompt", SCOUT_HINT]
|
|
232
|
+
level = thinking(sampling)
|
|
233
|
+
if level:
|
|
234
|
+
cmd += ["--thinking", level]
|
|
235
|
+
return cmd + ["--", prompt], level
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def main(argv=None):
|
|
239
|
+
argv = sys.argv[1:] if argv is None else argv
|
|
240
|
+
scouts = "--scouts" in argv
|
|
241
|
+
sampling = json.loads(os.environ.get("TUIEVAL_SAMPLING") or "{}")
|
|
242
|
+
max_turns = int(os.environ.get("TUIEVAL_MAX_TURNS") or 40)
|
|
243
|
+
prompt = open(os.environ["TUIEVAL_PROMPT_FILE"]).read()
|
|
244
|
+
model_id = os.environ["TUIEVAL_MODEL_ID"]
|
|
245
|
+
stats = {"agent": pi_version() + (" + scouts" if scouts else ""), "turns": 0, "input_tokens": 0,
|
|
246
|
+
"output_tokens": 0, "tool_calls": 0, "tool_errors": 0, "ran_tests": False, "stop": "", "final_message": ""}
|
|
247
|
+
extension = None
|
|
248
|
+
if scouts:
|
|
249
|
+
stats.update(dict.fromkeys(SUBAGENT_STATS, 0))
|
|
250
|
+
extension = subagent_extension()
|
|
251
|
+
if not extension:
|
|
252
|
+
print("pi's examples/extensions/subagent/index.ts wasn't found next to the pi on PATH", flush=True)
|
|
253
|
+
stats.update(stop="error", final_message="no subagent extension")
|
|
254
|
+
save(stats)
|
|
255
|
+
return 1
|
|
256
|
+
tmp = tempfile.mkdtemp(prefix="pi-adapter-")
|
|
257
|
+
cfg_dir = os.path.join(tmp, "pi-config")
|
|
258
|
+
config(cfg_dir, sampling, model_id, scouts)
|
|
259
|
+
cmd, level = build_command(model_id, sampling, prompt, scouts, extension)
|
|
260
|
+
env = dict(os.environ, PI_CODING_AGENT_DIR=cfg_dir, PI_OFFLINE="1", PI_TELEMETRY="0")
|
|
261
|
+
shown = " ".join(cmd[:-1])
|
|
262
|
+
sandbox = os.environ.get("TUIEVAL_NO_SANDBOX") != "1" and shutil.which("sandbox-exec")
|
|
263
|
+
if sandbox:
|
|
264
|
+
fake_home, fake_tmp = os.path.join(tmp, "home"), os.path.join(tmp, "tmp")
|
|
265
|
+
os.makedirs(fake_home)
|
|
266
|
+
os.makedirs(fake_tmp)
|
|
267
|
+
env.update(HOME=fake_home, TMPDIR=fake_tmp + "/", ZDOTDIR=fake_home)
|
|
268
|
+
pi = shutil.which("pi") or "pi"
|
|
269
|
+
cmd = ["sandbox-exec", "-p", sandbox_profile(os.getcwd(), tmp, python_dirs()), pi] + cmd[1:]
|
|
270
|
+
print(f"$ {shown} <task> (thinking {level or 'default'}, max {max_turns} turns, "
|
|
271
|
+
f"sandbox {'on' if sandbox else 'OFF'})", flush=True)
|
|
272
|
+
try:
|
|
273
|
+
proc = subprocess.Popen(cmd, env=env, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
|
|
274
|
+
stderr=subprocess.PIPE, start_new_session=True)
|
|
275
|
+
except OSError as e:
|
|
276
|
+
shutil.rmtree(tmp, ignore_errors=True)
|
|
277
|
+
stats.update(stop="error", final_message=f"can't start pi: {e}")
|
|
278
|
+
save(stats)
|
|
279
|
+
return 1
|
|
280
|
+
|
|
281
|
+
def stop_pi(*_):
|
|
282
|
+
try:
|
|
283
|
+
os.killpg(proc.pid, signal.SIGKILL)
|
|
284
|
+
except ProcessLookupError:
|
|
285
|
+
pass
|
|
286
|
+
signal.signal(signal.SIGTERM, lambda *a: (stop_pi(), save(stats), sys.exit(1)))
|
|
287
|
+
error = ""
|
|
288
|
+
try:
|
|
289
|
+
for raw in iter(proc.stdout.readline, b""):
|
|
290
|
+
try:
|
|
291
|
+
ev = json.loads(raw)
|
|
292
|
+
except ValueError:
|
|
293
|
+
continue
|
|
294
|
+
kind = ev.get("type")
|
|
295
|
+
if kind == "message_end" and ev.get("message", {}).get("role") == "assistant":
|
|
296
|
+
m = ev["message"]
|
|
297
|
+
u = m.get("usage") or {}
|
|
298
|
+
stats["turns"] += 1
|
|
299
|
+
stats["output_tokens"] += u.get("output") or 0
|
|
300
|
+
stats["input_tokens"] += (u.get("input") or 0) + (u.get("cacheRead") or 0)
|
|
301
|
+
text = "".join(c.get("text", "") for c in m.get("content", []) if c.get("type") == "text").strip()
|
|
302
|
+
if text:
|
|
303
|
+
stats["final_message"] = text
|
|
304
|
+
if m.get("errorMessage"):
|
|
305
|
+
error = str(m["errorMessage"])
|
|
306
|
+
print(f"turn {stats['turns']}: {u.get('output') or 0} tokens, {m.get('stopReason')}"
|
|
307
|
+
+ (f": {short(text)}" if text else "") + (f" [error: {short(error)}]" if error else ""),
|
|
308
|
+
flush=True)
|
|
309
|
+
if stats["turns"] >= max_turns and m.get("stopReason") == "toolUse":
|
|
310
|
+
stats["stop"] = "turn limit"
|
|
311
|
+
print(f"turn limit ({max_turns}) reached", flush=True)
|
|
312
|
+
break
|
|
313
|
+
elif kind == "tool_execution_start":
|
|
314
|
+
stats["tool_calls"] += 1
|
|
315
|
+
args = ev.get("args") or {}
|
|
316
|
+
what = args.get("command") or args.get("path") or json.dumps(args)
|
|
317
|
+
if "pytest" in json.dumps(args) or "unittest" in json.dumps(args):
|
|
318
|
+
stats["ran_tests"] = True
|
|
319
|
+
print(f" {ev.get('toolName')}: {short(what)}", flush=True)
|
|
320
|
+
elif kind == "tool_execution_end" and ev.get("toolName") == "subagent" and scouts:
|
|
321
|
+
print(add_subagents(stats, ev), flush=True)
|
|
322
|
+
elif kind == "tool_execution_end" and ev.get("isError"):
|
|
323
|
+
if ev.get("toolName") != "bash": # a failed edit or a bad call, not a failing command
|
|
324
|
+
stats["tool_errors"] += 1
|
|
325
|
+
out = " ".join(c.get("text", "") for c in (ev.get("result") or {}).get("content", []))
|
|
326
|
+
print(f" ! {ev.get('toolName')} failed: {short(out)}", flush=True)
|
|
327
|
+
elif kind == "agent_settled":
|
|
328
|
+
stats["stop"] = stats["stop"] or ("error" if ev.get("aborted") or error else "done")
|
|
329
|
+
break
|
|
330
|
+
finally:
|
|
331
|
+
stop_pi()
|
|
332
|
+
proc.wait()
|
|
333
|
+
err = proc.stderr.read().decode("utf-8", "replace").strip()
|
|
334
|
+
if err:
|
|
335
|
+
print("pi stderr: " + short(err, 600), flush=True)
|
|
336
|
+
shutil.rmtree(tmp, ignore_errors=True)
|
|
337
|
+
if not stats["stop"]:
|
|
338
|
+
stats["stop"] = "error"
|
|
339
|
+
error = error or f"pi exited ({proc.returncode})"
|
|
340
|
+
if error and any(s in error for s in SERVER_ERRORS):
|
|
341
|
+
stats["server_error"] = error # the server failed, not the model: tuieval asks the task again
|
|
342
|
+
save(stats)
|
|
343
|
+
return 0
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
def save(stats):
|
|
347
|
+
with open(os.environ["TUIEVAL_STATS_FILE"], "w") as f:
|
|
348
|
+
json.dump(stats, f)
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
if __name__ == "__main__":
|
|
352
|
+
sys.exit(main())
|
tuieval/agents.py
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"""Agent packs: coding tasks a command-line agent works on, graded by tests.
|
|
2
2
|
|
|
3
|
-
models.toml says how to start each agent (any program; {root} is the workspace
|
|
3
|
+
models.toml says how to start each agent (any program; {root} is the workspace, {tuieval_python} the Python
|
|
4
|
+
tuieval runs with):
|
|
4
5
|
|
|
5
6
|
[agents.my-agent]
|
|
6
7
|
cmd = ["python3", "{root}/agents/my_agent.py"]
|
|
7
8
|
|
|
9
|
+
Built in (builtin.toml, replaced by an [agents.<name>] of the same name): "pi" and "pi-scouts", pi through
|
|
10
|
+
tuieval/adapters/pi.py.
|
|
11
|
+
|
|
8
12
|
[defaults]
|
|
9
13
|
agent = "my-agent" # for agent packs that don't name one (pack.toml agent = "...")
|
|
10
14
|
|
|
@@ -28,9 +32,11 @@ The agent learns the rest from its environment:
|
|
|
28
32
|
TUIEVAL_STATS_FILE where it may write its stats as JSON when it finishes (all optional):
|
|
29
33
|
agent ("name version"), turns, input_tokens, output_tokens, tool_calls,
|
|
30
34
|
tool_errors (failed edits, bad tool calls; not commands that exit nonzero),
|
|
31
|
-
ran_tests, stop ("done", "turn limit" or "error"), final_message,
|
|
35
|
+
ran_tests, stop ("done", "turn limit" or "error"), final_message,
|
|
32
36
|
server_error: the model's server failed, not the model (the task isn't counted
|
|
33
|
-
and is asked again)
|
|
37
|
+
and is asked again), and subagent_calls, subagent_tasks, subagent_failed,
|
|
38
|
+
subagent_turns, subagent_input_tokens, subagent_output_tokens for work handed to
|
|
39
|
+
subagents (also counted in input_tokens and output_tokens)
|
|
34
40
|
|
|
35
41
|
PATH starts with the pack's Python (pack.toml python, else tuieval's), so `python` runs the tasks'
|
|
36
42
|
code and tests. The agent's exit code decides nothing; the tests do.
|
|
@@ -55,8 +61,12 @@ PROMPT_TAIL = "\n\nYou're working in a project in the current directory. Run Pyt
|
|
|
55
61
|
GRADE_TIMEOUT_S = 300
|
|
56
62
|
DIFF_KEEP = 20_000 # characters of the diff kept in the result (the whole diff is in the log)
|
|
57
63
|
HIDDEN_RE = re.compile(r"\.?_hidden\b") # junit names of the hidden tests (a collection error starts with ".")
|
|
64
|
+
# subagent_*: work the agent handed to subagents (counted in its own input/output tokens too), e.g. the
|
|
65
|
+
# built-in pi-scouts agent's scouts
|
|
66
|
+
SUBAGENT_KEYS = ("subagent_calls", "subagent_tasks", "subagent_failed", "subagent_turns", "subagent_input_tokens",
|
|
67
|
+
"subagent_output_tokens")
|
|
58
68
|
STATS_KEYS = ("agent", "turns", "input_tokens", "output_tokens", "tool_calls", "tool_errors", "ran_tests", "stop",
|
|
59
|
-
"final_message", "server_error")
|
|
69
|
+
"final_message", "server_error", *SUBAGENT_KEYS)
|
|
60
70
|
|
|
61
71
|
|
|
62
72
|
class AgentError(Exception):
|
tuieval/builtin.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Built-in defaults and
|
|
1
|
+
# Built-in defaults, servers and agents, used when a workspace's models.toml doesn't define them.
|
|
2
2
|
# [defaults] fill in key by key; [sampling] only when models.toml has no [sampling] at all (it's part of
|
|
3
|
-
# every result's fingerprint); a server here is replaced whole by one of the same name in models.toml.
|
|
3
|
+
# every result's fingerprint); a server or agent here is replaced whole by one of the same name in models.toml.
|
|
4
4
|
|
|
5
5
|
[defaults]
|
|
6
6
|
repeat = 3
|
|
@@ -85,3 +85,13 @@ pin_endpoint = true
|
|
|
85
85
|
api_key_env = "OPENROUTER_API_KEY"
|
|
86
86
|
thinking_param = "reasoning" # [sampling] enable_thinking -> OpenRouter's reasoning.enabled
|
|
87
87
|
headers = { "X-Title" = "tuieval" }
|
|
88
|
+
|
|
89
|
+
# pi (https://github.com/earendil-works/pi) for agent packs, through the built-in adapter (tuieval/adapters/pi.py):
|
|
90
|
+
# bare pi on the served model, sandboxed on macOS. pi-scouts adds pi's subagent extension and a read-only "scout"
|
|
91
|
+
# agent on the same model, which the lead may send in parallel. pi must be on PATH. {tuieval_python} is the
|
|
92
|
+
# Python tuieval runs with. Use one in a pack with agent = "pi" (pack.toml) or [defaults] agent = "pi".
|
|
93
|
+
[agents.pi]
|
|
94
|
+
cmd = ["{tuieval_python}", "-m", "tuieval.adapters.pi"]
|
|
95
|
+
|
|
96
|
+
[agents.pi-scouts]
|
|
97
|
+
cmd = ["{tuieval_python}", "-m", "tuieval.adapters.pi", "--scouts"]
|
tuieval/compare.py
CHANGED
|
@@ -639,7 +639,9 @@ def items(rows):
|
|
|
639
639
|
|
|
640
640
|
def agent_table(rows):
|
|
641
641
|
"""(header, table) summing up agent-pack tasks per model and pack, or None without any. A pack run
|
|
642
|
-
by more than one agent version is marked, since a new version can change how models do.
|
|
642
|
+
by more than one agent version is marked, since a new version can change how models do. A
|
|
643
|
+
"subagent tasks" column (tasks handed to subagents, out of the agent's calls) appears only when
|
|
644
|
+
some agent reported subagent stats."""
|
|
643
645
|
groups = collections.defaultdict(list)
|
|
644
646
|
for r in rows:
|
|
645
647
|
if r.get("agent"):
|
|
@@ -648,6 +650,9 @@ def agent_table(rows):
|
|
|
648
650
|
return None
|
|
649
651
|
header = ["model", "pack", "passed", "med min", "med turns", "out tokens", "tool errors", "ran tests",
|
|
650
652
|
"limits hit", "tests edited", "agent"]
|
|
653
|
+
subagents = any("subagent_tasks" in r["agent"] for rs in groups.values() for r in rs)
|
|
654
|
+
if subagents:
|
|
655
|
+
header.insert(-1, "subagent tasks")
|
|
651
656
|
table = []
|
|
652
657
|
for (model, suite), rs in sorted(groups.items()):
|
|
653
658
|
a = [r["agent"] for r in rs]
|
|
@@ -662,6 +667,10 @@ def agent_table(rows):
|
|
|
662
667
|
str(sum(x.get("stop") in ("time limit", "turn limit") for x in a)),
|
|
663
668
|
str(sum(bool(x.get("tests_edited")) for x in a)),
|
|
664
669
|
" + ".join(versions) + (" (MIXED)" if len(versions) > 1 else "")])
|
|
670
|
+
if subagents:
|
|
671
|
+
sub = [x for x in a if "subagent_tasks" in x]
|
|
672
|
+
table[-1].insert(-1, f"{sum(x['subagent_tasks'] for x in sub)} in "
|
|
673
|
+
f"{sum(x.get('subagent_calls') or 0 for x in sub)} calls" if sub else "-")
|
|
665
674
|
return header, table
|
|
666
675
|
|
|
667
676
|
|
tuieval/engine.py
CHANGED
|
@@ -45,6 +45,7 @@ import socket
|
|
|
45
45
|
import statistics
|
|
46
46
|
import string
|
|
47
47
|
import subprocess
|
|
48
|
+
import sys
|
|
48
49
|
import tempfile
|
|
49
50
|
import threading
|
|
50
51
|
import time
|
|
@@ -105,7 +106,7 @@ def hosted(cfg, m):
|
|
|
105
106
|
def load_config(path):
|
|
106
107
|
"""Read models.toml, fill in the built-ins it leaves out (builtin.toml) and each model's defaults.
|
|
107
108
|
[defaults] are filled key by key; [sampling] only when models.toml has none (sampling is part of
|
|
108
|
-
every result's fingerprint, so a workspace's own keys are never added to); servers by name."""
|
|
109
|
+
every result's fingerprint, so a workspace's own keys are never added to); servers and agents by name."""
|
|
109
110
|
with open(path, "rb") as f:
|
|
110
111
|
cfg = tomllib.load(f)
|
|
111
112
|
builtin = builtin_config()
|
|
@@ -117,6 +118,7 @@ def load_config(path):
|
|
|
117
118
|
own = cfg.get("servers", {})
|
|
118
119
|
cfg["servers"] = {**builtin["servers"], **own}
|
|
119
120
|
cfg["builtin_servers"] = sorted(set(builtin["servers"]) - set(own)) # not defined in models.toml
|
|
121
|
+
cfg["agents"] = {**builtin.get("agents", {}), **cfg.get("agents", {})}
|
|
120
122
|
cfg.setdefault("models", [])
|
|
121
123
|
seen = set()
|
|
122
124
|
for m in cfg["models"]:
|
|
@@ -2310,7 +2312,7 @@ class Engine:
|
|
|
2310
2312
|
python = agents.python_for(job.pack, self.root)
|
|
2311
2313
|
m, s = job.model, job.sampling
|
|
2312
2314
|
key_env = self.cfg["servers"][m["server"]].get("api_key_env")
|
|
2313
|
-
cmd = [expand(str(a), root=self.root) for a in agent["cmd"]]
|
|
2315
|
+
cmd = [expand(str(a), root=self.root, tuieval_python=sys.executable) for a in agent["cmd"]]
|
|
2314
2316
|
live = os.path.join(self.log_dir, "live")
|
|
2315
2317
|
os.makedirs(live, exist_ok=True)
|
|
2316
2318
|
waits = list(self.SERVER_RETRY_WAITS_S)
|
|
@@ -2377,7 +2379,7 @@ class Engine:
|
|
|
2377
2379
|
"agent": {"name": name, "version": stats.get("agent"), "stop": stop if stop != "exited" else
|
|
2378
2380
|
stats.get("stop") or "exited",
|
|
2379
2381
|
**{k: stats[k] for k in ("turns", "input_tokens", "output_tokens", "tool_calls",
|
|
2380
|
-
"tool_errors", "ran_tests") if k in stats},
|
|
2382
|
+
"tool_errors", "ran_tests", *agents.SUBAGENT_KEYS) if k in stats},
|
|
2381
2383
|
"exit_code": code, "tests_edited": edited, "visible": g["visible"],
|
|
2382
2384
|
"hidden": g["hidden"], "failed": g["failed"], "diff": patch[:agents.DIFF_KEEP],
|
|
2383
2385
|
"diff_cut": len(patch) > agents.DIFF_KEEP}}
|
|
@@ -2716,6 +2718,7 @@ class Engine:
|
|
|
2716
2718
|
"model": {**{k: m.get(k) for k in ("label", "served_name", "server", "model", "tags", "vision", "mmproj")},
|
|
2717
2719
|
**{k: m[k] for k in ("tools", "max_context", "thinking") if k in m}},
|
|
2718
2720
|
"pack": {"name": job.pack.name, "label": job.pack.label, "group": job.pack.group,
|
|
2721
|
+
"use_case": job.pack.use_case,
|
|
2719
2722
|
"fingerprint": job.pack.fingerprint, "tests": len(job.pack.tests),
|
|
2720
2723
|
**({"max_tokens": job.pack.max_tokens} if job.pack.max_tokens else {})},
|
|
2721
2724
|
"settings": job.sampling,
|
tuieval/insights.py
CHANGED
|
@@ -25,7 +25,7 @@ import statistics
|
|
|
25
25
|
|
|
26
26
|
from rich.markup import escape as rich_escape
|
|
27
27
|
|
|
28
|
-
from . import compare
|
|
28
|
+
from . import compare, verdict
|
|
29
29
|
|
|
30
30
|
MIN_SHARE = 0.5 # like the PTA index: models with fewer answers than this share of the most-answered are left out
|
|
31
31
|
HALF = 15 # half width of a diverging bar
|
|
@@ -140,20 +140,18 @@ def _heat(acc):
|
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
def use_cases(rows, models, packs):
|
|
143
|
-
"""packs: {name: Pack} (for
|
|
143
|
+
"""packs: {name: Pack} (for use cases, their sections and question counts)."""
|
|
144
144
|
title = "Best model per use case"
|
|
145
|
-
|
|
146
|
-
for name, p in packs.items()
|
|
147
|
-
|
|
148
|
-
groups.append(p.group)
|
|
149
|
-
groups = [g for g in groups if any(packs.get(r["suite"]) and packs[r["suite"]].group == g for r in rows)]
|
|
145
|
+
section_of = {u: sec for sec, ucs in verdict.sections(packs) for u in ucs}
|
|
146
|
+
uc = {name: verdict.use_case_of(p) for name, p in packs.items()}
|
|
147
|
+
groups = [u for u in section_of if any(uc.get(r["suite"]) == u for r in rows)]
|
|
150
148
|
if not groups:
|
|
151
149
|
return {"title": title, "lines": ["[dim]No results yet.[/dim]"], "actions": []}
|
|
152
|
-
size = {g: sum(len(p.tests) for p in packs.
|
|
153
|
-
per = collections.defaultdict(lambda: collections.defaultdict(list)) # (model,
|
|
150
|
+
size = {g: sum(len(p.tests) for name, p in packs.items() if uc[name] == g) for g in groups}
|
|
151
|
+
per = collections.defaultdict(lambda: collections.defaultdict(list)) # (model, use case) -> test -> oks
|
|
154
152
|
for r in rows:
|
|
155
153
|
if r["suite"] in packs:
|
|
156
|
-
per[r["model"],
|
|
154
|
+
per[r["model"], uc[r["suite"]]][r["test"]].append(r["ok"])
|
|
157
155
|
cell = {}
|
|
158
156
|
for m in models:
|
|
159
157
|
for g in groups:
|
|
@@ -168,7 +166,18 @@ def use_cases(rows, models, packs):
|
|
|
168
166
|
best[g] = (sorted((m for m, a in full.items() if a == top)), sorted(full.items(), key=lambda x: -x[1]))
|
|
169
167
|
w = max(len(m) for m in models)
|
|
170
168
|
short = {g: (g if len(g) <= CELL - 1 else f"{groups.index(g) + 1} {g[:CELL - 4]}…") for g in groups}
|
|
171
|
-
|
|
169
|
+
spans, prev = [], None # the section names over their use cases' columns
|
|
170
|
+
for g in groups:
|
|
171
|
+
if section_of[g] != prev:
|
|
172
|
+
spans.append([section_of[g], 0])
|
|
173
|
+
prev = section_of[g]
|
|
174
|
+
spans[-1][1] += 1
|
|
175
|
+
heading = ""
|
|
176
|
+
for sec, n in spans:
|
|
177
|
+
name = sec.upper()[:n * CELL - 2]
|
|
178
|
+
heading += f"[b underline]{_esc(name)}[/]" + " " * (n * CELL - len(name))
|
|
179
|
+
lines = [" " * (w + 2) + heading]
|
|
180
|
+
lines.append(" " * (w + 2) + "".join(f"[b]{short[g]:<{CELL}}[/b]" for g in groups))
|
|
172
181
|
for m in models:
|
|
173
182
|
cells = []
|
|
174
183
|
for g in groups:
|
tuieval/packs.py
CHANGED
|
@@ -63,6 +63,11 @@ class Pack:
|
|
|
63
63
|
agent: str = "" # agent packs: the [agents.<name>] that runs them ("" = [defaults] agent)
|
|
64
64
|
python: str = "" # agent packs: the Python the tasks and their tests run with ("" = tuieval's)
|
|
65
65
|
min_context: int = 0 # context the pack needs, when its prompts don't show it (agent packs)
|
|
66
|
+
use_case: str = "" # what its verdict counts toward (pack.toml use_case; "" = its group). The group is
|
|
67
|
+
# the section it's listed under: a section can hold several use cases.
|
|
68
|
+
|
|
69
|
+
def __post_init__(self):
|
|
70
|
+
self.use_case = self.use_case or self.group
|
|
66
71
|
|
|
67
72
|
@property
|
|
68
73
|
def modules(self):
|
|
@@ -238,7 +243,8 @@ def _load_agent_pack(name, path, meta, meta_path):
|
|
|
238
243
|
raise PackError(f"{meta_path}: min_context must be a whole number above 0, not {min_context!r}")
|
|
239
244
|
gate = {"min_accuracy": 0.8, **meta.get("gate", {})}
|
|
240
245
|
return Pack(name=name, path=path, label=meta.get("label", name), group=meta.get("group", "Other"),
|
|
241
|
-
|
|
246
|
+
use_case=meta.get("use_case", ""), description=meta.get("description", ""), grader="agent",
|
|
247
|
+
system="", needs=[], tools=[],
|
|
242
248
|
tests=tests, fingerprint=_task_fingerprint(tests), gate=gate, screen=int(meta.get("screen", 10)),
|
|
243
249
|
certify_repeat=int(meta.get("certify", {}).get("repeat", 0)),
|
|
244
250
|
stop_early=bool(meta.get("stop_early", False)), kind="agent", agent=str(meta.get("agent", "")),
|
|
@@ -323,7 +329,8 @@ def load_pack(path):
|
|
|
323
329
|
if "max_tokens" in meta and (isinstance(max_tokens, bool) or not isinstance(max_tokens, int) or max_tokens < 1):
|
|
324
330
|
raise PackError(f"{meta_path}: max_tokens must be a whole number above 0, not {max_tokens!r}")
|
|
325
331
|
return Pack(name=name, path=path, label=meta.get("label", name), group=meta.get("group", "Other"),
|
|
326
|
-
|
|
332
|
+
use_case=meta.get("use_case", ""), description=meta.get("description", ""),
|
|
333
|
+
grader=meta.get("grader", "answer"),
|
|
327
334
|
system=system, needs=list(needs), tools=tools, tests=tests,
|
|
328
335
|
fingerprint=_fingerprint(system, tools, meta.get("grader", "answer"), tests, images, max_tokens),
|
|
329
336
|
gate=gate, screen=int(meta.get("screen", 10)),
|
tuieval/tui.py
CHANGED
|
@@ -65,7 +65,7 @@ def model_verdicts(e):
|
|
|
65
65
|
results (when = None) or, failing that, the last recorded one (when = its date)."""
|
|
66
66
|
current = verdict.readiness(e)
|
|
67
67
|
last = verdict.latest(verdict.load_history(e))
|
|
68
|
-
groups =
|
|
68
|
+
groups = use_case_order(e)
|
|
69
69
|
out = {}
|
|
70
70
|
for m in e.cfg["models"]:
|
|
71
71
|
label, rows = m["label"], []
|
|
@@ -82,10 +82,20 @@ def model_verdicts(e):
|
|
|
82
82
|
VERDICT_MARK = {"PASS": "✓", "FAIL": "✗", "INCONCLUSIVE": "?"}
|
|
83
83
|
|
|
84
84
|
|
|
85
|
+
def use_case_order(e):
|
|
86
|
+
"""Every use case, section by section in pack order (see verdict.sections)."""
|
|
87
|
+
return [u for _, ucs in verdict.sections(e.packs) for u in ucs]
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def section_starts(e):
|
|
91
|
+
"""The use cases that open a section after the first: the model list puts a divider before each."""
|
|
92
|
+
return {ucs[0] for _, ucs in verdict.sections(e.packs)[1:]}
|
|
93
|
+
|
|
94
|
+
|
|
85
95
|
def group_codes(e):
|
|
86
96
|
"""{use case: short code}: its first letter, or its words' initials, or more letters, whichever
|
|
87
97
|
is the shortest that keeps every code unique (Coding -> C; Demo answer, Demo code -> DA, DC)."""
|
|
88
|
-
groups =
|
|
98
|
+
groups = use_case_order(e)
|
|
89
99
|
|
|
90
100
|
def initials(g, extra=0):
|
|
91
101
|
words = g.split() or [g]
|
|
@@ -98,12 +108,15 @@ def group_codes(e):
|
|
|
98
108
|
return {g: f"{g[:1].upper()}{i + 1}" for i, g in enumerate(groups)}
|
|
99
109
|
|
|
100
110
|
|
|
101
|
-
def verdict_codes(rows, codes):
|
|
102
|
-
"""Compact markup, e.g. C✗ D? T✓ (colour = verdict, dim = from earlier results), one fixed
|
|
103
|
-
column per use case so rows line up; blank where a use case has no verdict.
|
|
111
|
+
def verdict_codes(rows, codes, starts=()):
|
|
112
|
+
"""Compact markup, e.g. C✗ D? │ T✓ (colour = verdict, dim = from earlier results), one fixed
|
|
113
|
+
column per use case so rows line up; blank where a use case has no verdict. starts: use cases that
|
|
114
|
+
open a section (a divider goes before each)."""
|
|
104
115
|
by_group = {g: (status, when) for g, status, when in rows}
|
|
105
116
|
out = []
|
|
106
117
|
for g in list(codes) + [g for g in by_group if g not in codes]:
|
|
118
|
+
if g in starts and out:
|
|
119
|
+
out.append("│")
|
|
107
120
|
code = codes.get(g, g[:1].upper())
|
|
108
121
|
if g not in by_group:
|
|
109
122
|
out.append(" " * (len(code) + 1))
|
|
@@ -757,7 +770,7 @@ class SetupScreen(Screen):
|
|
|
757
770
|
yield Header()
|
|
758
771
|
yield Static(id="machine")
|
|
759
772
|
with Horizontal(id="pickers"):
|
|
760
|
-
with Vertical(classes="picker"):
|
|
773
|
+
with Vertical(classes="picker", id="packs-picker"):
|
|
761
774
|
yield Label("[b]Eval packs[/b] (space to toggle · e picks tests)")
|
|
762
775
|
yield SelectionList(id="suites")
|
|
763
776
|
with Vertical(classes="picker"):
|
|
@@ -849,6 +862,21 @@ class SetupScreen(Screen):
|
|
|
849
862
|
if not e.packs:
|
|
850
863
|
for i, line in enumerate(NO_PACKS):
|
|
851
864
|
packs.add_option(Selection(line, f"\x00nopacks:{i}", disabled=True))
|
|
865
|
+
self.fit_packs_panel()
|
|
866
|
+
|
|
867
|
+
def fit_packs_panel(self):
|
|
868
|
+
"""Eval packs gets the width its longest line needs (at most 45% of the screen); the models
|
|
869
|
+
panel, whose lines are longer, gets the rest."""
|
|
870
|
+
packs = self.query_one("#suites", SelectionList)
|
|
871
|
+
if not self.size.width or not packs.option_count:
|
|
872
|
+
return
|
|
873
|
+
widest = max(Text.from_markup(str(packs.get_option_at_index(i).prompt)).cell_len
|
|
874
|
+
for i in range(packs.option_count))
|
|
875
|
+
need = max(widest, len("Eval packs (space to toggle · e picks tests)")) + 10 # tick box, scrollbar, padding
|
|
876
|
+
self.query_one("#packs-picker").styles.width = max(30, min(need, int(self.size.width * 0.45)))
|
|
877
|
+
|
|
878
|
+
def on_resize(self, event):
|
|
879
|
+
self.fit_packs_panel()
|
|
852
880
|
|
|
853
881
|
def refresh_models(self, select=None):
|
|
854
882
|
"""Local models, then each hosted API's models tried so far, best verdicts first. Hidden
|
|
@@ -870,7 +898,7 @@ class SetupScreen(Screen):
|
|
|
870
898
|
except Exception as err: # a broken results file must not hide the model list
|
|
871
899
|
self.verdicts = {}
|
|
872
900
|
self.app.log(f"verdicts failed: {err!r}")
|
|
873
|
-
codes = group_codes(e)
|
|
901
|
+
codes, starts = group_codes(e), section_starts(e)
|
|
874
902
|
self.legend_codes = codes
|
|
875
903
|
n_hidden = sum(m["label"] in hidden for m in e.cfg["models"])
|
|
876
904
|
self.query_one("#show-hidden", Checkbox).label = f"Show hidden ({n_hidden})"
|
|
@@ -897,7 +925,8 @@ class SetupScreen(Screen):
|
|
|
897
925
|
(" [dim italic]hidden[/dim italic]" if label in hidden else "")
|
|
898
926
|
where = "" if m.get("remote") else f" [dim]{m['server']}[/dim]{serving_badge(e, m, newcomer)}"
|
|
899
927
|
rows = self.verdicts.get(label, [])
|
|
900
|
-
vcodes = verdict_codes(rows, codes) if rows
|
|
928
|
+
vcodes = (verdict_codes(rows, codes, starts) if rows
|
|
929
|
+
else f"[dim]{'not run':<{len(verdict_codes([], codes, starts))}}[/dim]")
|
|
901
930
|
# a Selection shows one line only: keep it short, the detail line has the rest
|
|
902
931
|
models.add_option(Selection(f"{label:<{width}} {vcodes}{flags}{where}{extra}",
|
|
903
932
|
label, label in self.selected_models))
|
|
@@ -3660,9 +3689,18 @@ class ResultsScreen(Screen):
|
|
|
3660
3689
|
short.append(" [dim]To run Certify: in Setup tick the model and pack, choose Certify, press s.[/dim]")
|
|
3661
3690
|
self.query_one("#readiness-short", Static).update("\n".join(short) if table else
|
|
3662
3691
|
"[dim]No verdicts yet: run something from Setup.[/dim]")
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3692
|
+
present = {g for t in table.values() for g in t}
|
|
3693
|
+
section_of = {u: sec for sec, ucs in verdict.sections(self.app.engine.packs) for u in ucs}
|
|
3694
|
+
groups = [u for u in use_case_order(self.app.engine) if u in present] + sorted(present - set(section_of))
|
|
3695
|
+
# two header lines: the section over its first use case, then the use case
|
|
3696
|
+
matrix.header_height = 2
|
|
3697
|
+
heads, prev = [], None
|
|
3698
|
+
for g in groups:
|
|
3699
|
+
sec = section_of.get(g, "")
|
|
3700
|
+
heads.append(Text(f"{sec.upper() if sec != prev else ''}\n{g}", style="bold"))
|
|
3701
|
+
prev = sec
|
|
3702
|
+
matrix.add_columns(Text("\nModel", style="bold"), *heads)
|
|
3703
|
+
detail.add_columns("Model", "Section", "Use case", "Pack", "Verdict", "Answers right", "Answered", "Why")
|
|
3666
3704
|
right = collections.Counter((r["model"], r["suite"]) for r in self.rows if r["ok"])
|
|
3667
3705
|
answered = collections.Counter((r["model"], r["suite"]) for r in self.rows)
|
|
3668
3706
|
when = collections.defaultdict(list)
|
|
@@ -3681,11 +3719,12 @@ class ResultsScreen(Screen):
|
|
|
3681
3719
|
for g in gs:
|
|
3682
3720
|
row = lat.get(label, {}).get(g, {})
|
|
3683
3721
|
lt.add_row(label, g, *[latency_cell(row.get(mid)) for mid in machine_ids])
|
|
3684
|
-
for g
|
|
3722
|
+
for g in sorted(gs, key=lambda u: groups.index(u) if u in groups else len(groups)):
|
|
3723
|
+
packs = gs[g][1]
|
|
3685
3724
|
for name, pv in packs.items():
|
|
3686
3725
|
if pv.status != "NO DATA":
|
|
3687
3726
|
n = answered[(label, name)]
|
|
3688
|
-
detail.add_row(label, g, name, f"[{style[pv.status]}]{pv.status}[/]",
|
|
3727
|
+
detail.add_row(label, section_of.get(g, ""), g, name, f"[{style[pv.status]}]{pv.status}[/]",
|
|
3689
3728
|
f"{right[(label, name)]}/{n}" if n else "-", dates.span(when[(label, name)]),
|
|
3690
3729
|
"; ".join(pv.reasons)[:160])
|
|
3691
3730
|
|
tuieval/verdict.py
CHANGED
|
@@ -265,9 +265,27 @@ def latency_table(engine, labels=None, table=None, ran_on=None):
|
|
|
265
265
|
return out
|
|
266
266
|
|
|
267
267
|
|
|
268
|
+
def sections(packs):
|
|
269
|
+
"""[(section, [use case, ...])] in pack order: a section is a pack.toml `group`, a use case is a pack's
|
|
270
|
+
`use_case` (its group when it has none), listed in the section of its first pack."""
|
|
271
|
+
out, seen = {}, set()
|
|
272
|
+
for p in packs.values():
|
|
273
|
+
uc = use_case_of(p)
|
|
274
|
+
if uc not in seen:
|
|
275
|
+
seen.add(uc)
|
|
276
|
+
out.setdefault(p.group, []).append(uc)
|
|
277
|
+
return list(out.items())
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def use_case_of(pack):
|
|
281
|
+
"""A pack's use case: pack.toml use_case, or its group."""
|
|
282
|
+
return getattr(pack, "use_case", "") or pack.group
|
|
283
|
+
|
|
284
|
+
|
|
268
285
|
def readiness(engine, labels=None, ran_on=None):
|
|
269
286
|
"""{label: {use_case: (verdict, {pack: verdict})}} for every model with results.
|
|
270
|
-
A use case is a pack
|
|
287
|
+
A use case is a pack's `use_case` (pack.toml; its `group` when it has none), e.g. Coding = the coding and
|
|
288
|
+
coding-advanced packs.
|
|
271
289
|
ran_on: (machine, hosted_any) judges only the answers that ran on that machine (see records)."""
|
|
272
290
|
out = {}
|
|
273
291
|
for m in engine.cfg["models"]:
|
|
@@ -278,7 +296,7 @@ def readiness(engine, labels=None, ran_on=None):
|
|
|
278
296
|
recs = records(engine, m["label"], name, ran_on)
|
|
279
297
|
if engine.result_status(m["label"], name) not in ("certified", "screened"):
|
|
280
298
|
recs = [] # missing or outdated results don't count
|
|
281
|
-
by_group.setdefault(pack.
|
|
299
|
+
by_group.setdefault(pack.use_case, {})[name] = evaluate(pack, recs, engine.certify_repeat(pack))
|
|
282
300
|
groups = {g: (combine(v), v) for g, v in by_group.items()
|
|
283
301
|
if any(x.status != "NO DATA" for x in v.values())}
|
|
284
302
|
if groups:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: tuieval
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0.dev2
|
|
4
4
|
Summary: Evaluate local and frontier LLMs on your own questions: accuracy, speed, tokens and PASS/FAIL verdicts, in the terminal.
|
|
5
5
|
Project-URL: Homepage, https://github.com/ashe-wb/tuieval
|
|
6
6
|
Project-URL: Issues, https://github.com/ashe-wb/tuieval/issues
|
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
tuieval/__init__.py,sha256=myVXVX7htbwezW6k3x_FuKgn1RSZ2WcTaDEMByGn6Wg,312
|
|
2
2
|
tuieval/__main__.py,sha256=E6Gls0DNz8GQK2K-kOUIx8cYhgANW_CH54VKrfCfs14,52
|
|
3
|
-
tuieval/_version.py,sha256=
|
|
4
|
-
tuieval/agents.py,sha256=
|
|
5
|
-
tuieval/builtin.toml,sha256=
|
|
3
|
+
tuieval/_version.py,sha256=Dvv6eOPcbaU80c-ESaC-CYYk_TtRZ5mMu0o3MINCfNg,533
|
|
4
|
+
tuieval/agents.py,sha256=3WFNlON_rGOmsYjHqPv2OqbYu2zXvCHH0ixVEAX-IWQ,16141
|
|
5
|
+
tuieval/builtin.toml,sha256=du2r1TxAH8StbiMDoTWUzy6xSRx4Y3cO1W_x_6P7iac,5387
|
|
6
6
|
tuieval/cli.py,sha256=Q9-b9sg6LSAfNq6o-c3J3hiOIoINgvH_Fe_U1x-0W4U,4915
|
|
7
7
|
tuieval/client.py,sha256=O77uftaxqgQ8b8rMnpR5822kmYFfr574w1pZlaSOFEE,14304
|
|
8
|
-
tuieval/compare.py,sha256=
|
|
8
|
+
tuieval/compare.py,sha256=h1Fy14yr5aE47leignmGvj_o9Z8eMb0rCX-KRIXaUik,40216
|
|
9
9
|
tuieval/ctxbench.py,sha256=VLl6Em7iCbZz2wwI9rTHMaWFMehcaJ7SYUL7g93B3j8,34366
|
|
10
10
|
tuieval/dates.py,sha256=CVazlwNjCRhD__D12zXLdeqF2ySt15X3xLUQeE-o6PY,6293
|
|
11
11
|
tuieval/doctor.py,sha256=j2MdDORstsAGPnRmpsnxau1_fR6sTc_oEFGM5zugTJU,7246
|
|
12
|
-
tuieval/engine.py,sha256=
|
|
12
|
+
tuieval/engine.py,sha256=Ji9spgPj3jQRcpXXVFXNMhC7rPF0aixzwtiKPqgeAMU,145568
|
|
13
13
|
tuieval/export.py,sha256=dbHQgL_ubWtIPM1sLzAew_gETnrDJyd0zgqVA5vkpXM,9657
|
|
14
|
-
tuieval/insights.py,sha256=
|
|
14
|
+
tuieval/insights.py,sha256=32mpNiLgSoxxZaJq9LBZKj5iJJCKChpGQYHSnar7bSo,30074
|
|
15
15
|
tuieval/logs.py,sha256=01gZK6tf53dIThaIrs1bEsz9eqKYVlcxpyaLnSPTVxo,8127
|
|
16
16
|
tuieval/machines.py,sha256=pWbWw1_B29U2H_c3PTrrOJkPO-wW_o12buxMay5TNdA,24515
|
|
17
17
|
tuieval/onboard.py,sha256=IYETVDWCCo9vF0Dtj4_rr9VanYeCky8PwP3-2g5A_l0,6215
|
|
18
|
-
tuieval/packs.py,sha256=
|
|
18
|
+
tuieval/packs.py,sha256=LPB9qhuN6zfic0zfVJuSE9lx4BTCFQJoibdB4vvGDhQ,17859
|
|
19
19
|
tuieval/profiles.py,sha256=3GribubCOCRTi_rClLxVynBeX2SBYTig0XObAlS8lzg,5300
|
|
20
20
|
tuieval/pta.py,sha256=MBn2EkDysayv8XOqiTKp5zomuUmZnZTuQ5jGBR2-Z4s,19281
|
|
21
21
|
tuieval/remove.py,sha256=ckep4iZUkuWE2JTcZFovCy7snNd_WLkJ6b602eGKZws,5339
|
|
22
22
|
tuieval/run_evals.py,sha256=vvLAJJUD6SJmJJ2LwCXl3IRj9h4dydvYpmzRgxOE7I8,56440
|
|
23
23
|
tuieval/scaffold.py,sha256=YBOqniJpf_GtKKAFF3_OHxxMGbmTWdFjcClGcOnrrKE,12130
|
|
24
24
|
tuieval/selftest.py,sha256=cIGSDCrCK-QISAXjKSJDB4sD-WwS32bn3Gn4Y0oGoF8,11502
|
|
25
|
-
tuieval/tui.py,sha256=
|
|
25
|
+
tuieval/tui.py,sha256=2ijU3DnaGLcoqaxKTsQdQd75U2MT7Q12u5BA7f4XZ2g,213337
|
|
26
26
|
tuieval/tune.py,sha256=V43Lo3x-flTuUFYXRt2_aqmpo4RML0adP-XUHWTgfRQ,41659
|
|
27
|
-
tuieval/verdict.py,sha256=
|
|
27
|
+
tuieval/verdict.py,sha256=eBPTAS6GTtslOe5t3PkH80bf-ZGu6TfK5-0448yFfwU,21843
|
|
28
28
|
tuieval/watch_proxy.py,sha256=bnDO1i6n6yUs1hODoUWcMppJMGPavoQqs6aNYrIxpT8,11416
|
|
29
29
|
tuieval/workspace.py,sha256=V_HhkaN1odr0OpjNsPYradRWLpzDldM7SwpvxohBL4U,895
|
|
30
30
|
tuieval/yamlout.py,sha256=r1IokjLqW-Ztpg1fSn33ZW3VK00v1VvxymmU5Qy7GEw,606
|
|
31
|
+
tuieval/adapters/__init__.py,sha256=EO0CiSKdLLe68GWfy6-V3eVL4XIY9nypkOgDs3AHArY,83
|
|
32
|
+
tuieval/adapters/pi.py,sha256=y4wm20XCPZz1ClUH3mh8ozNZxS9JatN-l2YjZY5WNtE,17318
|
|
31
33
|
tuieval/graders/__init__.py,sha256=HEjlh6FnCCuiMHfFwJgkJSdFIdNHH26O2VeEJlS4BY4,6384
|
|
32
34
|
tuieval/graders/answer.py,sha256=pTETs2LzOWPhtuuowMVXpLFwdnNjMw-7sELqrFV6ocQ,2125
|
|
33
35
|
tuieval/graders/code.py,sha256=eLjV1CfaBO398bBSWvNvEoJJTRXLVnTv51WKNqYzMSw,4459
|
|
@@ -51,8 +53,8 @@ tuieval/templates/packs/tool_call/pack.toml,sha256=n4bx0lGJHSmW41uVqhfIXJ2BWZpmT
|
|
|
51
53
|
tuieval/templates/packs/tool_call/system.txt,sha256=mKxu-lB-0YjLHXdgeFJa8x2C180OvcNz5cHv2N5Bg3U,254
|
|
52
54
|
tuieval/templates/packs/tool_call/tests.yaml,sha256=Nv7c4syrzJ9cU8EBKSK_1ZSFx9V02aCjW4-2TBCPT7s,1859
|
|
53
55
|
tuieval/templates/packs/tool_call/tools.yaml,sha256=HgxCkh0On2VwbHSsjAGM8tNCK7ZtKLGrs7lMCn3Fprs,1048
|
|
54
|
-
tuieval-0.
|
|
55
|
-
tuieval-0.
|
|
56
|
-
tuieval-0.
|
|
57
|
-
tuieval-0.
|
|
58
|
-
tuieval-0.
|
|
56
|
+
tuieval-0.3.0.dev2.dist-info/METADATA,sha256=hLTky7Ts9hSQwjSjBSRjxvJZxaTP6yG672IYa-gsHwY,15304
|
|
57
|
+
tuieval-0.3.0.dev2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
58
|
+
tuieval-0.3.0.dev2.dist-info/entry_points.txt,sha256=7eIhi1GpFxBP2OLJV02Nn8LwsNuO512eKOGt1IBbj04,45
|
|
59
|
+
tuieval-0.3.0.dev2.dist-info/licenses/LICENSE,sha256=7wfRgGtBGH1aXhZkIn47oUznqKC18kEPMvUVgol7Ffc,1077
|
|
60
|
+
tuieval-0.3.0.dev2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|