Download backend/api.py from ZAIDX11/Axiovora-X: direct link, hf CLI and curl.
- Browser
- Download file 1.9 kB
-
https://huggingface.co/ZAIDX11/Axiovora-X/resolve/main/backend/api.py
- Command line
-
hf download hf://ZAIDX11/Axiovora-X/backend/api.py
-
curl -L -o api.py https://huggingface.co/ZAIDX11/Axiovora-X/resolve/main/backend/api.py
1.9 kB
| from pydantic import BaseModel | |
| from .universe import UniverseManager | |
| class AxiomsRequest(BaseModel): | |
| axioms: list[str] | |
| class ProveRequest(BaseModel): | |
| theorem: str | |
| universe_id: str | |
| class PipelineRequest(BaseModel): | |
| axioms: list[str] | |
| theorem: str | |
| def create_app(): | |
| """Create and return the FastAPI app. This is lazy to avoid import-time | |
| collisions with a repo-local `fastapi/` directory when running tests in | |
| this workspace. | |
| """ | |
| from fastapi import FastAPI, HTTPException | |
| from .auth import require_token | |
| from .pipeline import Pipeline | |
| app = FastAPI(title="AlphaGeometry Demo API") | |
| manager = UniverseManager() | |
| pipeline = Pipeline(manager) | |
| def generate_universe(req: AxiomsRequest): | |
| uid = manager.create_universe(req.axioms) | |
| return {"universe_id": uid} | |
| def prove(req: ProveRequest): | |
| try: | |
| result = manager.prove(req.universe_id, req.theorem) | |
| except KeyError: | |
| raise HTTPException(status_code=404, detail="Universe not found") | |
| return {"result": result} | |
| def pipeline_generate_and_prove(req: PipelineRequest, x_api_key: str | None = None): | |
| # basic auth header check | |
| require_token(x_api_key) | |
| res = pipeline.run_generate_and_prove(req.axioms, req.theorem) | |
| return res | |
| def compare(a: str, b: str): | |
| try: | |
| score = manager.compare_universes(a, b) | |
| except KeyError: | |
| raise HTTPException(status_code=404, detail="Universe not found") | |
| return {"similarity": score} | |
| def health(): | |
| return {"status": "ok"} | |
| return app | |
| __all__ = ["create_app"] | |