7a0da7932b
Backwards Compatibility / Verify Encryption Constants (push) Waiting to run
Backwards Compatibility / PyPI Version Compatibility (push) Waiting to run
Backwards Compatibility / Database Migration Tests (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Blocked by required conditions
Docker Tests (Consolidated) / detect-changes (push) Waiting to run
Docker Tests (Consolidated) / Build Test Image (push) Waiting to run
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Blocked by required conditions
Docker Tests (Consolidated) / Accessibility Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Unit Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Example Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / Production Image Smoke Test (push) Blocked by required conditions
Docker Tests (Consolidated) / Infrastructure Tests (push) Blocked by required conditions
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Waiting to run
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
215 lines
5.9 KiB
Python
215 lines
5.9 KiB
Python
#!/usr/bin/env python
|
|
"""
|
|
Gemini Benchmark Runner for Local Deep Research.
|
|
|
|
This script provides a convenient way to run benchmarks with Gemini via OpenRouter.
|
|
|
|
Usage:
|
|
# Install dependencies with PDM
|
|
cd /path/to/local-deep-research
|
|
pdm install
|
|
|
|
# Run the script with PDM and your OpenRouter API key
|
|
pdm run python examples/benchmarks/run_gemini_benchmark.py --api-key YOUR_API_KEY
|
|
"""
|
|
|
|
import argparse
|
|
import os
|
|
import time
|
|
from datetime import datetime
|
|
from pathlib import Path
|
|
|
|
# Import the benchmark functionality
|
|
from local_deep_research.benchmarks.benchmark_functions import (
|
|
evaluate_browsecomp,
|
|
evaluate_simpleqa,
|
|
)
|
|
|
|
|
|
def setup_gemini_config(api_key):
|
|
"""
|
|
Create a configuration for using Gemini via OpenRouter.
|
|
|
|
Args:
|
|
api_key: OpenRouter API key
|
|
|
|
Returns:
|
|
Dictionary with configuration settings
|
|
"""
|
|
return {
|
|
"model_name": "google/gemini-2.0-flash-001",
|
|
"provider": "openai_endpoint",
|
|
"openai_endpoint_url": "https://openrouter.ai/api/v1",
|
|
"api_key": api_key,
|
|
}
|
|
|
|
|
|
def run_benchmark(args):
|
|
"""
|
|
Run benchmarks with Gemini via OpenRouter.
|
|
|
|
Args:
|
|
args: Command line arguments
|
|
"""
|
|
# Set up configuration
|
|
config = setup_gemini_config(args.api_key)
|
|
|
|
# Set environment variables
|
|
if args.api_key:
|
|
os.environ["OPENAI_ENDPOINT_API_KEY"] = args.api_key
|
|
os.environ["LDR_LLM__OPENAI_ENDPOINT_API_KEY"] = args.api_key
|
|
os.environ["OPENAI_ENDPOINT_URL"] = config["openai_endpoint_url"]
|
|
os.environ["LDR_LLM__OPENAI_ENDPOINT_URL"] = config["openai_endpoint_url"]
|
|
|
|
# Create timestamp for output directory
|
|
from datetime import timezone
|
|
|
|
timestamp = datetime.now(timezone.utc).strftime("%Y%m%d_%H%M%S")
|
|
base_output_dir = str(
|
|
Path("examples") / "benchmarks" / "results" / f"gemini_{timestamp}"
|
|
)
|
|
Path(base_output_dir).mkdir(parents=True, exist_ok=True)
|
|
|
|
# Configure benchmark settings
|
|
results = {}
|
|
benchmarks = []
|
|
|
|
if args.simpleqa:
|
|
benchmarks.append(
|
|
{
|
|
"name": "SimpleQA",
|
|
"function": evaluate_simpleqa,
|
|
"output_dir": str(Path(base_output_dir) / "simpleqa"),
|
|
}
|
|
)
|
|
|
|
if args.browsecomp:
|
|
benchmarks.append(
|
|
{
|
|
"name": "BrowseComp",
|
|
"function": evaluate_browsecomp,
|
|
"output_dir": str(Path(base_output_dir) / "browsecomp"),
|
|
}
|
|
)
|
|
|
|
# Run selected benchmarks
|
|
for benchmark in benchmarks:
|
|
print(
|
|
f"\n=== Running {benchmark['name']} benchmark with {args.examples} examples ==="
|
|
)
|
|
start_time = time.time()
|
|
|
|
benchmark_result = benchmark["function"](
|
|
num_examples=args.examples,
|
|
search_iterations=args.iterations,
|
|
questions_per_iteration=args.questions,
|
|
search_tool=args.search_tool,
|
|
search_model=config["model_name"],
|
|
search_provider=config["provider"],
|
|
endpoint_url=config["openai_endpoint_url"],
|
|
search_strategy=args.search_strategy,
|
|
evaluation_model=config["model_name"],
|
|
evaluation_provider=config["provider"],
|
|
output_dir=benchmark["output_dir"],
|
|
)
|
|
|
|
duration = time.time() - start_time
|
|
print(
|
|
f"{benchmark['name']} evaluation complete in {duration:.1f} seconds"
|
|
)
|
|
|
|
if (
|
|
isinstance(benchmark_result, dict)
|
|
and "accuracy" in benchmark_result
|
|
):
|
|
print(
|
|
f"{benchmark['name']} accuracy: {benchmark_result['accuracy']:.4f}"
|
|
)
|
|
else:
|
|
print(f"{benchmark['name']} accuracy: N/A")
|
|
|
|
results[benchmark["name"].lower()] = benchmark_result
|
|
|
|
# Print summary
|
|
print("\n=== Benchmark Summary ===")
|
|
print(f"Model: {config['model_name']}")
|
|
print(f"Provider: {config['provider']}")
|
|
print(f"Examples: {args.examples}")
|
|
print(f"Results saved to: {base_output_dir}")
|
|
|
|
return results
|
|
|
|
|
|
def main():
|
|
"""Parse arguments and run the benchmark."""
|
|
parser = argparse.ArgumentParser(
|
|
description="Run benchmarks with Gemini via OpenRouter"
|
|
)
|
|
|
|
# API key is required
|
|
parser.add_argument(
|
|
"--api-key",
|
|
type=str,
|
|
required=True,
|
|
help="OpenRouter API key (required)",
|
|
)
|
|
|
|
# Benchmark selection (at least one required)
|
|
benchmark_group = parser.add_argument_group("benchmark selection")
|
|
benchmark_group.add_argument(
|
|
"--simpleqa", action="store_true", help="Run SimpleQA benchmark"
|
|
)
|
|
benchmark_group.add_argument(
|
|
"--browsecomp", action="store_true", help="Run BrowseComp benchmark"
|
|
)
|
|
|
|
# Benchmark parameters
|
|
parser.add_argument(
|
|
"--examples",
|
|
type=int,
|
|
default=3,
|
|
help="Number of examples to run (default: 3)",
|
|
)
|
|
parser.add_argument(
|
|
"--iterations",
|
|
type=int,
|
|
default=2,
|
|
help="Number of search iterations (default: 2)",
|
|
)
|
|
parser.add_argument(
|
|
"--questions",
|
|
type=int,
|
|
default=3,
|
|
help="Questions per iteration (default: 3)",
|
|
)
|
|
parser.add_argument(
|
|
"--search-tool",
|
|
type=str,
|
|
default="searxng",
|
|
help="Search tool to use (default: searxng)",
|
|
)
|
|
parser.add_argument(
|
|
"--search-strategy",
|
|
type=str,
|
|
default="source_based",
|
|
choices=["source_based", "standard", "rapid", "parallel", "iterdrag"],
|
|
help="Search strategy to use (default: source_based)",
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
# Ensure at least one benchmark is selected
|
|
if not (args.simpleqa or args.browsecomp):
|
|
parser.error(
|
|
"At least one benchmark must be selected (--simpleqa or --browsecomp)"
|
|
)
|
|
|
|
print(
|
|
f"Starting benchmarks with Gemini 2.0 Flash on {args.examples} examples"
|
|
)
|
|
run_benchmark(args)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|