File size: 831 Bytes
c8dfbc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from fastapi import FastAPI
from pydantic import BaseModel

from ragbench_eval.pipeline import RagBenchExperiment

app = FastAPI(title="RAGBench RAG Evaluation API")


class RunRequest(BaseModel):
    domain: str
    k: int = 3
    max_examples: int = 20
    split: str = "test"


@app.post("/run_domain")
def run_domain(req: RunRequest):
    exp = RagBenchExperiment(
        k=req.k,
        max_examples=req.max_examples,
        split=req.split,
    )
    result = exp.run_domain(req.domain)
    return result


@app.get("/health")
def health():
    return {"status": "ok"}


@app.get("/")
def root():
    return {
        "message": "RAGBench RAG Evaluation API is running.",
        "endpoints": {
            "health": "/health",
            "docs": "/docs",
            "run_domain": "/run_domain (POST)",
        },
    }