MCPcopy Create free account
hub / github.com/SpaceZephyr/myskill / evaluate_single_task

Function evaluate_single_task

mcp-builder/scripts/evaluation.py:154–184  ·  view source on GitHub ↗

Evaluate a single QA pair with the given tools.

(
    client: Anthropic,
    model: str,
    qa_pair: dict[str, Any],
    tools: list[dict[str, Any]],
    connection: Any,
    task_index: int,
)

Source from the content-addressed store, hash-verified

152
153
154async def evaluate_single_task(
155 client: Anthropic,
156 model: str,
157 qa_pair: dict[str, Any],
158 tools: list[dict[str, Any]],
159 connection: Any,
160 task_index: int,
161) -> dict[str, Any]:
162 """Evaluate a single QA pair with the given tools."""
163 start_time = time.time()
164
165 print(f"Task {task_index + 1}: Running task with question: {qa_pair['question']}")
166 response, tool_metrics = await agent_loop(client, model, qa_pair["question"], tools, connection)
167
168 response_value = extract_xml_content(response, "response")
169 summary = extract_xml_content(response, "summary")
170 feedback = extract_xml_content(response, "feedback")
171
172 duration_seconds = time.time() - start_time
173
174 return {
175 "question": qa_pair["question"],
176 "expected": qa_pair["answer"],
177 "actual": response_value,
178 "score": int(response_value == qa_pair["answer"]) if response_value else 0,
179 "total_duration": duration_seconds,
180 "tool_calls": tool_metrics,
181 "num_tool_calls": sum(len(metrics["durations"]) for metrics in tool_metrics.values()),
182 "summary": summary,
183 "feedback": feedback,
184 }
185
186
187REPORT_HEADER = """

Callers 1

run_evaluationFunction · 0.85

Calls 3

agent_loopFunction · 0.85
extract_xml_contentFunction · 0.85
valuesMethod · 0.80

Tested by

no test coverage detected