Mehedi2 commited on
Commit
44b9dd8
·
verified ·
1 Parent(s): a05ba9b

Create gaia_api.py

Browse files
Files changed (1) hide show
  1. gaia_api.py +40 -0
gaia_api.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from pydantic import BaseModel
3
+ from app import run_agent
4
+
5
+ app = FastAPI()
6
+
7
+ class GaiaRequest(BaseModel):
8
+ prompt: str
9
+
10
+ class GaiaResponse(BaseModel):
11
+ output: str
12
+
13
+ @app.post("/predict", response_model=GaiaResponse)
14
+ def predict(req: GaiaRequest):
15
+ """
16
+ GAIA evaluation endpoint
17
+ Takes a prompt and returns the agent's response
18
+ """
19
+ try:
20
+ result = run_agent(req.prompt)
21
+ return GaiaResponse(output=result)
22
+ except Exception as e:
23
+ return GaiaResponse(output=f"Error: {str(e)}")
24
+
25
+ @app.get("/health")
26
+ def health_check():
27
+ """Health check endpoint"""
28
+ return {"status": "healthy"}
29
+
30
+ @app.get("/")
31
+ def root():
32
+ """Root endpoint with basic info"""
33
+ return {
34
+ "name": "GAIA Test Agent",
35
+ "description": "AI Navigation and General Assistant Agent",
36
+ "endpoints": {
37
+ "predict": "/predict",
38
+ "health": "/health"
39
+ }
40
+ }