margin-referee 0.1.1__tar.gz → 0.1.2__tar.gz

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.
Files changed (19) hide show
  1. {margin_referee-0.1.1 → margin_referee-0.1.2}/PKG-INFO +4 -1
  2. {margin_referee-0.1.1 → margin_referee-0.1.2}/README.md +3 -0
  3. {margin_referee-0.1.1 → margin_referee-0.1.2}/margin_referee/__init__.py +1 -1
  4. {margin_referee-0.1.1 → margin_referee-0.1.2}/margin_referee/cases.py +19 -1
  5. {margin_referee-0.1.1 → margin_referee-0.1.2}/margin_referee.egg-info/PKG-INFO +4 -1
  6. {margin_referee-0.1.1 → margin_referee-0.1.2}/margin_referee.egg-info/SOURCES.txt +1 -0
  7. {margin_referee-0.1.1 → margin_referee-0.1.2}/pyproject.toml +1 -1
  8. margin_referee-0.1.2/tests/test_cases.py +16 -0
  9. {margin_referee-0.1.1 → margin_referee-0.1.2}/LICENSE +0 -0
  10. {margin_referee-0.1.1 → margin_referee-0.1.2}/margin_referee/cli.py +0 -0
  11. {margin_referee-0.1.1 → margin_referee-0.1.2}/margin_referee/endpoints.py +0 -0
  12. {margin_referee-0.1.1 → margin_referee-0.1.2}/margin_referee/replay.py +0 -0
  13. {margin_referee-0.1.1 → margin_referee-0.1.2}/margin_referee/stats.py +0 -0
  14. {margin_referee-0.1.1 → margin_referee-0.1.2}/margin_referee.egg-info/dependency_links.txt +0 -0
  15. {margin_referee-0.1.1 → margin_referee-0.1.2}/margin_referee.egg-info/entry_points.txt +0 -0
  16. {margin_referee-0.1.1 → margin_referee-0.1.2}/margin_referee.egg-info/requires.txt +0 -0
  17. {margin_referee-0.1.1 → margin_referee-0.1.2}/margin_referee.egg-info/top_level.txt +0 -0
  18. {margin_referee-0.1.1 → margin_referee-0.1.2}/setup.cfg +0 -0
  19. {margin_referee-0.1.1 → margin_referee-0.1.2}/tests/test_referee.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: margin-referee
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Should you switch models? Replay your own eval set on a candidate and get a verdict that holds up.
5
5
  License: MIT
6
6
  Keywords: llm,evals,model-selection,agents,promptfoo,langfuse,braintrust
@@ -20,6 +20,9 @@ LangSmith or Langfuse dataset export, or JSONL) on the model you run today and o
20
20
  grades both with each case's own check, and tells you whether the candidate holds up and costs
21
21
  less. No account, no backend, no telemetry.
22
22
 
23
+ Published on PyPI (https://pypi.org/project/margin-referee/) and GitHub
24
+ (https://github.com/trymargin/margin-referee).
25
+
23
26
  ```
24
27
  pip install margin-referee
25
28
  margin-referee fit cases.jsonl
@@ -7,6 +7,9 @@ LangSmith or Langfuse dataset export, or JSONL) on the model you run today and o
7
7
  grades both with each case's own check, and tells you whether the candidate holds up and costs
8
8
  less. No account, no backend, no telemetry.
9
9
 
10
+ Published on PyPI (https://pypi.org/project/margin-referee/) and GitHub
11
+ (https://github.com/trymargin/margin-referee).
12
+
10
13
  ```
11
14
  pip install margin-referee
12
15
  margin-referee fit cases.jsonl
@@ -1,2 +1,2 @@
1
1
  """margin-referee: should you switch models? Ask your own eval set."""
2
- __version__ = "0.1.1"
2
+ __version__ = "0.1.2"
@@ -138,7 +138,7 @@ def parse(text: str) -> Parsed:
138
138
  doc = None
139
139
  if isinstance(doc, dict) and "results" in doc:
140
140
  _promptfoo(doc, out)
141
- return out
141
+ return _unique_ids(out)
142
142
  rows: Iterable = doc if isinstance(doc, list) else (
143
143
  [doc] if isinstance(doc, dict) else _lines(text))
144
144
  for i, row in enumerate(rows):
@@ -146,6 +146,24 @@ def parse(text: str) -> Parsed:
146
146
  _row(i, row, out)
147
147
  else:
148
148
  out.ungraded.append((f"case-{i}", "not a JSON object"))
149
+ return _unique_ids(out)
150
+
151
+
152
+ def _unique_ids(out: Parsed) -> Parsed:
153
+ """Cases pair by id, so a repeated id (a promptfoo description used twice, say) would pair
154
+ one case's answers with another's. Repeats get ``#2``, ``#3``; the first keeps its name."""
155
+ from dataclasses import replace
156
+ taken, cases = {c.id for c in out.cases}, []
157
+ used: set[str] = set()
158
+ for c in out.cases:
159
+ name, n = c.id, 1
160
+ # a rename never takes a name already used, or one a later case carries as its own
161
+ while name in used or (name != c.id and name in taken):
162
+ n += 1
163
+ name = f"{c.id}#{n}"
164
+ used.add(name)
165
+ cases.append(c if name == c.id else replace(c, id=name))
166
+ out.cases = cases
149
167
  return out
150
168
 
151
169
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: margin-referee
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Should you switch models? Replay your own eval set on a candidate and get a verdict that holds up.
5
5
  License: MIT
6
6
  Keywords: llm,evals,model-selection,agents,promptfoo,langfuse,braintrust
@@ -20,6 +20,9 @@ LangSmith or Langfuse dataset export, or JSONL) on the model you run today and o
20
20
  grades both with each case's own check, and tells you whether the candidate holds up and costs
21
21
  less. No account, no backend, no telemetry.
22
22
 
23
+ Published on PyPI (https://pypi.org/project/margin-referee/) and GitHub
24
+ (https://github.com/trymargin/margin-referee).
25
+
23
26
  ```
24
27
  pip install margin-referee
25
28
  margin-referee fit cases.jsonl
@@ -13,4 +13,5 @@ margin_referee.egg-info/dependency_links.txt
13
13
  margin_referee.egg-info/entry_points.txt
14
14
  margin_referee.egg-info/requires.txt
15
15
  margin_referee.egg-info/top_level.txt
16
+ tests/test_cases.py
16
17
  tests/test_referee.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "margin-referee"
7
- version = "0.1.1"
7
+ version = "0.1.2"
8
8
  description = "Should you switch models? Replay your own eval set on a candidate and get a verdict that holds up."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -0,0 +1,16 @@
1
+
2
+
3
+ def test_a_repeated_case_id_is_made_unique():
4
+ import json
5
+ from margin_referee import cases
6
+ text = "\n".join(json.dumps({"id": i, "input": "q", "expected": "yes"}) for i in "aab")
7
+ assert [c.id for c in cases.parse(text).cases] == ["a", "a#2", "b"]
8
+
9
+
10
+ def test_a_renamed_id_never_collides_with_a_literal_one():
11
+ import json
12
+ from margin_referee import cases
13
+ text = "\n".join(json.dumps({"id": i, "input": "q", "expected": "yes"}) for i in
14
+ ["a", "a", "a#2"])
15
+ got = [c.id for c in cases.parse(text).cases]
16
+ assert len(set(got)) == 3 and got[2] == "a#2"
File without changes
File without changes