Spaces:
Running
Running
Commit ·
00d49da
1
Parent(s): be350cb
adding claude code + mcp
Browse files- agent/config_claude_mcp.json +11 -0
- eval/run_eval_with_leaderboard.py +1 -1
- eval/solvers.py +47 -0
agent/config_claude_mcp.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mcpServers": {
|
| 3 |
+
"huggingface": {
|
| 4 |
+
"type": "http",
|
| 5 |
+
"url": "https://huggingface.co/mcp",
|
| 6 |
+
"headers": {
|
| 7 |
+
"Authorization": "Bearer ${HF_TOKEN}"
|
| 8 |
+
}
|
| 9 |
+
}
|
| 10 |
+
}
|
| 11 |
+
}
|
eval/run_eval_with_leaderboard.py
CHANGED
|
@@ -112,7 +112,7 @@ def main() -> None:
|
|
| 112 |
)
|
| 113 |
parser.add_argument(
|
| 114 |
"--hf-dataset",
|
| 115 |
-
|
| 116 |
help="HF dataset repo id for the leaderboard (e.g. user/leaderboard).",
|
| 117 |
)
|
| 118 |
|
|
|
|
| 112 |
)
|
| 113 |
parser.add_argument(
|
| 114 |
"--hf-dataset",
|
| 115 |
+
default="akseljoonas/hf-agent-leaderboard",
|
| 116 |
help="HF dataset repo id for the leaderboard (e.g. user/leaderboard).",
|
| 117 |
)
|
| 118 |
|
eval/solvers.py
CHANGED
|
@@ -6,6 +6,8 @@ from __future__ import annotations
|
|
| 6 |
|
| 7 |
import asyncio
|
| 8 |
import json
|
|
|
|
|
|
|
| 9 |
from typing import Callable, Dict, List, Sequence
|
| 10 |
|
| 11 |
from inspect_ai.model import ChatMessageAssistant, ModelOutput
|
|
@@ -100,9 +102,54 @@ def claude_code(
|
|
| 100 |
return solve
|
| 101 |
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
SOLVER_REGISTRY: Dict[str, Callable[..., Solver]] = {
|
| 104 |
"hf_agent_solver": hf_agent_solver,
|
| 105 |
"claude_code": claude_code,
|
|
|
|
| 106 |
}
|
| 107 |
|
| 108 |
|
|
|
|
| 6 |
|
| 7 |
import asyncio
|
| 8 |
import json
|
| 9 |
+
import os
|
| 10 |
+
import tempfile
|
| 11 |
from typing import Callable, Dict, List, Sequence
|
| 12 |
|
| 13 |
from inspect_ai.model import ChatMessageAssistant, ModelOutput
|
|
|
|
| 102 |
return solve
|
| 103 |
|
| 104 |
|
| 105 |
+
@solver(name="claude_code+hf_mcp")
|
| 106 |
+
def claude_code_hf_mcp(
|
| 107 |
+
output_format: str = "json",
|
| 108 |
+
hf_token: str | None = None,
|
| 109 |
+
) -> Solver:
|
| 110 |
+
"""
|
| 111 |
+
A solver that uses Claude Code with the Hugging Face MCP server.
|
| 112 |
+
Requires HF_TOKEN in environment variables or passed as argument.
|
| 113 |
+
"""
|
| 114 |
+
token = hf_token or os.environ.get("HF_TOKEN")
|
| 115 |
+
if not token:
|
| 116 |
+
raise ValueError(
|
| 117 |
+
"HF_TOKEN not found. Please set HF_TOKEN env var or pass it to the solver."
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
# Construct the MCP configuration for Hugging Face
|
| 121 |
+
mcp_config = {
|
| 122 |
+
"mcpServers": {
|
| 123 |
+
"huggingface": {
|
| 124 |
+
"type": "http",
|
| 125 |
+
"url": "https://huggingface.co/mcp",
|
| 126 |
+
"headers": {"Authorization": f"Bearer {token}"},
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
async def solve(state: TaskState, generate) -> TaskState:
|
| 132 |
+
# Write config to a temporary file
|
| 133 |
+
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as tmp:
|
| 134 |
+
json.dump(mcp_config, tmp, indent=2)
|
| 135 |
+
tmp_path = tmp.name
|
| 136 |
+
|
| 137 |
+
try:
|
| 138 |
+
# Delegate to the base claude_code solver
|
| 139 |
+
delegate = claude_code(output_format=output_format, mcp_config=tmp_path)
|
| 140 |
+
return await delegate(state, generate)
|
| 141 |
+
finally:
|
| 142 |
+
# Clean up the temporary file
|
| 143 |
+
if os.path.exists(tmp_path):
|
| 144 |
+
os.remove(tmp_path)
|
| 145 |
+
|
| 146 |
+
return solve
|
| 147 |
+
|
| 148 |
+
|
| 149 |
SOLVER_REGISTRY: Dict[str, Callable[..., Solver]] = {
|
| 150 |
"hf_agent_solver": hf_agent_solver,
|
| 151 |
"claude_code": claude_code,
|
| 152 |
+
"claude_code+hf_mcp": claude_code_hf_mcp,
|
| 153 |
}
|
| 154 |
|
| 155 |
|