Upload 5 files
Browse files- README.md +43 -3
- package-lock.json +63 -0
- package.json +6 -0
- questbench.jsonl +0 -0
- vision_server.py +122 -0
README.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# QuestBench
|
| 2 |
+
|
| 3 |
+
**QuestBench** is a course-curated benchmark of **256 expert-level questions**
|
| 4 |
+
for evaluating the deep-search capabilities of language models. Questions are
|
| 5 |
+
long-tail queries spanning **14 normalized domains** in the humanities and
|
| 6 |
+
social sciences (Literature, Law, History, Foreign Languages, Social
|
| 7 |
+
Sciences, Arts, Archaeology, Journalism, …). Each question, reference answer,
|
| 8 |
+
and grading rubric is in Chinese; the model under evaluation may search and
|
| 9 |
+
read in any language.
|
| 10 |
+
|
| 11 |
+
## Files
|
| 12 |
+
|
| 13 |
+
- `questbench.jsonl` — 256 questions, one JSON record per line.
|
| 14 |
+
- `.claude.json` — [Claude Code](https://www.anthropic.com/claude-code) MCP server config.
|
| 15 |
+
- `vision_server.py` — local MCP server proxying image analysis to OpenRouter.
|
| 16 |
+
- `package.json`, `package-lock.json` — npm dependencies.
|
| 17 |
+
|
| 18 |
+
Each JSONL record has four fields: `domain`, `question`, `answer`,
|
| 19 |
+
`grading_criteria` (the rubric an LLM judge uses to assign a 0–100 score).
|
| 20 |
+
|
| 21 |
+
## Run
|
| 22 |
+
|
| 23 |
+
Setup:
|
| 24 |
+
|
| 25 |
+
```bash
|
| 26 |
+
brew install --cask claude # Claude Code CLI
|
| 27 |
+
brew install jq node uv
|
| 28 |
+
npm install
|
| 29 |
+
export ANTHROPIC_API_KEY=... # Claude
|
| 30 |
+
export SERPER_API_KEY=... # https://serper.dev
|
| 31 |
+
export OPENROUTER_API_KEY=... # https://openrouter.ai (vision)
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
Run a single question:
|
| 35 |
+
|
| 36 |
+
```bash
|
| 37 |
+
QUESTION=$(jq -r '.question' questbench.jsonl | head -n 1) && \
|
| 38 |
+
claude -p "$QUESTION" \
|
| 39 |
+
--mcp-config ./.claude.json --strict-mcp-config \
|
| 40 |
+
--permission-mode bypassPermissions \
|
| 41 |
+
--disallowedTools WebSearch WebFetch \
|
| 42 |
+
--output-format stream-json --verbose
|
| 43 |
+
```
|
package-lock.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "dr-bench",
|
| 3 |
+
"lockfileVersion": 3,
|
| 4 |
+
"requires": true,
|
| 5 |
+
"packages": {
|
| 6 |
+
"": {
|
| 7 |
+
"dependencies": {
|
| 8 |
+
"claude": "^0.1.1",
|
| 9 |
+
"playwright": "^1.59.1"
|
| 10 |
+
}
|
| 11 |
+
},
|
| 12 |
+
"node_modules/claude": {
|
| 13 |
+
"version": "0.1.1",
|
| 14 |
+
"resolved": "https://registry.npmjs.org/claude/-/claude-0.1.1.tgz",
|
| 15 |
+
"integrity": "sha512-j7oSibqQdIODNhkI1sEJzHMiPsF43L/GqNbcA+eDDyGM10+x2sH9NW/PK6vM3z0J2tLDKMBcc5ZjVaoRinhuCA==",
|
| 16 |
+
"license": "ISC"
|
| 17 |
+
},
|
| 18 |
+
"node_modules/fsevents": {
|
| 19 |
+
"version": "2.3.2",
|
| 20 |
+
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
| 21 |
+
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
| 22 |
+
"hasInstallScript": true,
|
| 23 |
+
"license": "MIT",
|
| 24 |
+
"optional": true,
|
| 25 |
+
"os": [
|
| 26 |
+
"darwin"
|
| 27 |
+
],
|
| 28 |
+
"engines": {
|
| 29 |
+
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
| 30 |
+
}
|
| 31 |
+
},
|
| 32 |
+
"node_modules/playwright": {
|
| 33 |
+
"version": "1.59.1",
|
| 34 |
+
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.59.1.tgz",
|
| 35 |
+
"integrity": "sha512-C8oWjPR3F81yljW9o5OxcWzfh6avkVwDD2VYdwIGqTkl+OGFISgypqzfu7dOe4QNLL2aqcWBmI3PMtLIK233lw==",
|
| 36 |
+
"license": "Apache-2.0",
|
| 37 |
+
"dependencies": {
|
| 38 |
+
"playwright-core": "1.59.1"
|
| 39 |
+
},
|
| 40 |
+
"bin": {
|
| 41 |
+
"playwright": "cli.js"
|
| 42 |
+
},
|
| 43 |
+
"engines": {
|
| 44 |
+
"node": ">=18"
|
| 45 |
+
},
|
| 46 |
+
"optionalDependencies": {
|
| 47 |
+
"fsevents": "2.3.2"
|
| 48 |
+
}
|
| 49 |
+
},
|
| 50 |
+
"node_modules/playwright-core": {
|
| 51 |
+
"version": "1.59.1",
|
| 52 |
+
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.59.1.tgz",
|
| 53 |
+
"integrity": "sha512-HBV/RJg81z5BiiZ9yPzIiClYV/QMsDCKUyogwH9p3MCP6IYjUFu/MActgYAvK0oWyV9NlwM3GLBjADyWgydVyg==",
|
| 54 |
+
"license": "Apache-2.0",
|
| 55 |
+
"bin": {
|
| 56 |
+
"playwright-core": "cli.js"
|
| 57 |
+
},
|
| 58 |
+
"engines": {
|
| 59 |
+
"node": ">=18"
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
}
|
package.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"dependencies": {
|
| 3 |
+
"claude": "^0.1.1",
|
| 4 |
+
"playwright": "^1.59.1"
|
| 5 |
+
}
|
| 6 |
+
}
|
questbench.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vision_server.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# /// script
|
| 2 |
+
# requires-python = ">=3.10"
|
| 3 |
+
# dependencies = ["mcp>=1.0", "openai>=1.0", "requests>=2.31"]
|
| 4 |
+
# ///
|
| 5 |
+
import os
|
| 6 |
+
import base64
|
| 7 |
+
import tempfile
|
| 8 |
+
import requests
|
| 9 |
+
from urllib.parse import urlparse
|
| 10 |
+
from mcp.server.fastmcp import FastMCP
|
| 11 |
+
from openai import OpenAI
|
| 12 |
+
|
| 13 |
+
mcp = FastMCP("Robust-Vision-Server")
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def is_valid_url(url: str) -> bool:
|
| 17 |
+
"""Return True iff the input is a syntactically valid http/https URL."""
|
| 18 |
+
try:
|
| 19 |
+
result = urlparse(url)
|
| 20 |
+
return all([result.scheme in ['http', 'https'], result.netloc])
|
| 21 |
+
except ValueError:
|
| 22 |
+
return False
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def get_base64_from_local_file(file_path: str) -> str:
|
| 26 |
+
"""Read a local image file and encode it as a base64 data URI."""
|
| 27 |
+
if not os.path.exists(file_path):
|
| 28 |
+
raise FileNotFoundError(f"local file not found: {file_path}")
|
| 29 |
+
|
| 30 |
+
with open(file_path, "rb") as f:
|
| 31 |
+
encoded = base64.b64encode(f.read()).decode('utf-8')
|
| 32 |
+
|
| 33 |
+
# OpenRouter accepts a generic image/jpeg URI; the API infers the real format.
|
| 34 |
+
return f"data:image/jpeg;base64,{encoded}"
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
@mcp.tool()
|
| 38 |
+
def analyze_image_with_openrouter(
|
| 39 |
+
image_source: str,
|
| 40 |
+
prompt: str = "Describe the image in detail and extract any salient text or information.",
|
| 41 |
+
model_name: str = "bytedance-seed/seed-2.0-lite",
|
| 42 |
+
) -> str:
|
| 43 |
+
"""
|
| 44 |
+
Analyze an image with an OpenRouter vision model. Accepts both local file
|
| 45 |
+
paths and remote http/https URLs. Remote images are downloaded to a
|
| 46 |
+
temporary directory before being sent to the API.
|
| 47 |
+
|
| 48 |
+
Args:
|
| 49 |
+
image_source: absolute local path or http/https URL.
|
| 50 |
+
prompt: instruction passed to the vision model.
|
| 51 |
+
model_name: OpenRouter model id.
|
| 52 |
+
"""
|
| 53 |
+
api_key = os.getenv("OPENROUTER_API_KEY")
|
| 54 |
+
if not api_key:
|
| 55 |
+
return "Error: OPENROUTER_API_KEY is not set."
|
| 56 |
+
|
| 57 |
+
client = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=api_key)
|
| 58 |
+
|
| 59 |
+
# Branch A: remote URL — download to a temp dir, then call the API.
|
| 60 |
+
if is_valid_url(image_source):
|
| 61 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
| 62 |
+
temp_file_path = os.path.join(temp_dir, "downloaded_image.tmp")
|
| 63 |
+
|
| 64 |
+
try:
|
| 65 |
+
headers = {
|
| 66 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
|
| 67 |
+
"Accept": "image/webp,image/apng,image/*,*/*;q=0.8",
|
| 68 |
+
}
|
| 69 |
+
response = requests.get(image_source, headers=headers, stream=True, timeout=15)
|
| 70 |
+
response.raise_for_status()
|
| 71 |
+
|
| 72 |
+
content_type = response.headers.get('Content-Type', '')
|
| 73 |
+
if not content_type.startswith('image/'):
|
| 74 |
+
return f"Download failed: target URL did not return an image (Content-Type: {content_type})."
|
| 75 |
+
|
| 76 |
+
with open(temp_file_path, 'wb') as f:
|
| 77 |
+
for chunk in response.iter_content(chunk_size=8192):
|
| 78 |
+
f.write(chunk)
|
| 79 |
+
|
| 80 |
+
image_data_uri = get_base64_from_local_file(temp_file_path)
|
| 81 |
+
|
| 82 |
+
except requests.exceptions.Timeout:
|
| 83 |
+
return "Download failed: request timed out (>15s)."
|
| 84 |
+
except requests.exceptions.HTTPError as err:
|
| 85 |
+
return f"Download failed: HTTP error {err.response.status_code}."
|
| 86 |
+
except requests.exceptions.RequestException as err:
|
| 87 |
+
return f"Download failed: network error: {err}"
|
| 88 |
+
except Exception as err:
|
| 89 |
+
return f"Temp-file processing failed: {err}"
|
| 90 |
+
|
| 91 |
+
# Call inside the `with` block so the temp file outlives the request.
|
| 92 |
+
return _call_openrouter_api(client, model_name, prompt, image_data_uri)
|
| 93 |
+
|
| 94 |
+
# Branch B: local file path.
|
| 95 |
+
try:
|
| 96 |
+
image_data_uri = get_base64_from_local_file(image_source)
|
| 97 |
+
return _call_openrouter_api(client, model_name, prompt, image_data_uri)
|
| 98 |
+
except Exception as err:
|
| 99 |
+
return f"Local file processing failed: {err}"
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def _call_openrouter_api(client: OpenAI, model: str, prompt: str, image_data_uri: str) -> str:
|
| 103 |
+
try:
|
| 104 |
+
response = client.chat.completions.create(
|
| 105 |
+
model=model,
|
| 106 |
+
messages=[
|
| 107 |
+
{
|
| 108 |
+
"role": "user",
|
| 109 |
+
"content": [
|
| 110 |
+
{"type": "text", "text": prompt},
|
| 111 |
+
{"type": "image_url", "image_url": {"url": image_data_uri}},
|
| 112 |
+
],
|
| 113 |
+
}
|
| 114 |
+
],
|
| 115 |
+
)
|
| 116 |
+
return response.choices[0].message.content
|
| 117 |
+
except Exception as err:
|
| 118 |
+
return f"OpenRouter API call failed: {err}"
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
if __name__ == "__main__":
|
| 122 |
+
mcp.run()
|