python-yama 0.5.0__py3-none-any.whl → 0.7.0__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.
- {python_yama-0.5.0.dist-info → python_yama-0.7.0.dist-info}/METADATA +3 -4
- {python_yama-0.5.0.dist-info → python_yama-0.7.0.dist-info}/RECORD +11 -10
- yama/assertions.py +32 -3
- yama/cli.py +236 -21
- yama/models.py +2 -0
- yama/report.py +234 -35
- yama/runner.py +265 -14
- yama/thread_case.py +403 -0
- {python_yama-0.5.0.dist-info → python_yama-0.7.0.dist-info}/WHEEL +0 -0
- {python_yama-0.5.0.dist-info → python_yama-0.7.0.dist-info}/entry_points.txt +0 -0
- {python_yama-0.5.0.dist-info → python_yama-0.7.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-yama
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: A reproducible evaluation runner for tool-using Agent skills
|
|
5
5
|
Project-URL: Repository, https://github.com/world-sim-dev/yama
|
|
6
6
|
Project-URL: Issues, https://github.com/world-sim-dev/yama/issues
|
|
@@ -72,15 +72,14 @@ steps:
|
|
|
72
72
|
- assistant_contains: creative direction
|
|
73
73
|
|
|
74
74
|
outcome:
|
|
75
|
-
require:
|
|
76
|
-
hard_checks: all_pass
|
|
75
|
+
require: {}
|
|
77
76
|
```
|
|
78
77
|
|
|
79
78
|
- `description` (optional) is a one-line summary of what the Case tests; it is shown in the CLI output and the HTML report.
|
|
80
79
|
- `context.tools` is the tool schema sent to the model; `mocks.tools` is how the runner responds when a tool call arrives. The two sets of tool names must match exactly.
|
|
81
80
|
- To use a Skill, declare it by name under `context.skills` and also declare `{builtin: skill}` under `context.tools`; the model reads the Skill body via `skill(name, file?, call_reason?)`.
|
|
82
81
|
- To simulate command-line tools, declare `{builtin: bash}` and configure per-command output under `mocks.cli`.
|
|
83
|
-
- `steps[].assert.hard` are deterministic checks (nine types, including `tool_called`, `tool_arguments`, and `assistant_contains`);
|
|
82
|
+
- `steps[].assert.hard` are deterministic checks (nine types, including `tool_called`, `tool_arguments`, and `assistant_contains`); untagged hard checks must all pass by default. Add `assert.judge` for LLM scoring.
|
|
84
83
|
|
|
85
84
|
For the full schema (every Skill/tool/mock form, the `bash` sandbox, message injection, judge configuration, and more), see the [design doc](https://github.com/world-sim-dev/yama/blob/main/docs/agent-skill-test-framework-design.md) (Chinese).
|
|
86
85
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
yama/__init__.py,sha256=UYhoZTSu1HiMT54LOZCdvLKMQ_L0qec8RT8jDfde_cY,1156
|
|
2
2
|
yama/__main__.py,sha256=k1ocEWawweo1qCJWNFAAvyxz3tcY13dzvCenHszij30,48
|
|
3
|
-
yama/assertions.py,sha256=
|
|
4
|
-
yama/cli.py,sha256=
|
|
3
|
+
yama/assertions.py,sha256=9tp_fuoFxqHPrClq_D1WF4i58TxgZUMnTdc-Kc9uKiw,23000
|
|
4
|
+
yama/cli.py,sha256=bM1w8AbSzLkaAKypznIfhGA0iWKbpN8BoS0a4G9vCpI,38032
|
|
5
5
|
yama/dashboard.py,sha256=0yxRh-j_5Mk6Ug_xgv9-VyBSEr1aVKxX-zJwxGfd_TU,11601
|
|
6
6
|
yama/llm.py,sha256=JzQ4YHhBLd1WE8W_ipTVcoNK6f-nSqRKDzqEl5kmuis,16085
|
|
7
7
|
yama/mocks.py,sha256=YyiU6Y7NgttxHYJBsqGPILKYlTsM4IMTIilMNRkUuzs,14973
|
|
8
|
-
yama/models.py,sha256=
|
|
8
|
+
yama/models.py,sha256=zd8RIxvUoWa3OdCLIRtgLvYmCVtkAjhQECJheo3HmKE,4128
|
|
9
9
|
yama/preview.py,sha256=gVTMqArXQqOLktGnactK9c0kfX6oHd6fWGjhkB7-QLQ,14220
|
|
10
|
-
yama/report.py,sha256=
|
|
11
|
-
yama/runner.py,sha256=
|
|
10
|
+
yama/report.py,sha256=WVY4EWInVQbE-Pv2LFHcH-QMoPFpdOd5unDs4uGEq-w,64557
|
|
11
|
+
yama/runner.py,sha256=e3vIBgYBAbhRzG7aUTb9YKw5HJlEUWdpASIDwav1RGQ,38942
|
|
12
|
+
yama/thread_case.py,sha256=9TvZxbzqk3Klihq9ghyRcyhv63HSkjEMQgrOEf26L4g,13171
|
|
12
13
|
yama/workspace.py,sha256=4GAe36Uj1-gjROMPwrQfTIg1TkzEIk9-gHEuezjbY_I,4614
|
|
13
14
|
yama/loaders/__init__.py,sha256=DIwfa8QlIlKt6NpFMZJ_OcqbJPPrmKLBzd9_e-BCuBs,174
|
|
14
15
|
yama/loaders/case.py,sha256=5uUpXm1t9EOmee2BZe7vDGXCrc4CSgcFGApSkuFe5tc,13954
|
|
@@ -22,8 +23,8 @@ yama/tools/bash/bash.py,sha256=4GlFvmqTUS4k6DgJ5Io91YF5fB6wF6e3e7p2P-pmbEQ,10358
|
|
|
22
23
|
yama/tools/bash/fs.py,sha256=GChDwGe_Sgn73btZJDNp5nOwlVDhLfZyaMVqWSQwfOw,21859
|
|
23
24
|
yama/tools/skill/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
25
|
yama/tools/skill/skill.py,sha256=H2KdIBLkYhecYX7M2xbn79csDpDvougpRcAmlrwigEM,2235
|
|
25
|
-
python_yama-0.
|
|
26
|
-
python_yama-0.
|
|
27
|
-
python_yama-0.
|
|
28
|
-
python_yama-0.
|
|
29
|
-
python_yama-0.
|
|
26
|
+
python_yama-0.7.0.dist-info/METADATA,sha256=abnFJBim_JNAHsPiflJ6wn-OT8lhwBALIM9NrnzMsmw,7539
|
|
27
|
+
python_yama-0.7.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
28
|
+
python_yama-0.7.0.dist-info/entry_points.txt,sha256=N5se3y1FflUcDU3TmUrH2Tu9dzsrBBo7sUP-Gu_2cVs,39
|
|
29
|
+
python_yama-0.7.0.dist-info/licenses/LICENSE,sha256=cMAJJAs7R1lemJPPc7qMNv4w_sqn5QncFf4aXKYyEc4,1067
|
|
30
|
+
python_yama-0.7.0.dist-info/RECORD,,
|
yama/assertions.py
CHANGED
|
@@ -16,6 +16,28 @@ class AssertionConfigurationError(ValueError):
|
|
|
16
16
|
pass
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
DEFAULT_HARD_ASSERTION_TAG = "must_pass"
|
|
20
|
+
HARD_ASSERTION_TAG_THRESHOLDS: dict[str, float] = {
|
|
21
|
+
"must_pass": 1.0,
|
|
22
|
+
"high_confidence": 0.9,
|
|
23
|
+
"tolerant": 0.8,
|
|
24
|
+
"informational": 0.0,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def normalize_hard_assertion_tag(tag: Any) -> str:
|
|
29
|
+
if tag is None:
|
|
30
|
+
return DEFAULT_HARD_ASSERTION_TAG
|
|
31
|
+
if not isinstance(tag, str):
|
|
32
|
+
raise AssertionConfigurationError("hard assertion 'tag' must be a string")
|
|
33
|
+
if tag not in HARD_ASSERTION_TAG_THRESHOLDS:
|
|
34
|
+
allowed = ", ".join(HARD_ASSERTION_TAG_THRESHOLDS)
|
|
35
|
+
raise AssertionConfigurationError(
|
|
36
|
+
f"unknown hard assertion tag {tag!r}; expected one of: {allowed}"
|
|
37
|
+
)
|
|
38
|
+
return tag
|
|
39
|
+
|
|
40
|
+
|
|
19
41
|
_MISSING = object()
|
|
20
42
|
|
|
21
43
|
|
|
@@ -165,11 +187,18 @@ async def run_hard_assertions(
|
|
|
165
187
|
) -> list[dict[str, Any]]:
|
|
166
188
|
checks: list[dict[str, Any]] = []
|
|
167
189
|
for assertion in assertions:
|
|
168
|
-
if not isinstance(assertion, dict)
|
|
190
|
+
if not isinstance(assertion, dict):
|
|
169
191
|
raise AssertionConfigurationError(
|
|
170
192
|
"each hard assertion must contain exactly one type"
|
|
171
193
|
)
|
|
172
|
-
|
|
194
|
+
tag = normalize_hard_assertion_tag(assertion.get("tag"))
|
|
195
|
+
type_items = {key: value for key, value in assertion.items() if key != "tag"}
|
|
196
|
+
if len(type_items) != 1:
|
|
197
|
+
raise AssertionConfigurationError(
|
|
198
|
+
"each hard assertion must contain exactly one type, plus an "
|
|
199
|
+
"optional string 'tag'"
|
|
200
|
+
)
|
|
201
|
+
kind, config = next(iter(type_items.items()))
|
|
173
202
|
diagnostic = await _run_one(
|
|
174
203
|
kind,
|
|
175
204
|
config,
|
|
@@ -179,7 +208,7 @@ async def run_hard_assertions(
|
|
|
179
208
|
plugin_root=plugin_root,
|
|
180
209
|
relative_root=relative_root,
|
|
181
210
|
)
|
|
182
|
-
checks.append({"type": kind, **diagnostic})
|
|
211
|
+
checks.append({"type": kind, "tag": tag, **diagnostic})
|
|
183
212
|
return checks
|
|
184
213
|
|
|
185
214
|
|
yama/cli.py
CHANGED
|
@@ -31,16 +31,64 @@ from .loaders import CollectionError, resolve_case
|
|
|
31
31
|
from .preview import preview_payload, write_preview_html
|
|
32
32
|
from .report import write_html_report, write_timestamped_report
|
|
33
33
|
from .runner import YamaRunner, combine_usage
|
|
34
|
+
from .thread_case import (
|
|
35
|
+
ThreadCaseError,
|
|
36
|
+
build_case_dict,
|
|
37
|
+
build_response_preview,
|
|
38
|
+
dump_case_yaml,
|
|
39
|
+
fetch_dsl_at_commit,
|
|
40
|
+
fetch_model_records,
|
|
41
|
+
parse_record_id,
|
|
42
|
+
resolve_dsl_remote_base_dir,
|
|
43
|
+
resolve_dsl_ssh_host,
|
|
44
|
+
select_record,
|
|
45
|
+
)
|
|
34
46
|
|
|
35
47
|
DEFAULT_REPORT = Path("__yama_default_report__")
|
|
36
48
|
|
|
37
49
|
|
|
38
|
-
def
|
|
39
|
-
if
|
|
50
|
+
def _result_status(value: Any) -> str:
|
|
51
|
+
if isinstance(value, bool):
|
|
52
|
+
return "pass" if value else "fail"
|
|
53
|
+
if isinstance(value, str) and value in {"pass", "fail", "error"}:
|
|
54
|
+
return value
|
|
55
|
+
if hasattr(value, "status"):
|
|
56
|
+
return _result_status(getattr(value, "status"))
|
|
57
|
+
if hasattr(value, "passed"):
|
|
58
|
+
return _result_status(bool(getattr(value, "passed")))
|
|
59
|
+
return "fail"
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _status(value: Any, *, compact: bool = False) -> Text:
|
|
63
|
+
status = _result_status(value)
|
|
64
|
+
if status == "pass":
|
|
40
65
|
return Text("✓" if compact else "PASS", style="bold green")
|
|
66
|
+
if status == "error":
|
|
67
|
+
return Text("!" if compact else "ERROR", style="bold yellow")
|
|
41
68
|
return Text("✗" if compact else "FAIL", style="bold red")
|
|
42
69
|
|
|
43
70
|
|
|
71
|
+
def _evaluated_runs(result: Any) -> list[Any]:
|
|
72
|
+
return [run for run in result.runs if _result_status(run) != "error"]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _error_kind(value: Any) -> str | None:
|
|
76
|
+
kind = getattr(value, "error_kind", None)
|
|
77
|
+
return kind if kind in {"llm", "framework"} else None
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _error_kind_label(kind: str | None) -> str:
|
|
81
|
+
if kind == "llm":
|
|
82
|
+
return "LLM error"
|
|
83
|
+
if kind == "framework":
|
|
84
|
+
return "Framework error"
|
|
85
|
+
return "Error"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _plural(count: int, singular: str) -> str:
|
|
89
|
+
return f"{count} {singular}{'' if count == 1 else 's'}"
|
|
90
|
+
|
|
91
|
+
|
|
44
92
|
def _usage_label(usage: dict[str, int] | None, *, split: bool = False) -> str:
|
|
45
93
|
"""`tokens 12,345`-style suffix for labels and captions; empty when no
|
|
46
94
|
LLM call reported usage (scripted replays, runs that died early)."""
|
|
@@ -55,6 +103,13 @@ def _usage_label(usage: dict[str, int] | None, *, split: bool = False) -> str:
|
|
|
55
103
|
return label
|
|
56
104
|
|
|
57
105
|
|
|
106
|
+
def _judge_required_label(judge: dict[str, Any]) -> str:
|
|
107
|
+
required = judge.get("overall_required")
|
|
108
|
+
if isinstance(required, (int, float)):
|
|
109
|
+
return f" (required >= {required:.0%})"
|
|
110
|
+
return ""
|
|
111
|
+
|
|
112
|
+
|
|
58
113
|
def _summary_case_key(case_key: str) -> str:
|
|
59
114
|
prefix = "__evals__/cases/"
|
|
60
115
|
return case_key.removeprefix(prefix)
|
|
@@ -90,6 +145,7 @@ def build_step_tree(step: Any) -> Tree:
|
|
|
90
145
|
)
|
|
91
146
|
if isinstance(judge.get("overall"), (int, float)):
|
|
92
147
|
step_label.append(f" {judge['overall']:.0%}", style="dim")
|
|
148
|
+
step_label.append(_judge_required_label(judge), style="dim")
|
|
93
149
|
step_node = Tree(step_label, guide_style="dim")
|
|
94
150
|
if judge is not None and not judge_passed:
|
|
95
151
|
judge_node = step_node.add(Text("Judge dimensions", style="bold red"))
|
|
@@ -140,7 +196,7 @@ def build_case_tree(result: Any) -> Tree:
|
|
|
140
196
|
"""Whole-case verdict tree (runs -> steps), shared by the aggregated
|
|
141
197
|
details of `format_text_results` and the parallel progress output."""
|
|
142
198
|
case_label = Text.assemble(
|
|
143
|
-
_status(result
|
|
199
|
+
_status(result, compact=True),
|
|
144
200
|
" ",
|
|
145
201
|
(result.case_key, "bold"),
|
|
146
202
|
(f" {result.pass_rate:.0%}", "dim"),
|
|
@@ -153,7 +209,7 @@ def build_case_tree(result: Any) -> Tree:
|
|
|
153
209
|
tree = Tree(case_label, guide_style="dim")
|
|
154
210
|
for run in result.runs:
|
|
155
211
|
run_label = Text.assemble(
|
|
156
|
-
_status(run
|
|
212
|
+
_status(run, compact=True),
|
|
157
213
|
" ",
|
|
158
214
|
(f"Run {run.run_index}", "bold"),
|
|
159
215
|
)
|
|
@@ -164,7 +220,12 @@ def build_case_tree(result: Any) -> Tree:
|
|
|
164
220
|
run_label.append(f" {_usage_label(run_usage)}", style="dim")
|
|
165
221
|
run_node = tree.add(run_label)
|
|
166
222
|
if run.error:
|
|
167
|
-
run_node.add(
|
|
223
|
+
run_node.add(
|
|
224
|
+
Text.assemble(
|
|
225
|
+
(f"{_error_kind_label(_error_kind(run))}: ", "bold yellow"),
|
|
226
|
+
(run.error, "yellow"),
|
|
227
|
+
)
|
|
228
|
+
)
|
|
168
229
|
run_node.children.extend(build_step_tree(step) for step in run.steps)
|
|
169
230
|
return tree
|
|
170
231
|
|
|
@@ -184,32 +245,65 @@ def build_summary_table(results: list[Any]) -> Table:
|
|
|
184
245
|
table.add_column("Tokens", justify="right", no_wrap=True)
|
|
185
246
|
|
|
186
247
|
passed_runs = 0
|
|
187
|
-
|
|
248
|
+
evaluated_run_count = 0
|
|
249
|
+
error_runs = 0
|
|
250
|
+
llm_errors = 0
|
|
251
|
+
framework_errors = 0
|
|
188
252
|
for result in results:
|
|
189
|
-
|
|
253
|
+
evaluated_runs = _evaluated_runs(result)
|
|
254
|
+
case_passed_runs = sum(run.passed for run in evaluated_runs)
|
|
255
|
+
case_error_runs = len(result.runs) - len(evaluated_runs)
|
|
190
256
|
passed_runs += case_passed_runs
|
|
191
|
-
|
|
257
|
+
evaluated_run_count += len(evaluated_runs)
|
|
258
|
+
error_runs += case_error_runs
|
|
259
|
+
llm_errors += sum(1 for run in result.runs if _error_kind(run) == "llm")
|
|
260
|
+
framework_errors += sum(
|
|
261
|
+
1 for run in result.runs if _error_kind(run) == "framework"
|
|
262
|
+
)
|
|
192
263
|
case_cell = Text(_summary_case_key(result.case_key))
|
|
193
264
|
if result.description:
|
|
194
265
|
case_cell.append(f"\n{result.description}", style="dim")
|
|
195
266
|
usage = result.usage()
|
|
267
|
+
run_count = f"{case_passed_runs}/{len(evaluated_runs)}"
|
|
268
|
+
if case_error_runs:
|
|
269
|
+
run_count += f" (+{case_error_runs} error)"
|
|
196
270
|
table.add_row(
|
|
197
|
-
_status(result
|
|
271
|
+
_status(result),
|
|
198
272
|
case_cell,
|
|
199
|
-
|
|
273
|
+
run_count,
|
|
200
274
|
f"{result.pass_rate:.0%}",
|
|
201
275
|
f"{usage['total_tokens']:,}" if usage else "–",
|
|
202
276
|
)
|
|
203
277
|
|
|
204
|
-
|
|
278
|
+
error_cases = sum(1 for result in results if _result_status(result) == "error")
|
|
279
|
+
evaluated_cases = len(results) - error_cases
|
|
280
|
+
passed_cases = sum(
|
|
281
|
+
result.passed for result in results if _result_status(result) != "error"
|
|
282
|
+
)
|
|
205
283
|
table.caption = (
|
|
206
|
-
f"{passed_cases}/{
|
|
207
|
-
f"{passed_runs}/{
|
|
284
|
+
f"{passed_cases}/{evaluated_cases} cases passed • "
|
|
285
|
+
f"{passed_runs}/{evaluated_run_count} runs passed"
|
|
208
286
|
)
|
|
287
|
+
if error_cases:
|
|
288
|
+
table.caption += f" • {error_cases} case error"
|
|
289
|
+
if error_cases != 1:
|
|
290
|
+
table.caption += "s"
|
|
291
|
+
if error_runs:
|
|
292
|
+
table.caption += f" • {_plural(error_runs, 'run error')}"
|
|
293
|
+
if llm_errors:
|
|
294
|
+
table.caption += f" • {_plural(llm_errors, 'llm error')}"
|
|
295
|
+
if framework_errors:
|
|
296
|
+
table.caption += f" • {_plural(framework_errors, 'framework error')}"
|
|
209
297
|
total_usage = combine_usage(result.usage() for result in results)
|
|
210
298
|
if total_usage:
|
|
211
299
|
table.caption += f" • {_usage_label(total_usage, split=True)}"
|
|
212
|
-
|
|
300
|
+
failed_cases = evaluated_cases - passed_cases
|
|
301
|
+
if failed_cases:
|
|
302
|
+
table.caption_style = "red"
|
|
303
|
+
elif error_cases:
|
|
304
|
+
table.caption_style = "yellow"
|
|
305
|
+
else:
|
|
306
|
+
table.caption_style = "green"
|
|
213
307
|
return table
|
|
214
308
|
|
|
215
309
|
|
|
@@ -291,17 +385,21 @@ class ProgressPrinter:
|
|
|
291
385
|
)
|
|
292
386
|
elif event == "case_end":
|
|
293
387
|
result = payload["result"]
|
|
294
|
-
|
|
388
|
+
evaluated_runs = _evaluated_runs(result)
|
|
389
|
+
passed_runs = sum(run.passed for run in evaluated_runs)
|
|
390
|
+
error_runs = len(result.runs) - len(evaluated_runs)
|
|
295
391
|
meta = (
|
|
296
|
-
f" {passed_runs}/{len(
|
|
392
|
+
f" {passed_runs}/{len(evaluated_runs)} runs passed"
|
|
297
393
|
f" {result.pass_rate:.0%}"
|
|
298
394
|
)
|
|
395
|
+
if error_runs:
|
|
396
|
+
meta += f" {error_runs} error"
|
|
299
397
|
usage = result.usage()
|
|
300
398
|
if usage:
|
|
301
399
|
meta += f" {_usage_label(usage)}"
|
|
302
400
|
self.console.print(
|
|
303
401
|
Text.assemble(
|
|
304
|
-
_status(result
|
|
402
|
+
_status(result, compact=True),
|
|
305
403
|
" ",
|
|
306
404
|
(result.case_key, "bold"),
|
|
307
405
|
(meta, "dim"),
|
|
@@ -398,16 +496,20 @@ class ParallelProgressPrinter:
|
|
|
398
496
|
)
|
|
399
497
|
else:
|
|
400
498
|
result = row["result"]
|
|
401
|
-
|
|
499
|
+
evaluated_runs = _evaluated_runs(result)
|
|
500
|
+
passed_runs = sum(run.passed for run in evaluated_runs)
|
|
501
|
+
error_runs = len(result.runs) - len(evaluated_runs)
|
|
402
502
|
meta = (
|
|
403
|
-
f" {passed_runs}/{len(
|
|
503
|
+
f" {passed_runs}/{len(evaluated_runs)} runs"
|
|
404
504
|
f" {result.pass_rate:.0%}"
|
|
405
505
|
)
|
|
506
|
+
if error_runs:
|
|
507
|
+
meta += f" {error_runs} error"
|
|
406
508
|
usage = result.usage()
|
|
407
509
|
if usage:
|
|
408
510
|
meta += f" {_usage_label(usage)}"
|
|
409
511
|
grid.add_row(
|
|
410
|
-
_status(result
|
|
512
|
+
_status(result, compact=True),
|
|
411
513
|
Text.assemble((case_key, "bold"), (meta, "dim")),
|
|
412
514
|
)
|
|
413
515
|
return grid
|
|
@@ -715,7 +817,11 @@ async def _run(args: argparse.Namespace) -> int:
|
|
|
715
817
|
(str(report_path), f"cyan link {report_path.as_uri()}"),
|
|
716
818
|
)
|
|
717
819
|
)
|
|
718
|
-
|
|
820
|
+
if any(_result_status(result) == "fail" for result in all_results):
|
|
821
|
+
return 1
|
|
822
|
+
if any(_result_status(result) == "error" for result in all_results):
|
|
823
|
+
return 2
|
|
824
|
+
return 0
|
|
719
825
|
|
|
720
826
|
|
|
721
827
|
def _dashboard_parser() -> argparse.ArgumentParser:
|
|
@@ -794,6 +900,105 @@ def _run_dashboard(args: argparse.Namespace) -> int:
|
|
|
794
900
|
return 0
|
|
795
901
|
|
|
796
902
|
|
|
903
|
+
_THREAD_TYPES = (
|
|
904
|
+
"one_shot",
|
|
905
|
+
"interactive",
|
|
906
|
+
"streaming",
|
|
907
|
+
"adventurer",
|
|
908
|
+
"gamer",
|
|
909
|
+
"atelier",
|
|
910
|
+
)
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
def _thread_case_parser() -> argparse.ArgumentParser:
|
|
914
|
+
parser = argparse.ArgumentParser(
|
|
915
|
+
prog="yama from-thread",
|
|
916
|
+
description=(
|
|
917
|
+
"Fetch one model-call record for a thread message and print a"
|
|
918
|
+
" single Case YAML skeleton to stdout, auto-populating one step when"
|
|
919
|
+
" DSL and request history make that possible."
|
|
920
|
+
),
|
|
921
|
+
)
|
|
922
|
+
parser.add_argument(
|
|
923
|
+
"--record-id",
|
|
924
|
+
required=True,
|
|
925
|
+
help=(
|
|
926
|
+
"Composite record ID, comma-separated with thread_id first and"
|
|
927
|
+
" message_id second (e.g. '<thread_id>, <message_id>, ,"
|
|
928
|
+
" <completion_id>'); only the first two parts are used"
|
|
929
|
+
),
|
|
930
|
+
)
|
|
931
|
+
parser.add_argument("--token", required=True, help="Bearer token")
|
|
932
|
+
parser.add_argument(
|
|
933
|
+
"--env",
|
|
934
|
+
default="dev",
|
|
935
|
+
help=(
|
|
936
|
+
"Target environment: dev, staging, or prod (default: dev)."
|
|
937
|
+
" Selects the admin API base URL and, when --commit-id is set,"
|
|
938
|
+
" the DSL SSH host and remote base dir"
|
|
939
|
+
),
|
|
940
|
+
)
|
|
941
|
+
parser.add_argument(
|
|
942
|
+
"--thread-type",
|
|
943
|
+
choices=_THREAD_TYPES,
|
|
944
|
+
default=None,
|
|
945
|
+
help=(
|
|
946
|
+
"Thread type query param (default: let the server fall back to"
|
|
947
|
+
" the Thread's own stored type)"
|
|
948
|
+
),
|
|
949
|
+
)
|
|
950
|
+
parser.add_argument(
|
|
951
|
+
"--record-index",
|
|
952
|
+
type=int,
|
|
953
|
+
default=-1,
|
|
954
|
+
metavar="N",
|
|
955
|
+
help="Which record to use from the message's records array (default: -1, the last one)",
|
|
956
|
+
)
|
|
957
|
+
parser.add_argument(
|
|
958
|
+
"--commit-id",
|
|
959
|
+
default=None,
|
|
960
|
+
help=(
|
|
961
|
+
"Git commit to read dsl.json from via SSH (git show <commit>:dsl.json);"
|
|
962
|
+
" omit to skip fetching dsl entirely"
|
|
963
|
+
),
|
|
964
|
+
)
|
|
965
|
+
return parser
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
def _run_thread_case(args: argparse.Namespace) -> int:
|
|
969
|
+
thread_id, message_id = parse_record_id(args.record_id)
|
|
970
|
+
payload = fetch_model_records(
|
|
971
|
+
thread_id, message_id, args.token, args.thread_type, env=args.env
|
|
972
|
+
)
|
|
973
|
+
record = select_record(payload.get("records", []), args.record_index)
|
|
974
|
+
stderr = Console(stderr=True)
|
|
975
|
+
stderr.print(
|
|
976
|
+
Text(
|
|
977
|
+
f"record: provider_file={record.get('provider_file')}"
|
|
978
|
+
f" line_no={record.get('line_no')} record_id={record.get('record_id')}"
|
|
979
|
+
f" model={record.get('model')} datetime={record.get('datetime')}",
|
|
980
|
+
style="dim",
|
|
981
|
+
)
|
|
982
|
+
)
|
|
983
|
+
stderr.print(
|
|
984
|
+
Text(f"response: {build_response_preview(record.get('response'))}", style="dim")
|
|
985
|
+
)
|
|
986
|
+
dsl: dict[str, Any] | None = None
|
|
987
|
+
if args.commit_id is not None:
|
|
988
|
+
ssh_host = resolve_dsl_ssh_host(args.env)
|
|
989
|
+
remote_base_dir = resolve_dsl_remote_base_dir(args.env)
|
|
990
|
+
dsl = fetch_dsl_at_commit(thread_id, args.commit_id, ssh_host, remote_base_dir)
|
|
991
|
+
stderr.print(
|
|
992
|
+
Text(
|
|
993
|
+
f"dsl: fetched {len(dsl)} top-level key(s) at commit {args.commit_id}",
|
|
994
|
+
style="dim",
|
|
995
|
+
)
|
|
996
|
+
)
|
|
997
|
+
case = build_case_dict(record, dsl=dsl, record_id=args.record_id)
|
|
998
|
+
print(dump_case_yaml(case), end="")
|
|
999
|
+
return 0
|
|
1000
|
+
|
|
1001
|
+
|
|
797
1002
|
def main(argv: list[str] | None = None) -> int:
|
|
798
1003
|
# .env is resolved from the working directory upward (like yama.toml);
|
|
799
1004
|
# variables already present in the real environment take precedence.
|
|
@@ -803,6 +1008,8 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
803
1008
|
try:
|
|
804
1009
|
if argv[:1] == ["dashboard"]:
|
|
805
1010
|
return _run_dashboard(_dashboard_parser().parse_args(argv[1:]))
|
|
1011
|
+
if argv[:1] == ["from-thread"]:
|
|
1012
|
+
return _run_thread_case(_thread_case_parser().parse_args(argv[1:]))
|
|
806
1013
|
args = _parser().parse_args(argv)
|
|
807
1014
|
return asyncio.run(_run(args))
|
|
808
1015
|
except (ConfigurationError, CollectionError, ValueError) as exc:
|
|
@@ -818,5 +1025,13 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
818
1025
|
Text.assemble(("LLM error: ", "bold red"), (str(exc), "red"))
|
|
819
1026
|
)
|
|
820
1027
|
return 2
|
|
1028
|
+
except ThreadCaseError as exc:
|
|
1029
|
+
# Fetching/selecting the thread record failed -- separate label from
|
|
1030
|
+
# "Collection error"/"LLM error" since neither Case collection nor an
|
|
1031
|
+
# LLM call was involved.
|
|
1032
|
+
Console(stderr=True).print(
|
|
1033
|
+
Text.assemble(("Thread case error: ", "bold red"), (str(exc), "red"))
|
|
1034
|
+
)
|
|
1035
|
+
return 2
|
|
821
1036
|
except KeyboardInterrupt:
|
|
822
1037
|
return 130
|
yama/models.py
CHANGED
|
@@ -111,6 +111,7 @@ class StepResult:
|
|
|
111
111
|
messages: list[Json]
|
|
112
112
|
hard_checks: list[Json] = field(default_factory=list)
|
|
113
113
|
hard_pass: bool = True
|
|
114
|
+
tag_summary: dict[str, Json] = field(default_factory=dict)
|
|
114
115
|
judge_result: Json | None = None
|
|
115
116
|
|
|
116
117
|
def to_dict(self) -> Json:
|
|
@@ -122,6 +123,7 @@ class StepResult:
|
|
|
122
123
|
"messages": self.messages,
|
|
123
124
|
"hard_checks": self.hard_checks,
|
|
124
125
|
"hard_pass": self.hard_pass,
|
|
126
|
+
"tag_summary": self.tag_summary,
|
|
125
127
|
"judge_result": self.judge_result,
|
|
126
128
|
}
|
|
127
129
|
|