| import sys |
| import os |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
|
|
| from fastapi import HTTPException |
| from pydantic import BaseModel |
| from openenv.core.env_server.http_server import create_app |
| from models import RevOpsAction, RevOpsObservation |
| from server.environment import RevOpsEnvironment |
| import subprocess |
|
|
| app = create_app( |
| RevOpsEnvironment, |
| RevOpsAction, |
| RevOpsObservation, |
| env_name="RevOps-Agent", |
| max_concurrent_envs=1 |
| ) |
|
|
| @app.post("/baseline") |
| @app.get("/baseline") |
| def run_baseline(): |
| try: |
| result = subprocess.run(["python", "baseline.py"], capture_output=True, text=True) |
| return {"output": result.stdout, "error": result.stderr} |
| except Exception as e: |
| raise HTTPException(status_code=500, detail=str(e)) |
|
|
| @app.get("/grader") |
| def get_grader(): |
| import server.environment as env_module |
| return {"grader_score": getattr(env_module, "global_last_grader_score", None)} |
|
|
| @app.get("/tasks") |
| def get_tasks_endpoint(): |
| schema = RevOpsAction.model_json_schema() |
| return { |
| "tasks": ["task_easy", "task_medium", "task_hard"], |
| "action_schema": schema |
| } |
|
|
| def main(host: str = "0.0.0.0", port: int = 8000): |
| import uvicorn |
| uvicorn.run("server.app:app", host=host, port=port) |
|
|
| if __name__ == '__main__': |
| main() |
|
|