Spaces:
No application file
No application file
Download server/app.py from Pankaj10346/meta-openenv-hackaghon: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/spaces/Pankaj10346/meta-openenv-hackaghon/resolve/main/server/app.py
- Command line
-
hf download hf://spaces/Pankaj10346/meta-openenv-hackaghon/server/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Pankaj10346/meta-openenv-hackaghon/resolve/main/server/app.py
1.23 kB
| """ | |
| FastAPI / WebSocket entrypoint for the Legal Contract Review environment. | |
| """ | |
| from __future__ import annotations | |
| import os | |
| from pathlib import Path | |
| from fastapi.staticfiles import StaticFiles | |
| from openenv.core.env_server import create_app | |
| try: | |
| from legal_contract_env.models import ContractAction, ContractObservation | |
| from legal_contract_env.server.legal_contract_environment import LegalContractEnvironment | |
| except ImportError: | |
| from models import ContractAction, ContractObservation | |
| from server.legal_contract_environment import LegalContractEnvironment | |
| def create_legal_contract_environment() -> LegalContractEnvironment: | |
| return LegalContractEnvironment() | |
| app = create_app( | |
| create_legal_contract_environment, | |
| ContractAction, | |
| ContractObservation, | |
| env_name="legal_contract_env", | |
| ) | |
| _web_dir = Path(__file__).resolve().parent.parent / "web" | |
| if _web_dir.is_dir(): | |
| app.mount( | |
| "/ui", | |
| StaticFiles(directory=str(_web_dir), html=True), | |
| name="legal_ui", | |
| ) | |
| def main() -> None: | |
| import uvicorn | |
| port = int(os.environ.get("API_PORT", os.environ.get("PORT", "8000"))) | |
| uvicorn.run(app, host="0.0.0.0", port=port) | |
| if __name__ == "__main__": | |
| main() | |