Spaces:
No application file
No application file
File size: 1,382 Bytes
52ec3b0 | 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 43 44 45 46 47 48 49 50 51 52 53 54 55 | """
FastAPI / WebSocket entrypoint for the Legal Contract Review environment.
Run: ``uvicorn app:app --host 0.0.0.0 --port 8000`` from this package root
(``PYTHONPATH`` / working directory must include the env root).
"""
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 / "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()
|