MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / _call_judge

Function _call_judge

src/benchmarks/writing_bench/evaluate.py:55–90  ·  view source on GitHub ↗

Score a single (response, criteria) pair via the judge model. Matches the official WritingBench evaluation protocol: - Criteria passed as raw dict (str() representation via .format()) - temperature=1.0, max_tokens=2048 - Up to 5 retries per criterion

(
    client: LLMClient,
    query: str,
    response: str,
    criteria: dict,
    model: str,
    max_retries: int = 5,
)

Source from the content-addressed store, hash-verified

53
54
55def _call_judge(
56 client: LLMClient,
57 query: str,
58 response: str,
59 criteria: dict,
60 model: str,
61 max_retries: int = 5,
62) -> Optional[dict]:
63 """Score a single (response, criteria) pair via the judge model.
64
65 Matches the official WritingBench evaluation protocol:
66 - Criteria passed as raw dict (str() representation via .format())
67 - temperature=1.0, max_tokens=2048
68 - Up to 5 retries per criterion
69 """
70 prompt = EVALUATE_PROMPT.format(query=query, response=response, criteria=criteria)
71
72 for _ in range(max_retries):
73 try:
74 completion = client.completion(
75 model=model,
76 messages=[
77 {"role": "system", "content": EVALUATE_SYSTEM},
78 {"role": "user", "content": prompt},
79 ],
80 temperature=1.0,
81 max_tokens=2048,
82 )
83 text = completion.choices[0].message.content or ""
84 result = _parse_score_json(text)
85 if result is not None:
86 return result
87 except Exception as e:
88 print(f" Judge API error: {e}")
89
90 return None
91
92
93def load_benchmark_queries(jsonl_path: Path) -> Dict[int, dict]:

Callers 1

_evaluate_singleFunction · 0.85

Calls 2

_parse_score_jsonFunction · 0.85
completionMethod · 0.80

Tested by

no test coverage detected