Spaces:
Runtime error
Runtime error
File size: 1,266 Bytes
cb054fe | 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 | """
FastAPI application for the Overflow Environment.
Exposes the OverflowEnvironment over HTTP and WebSocket endpoints.
Usage:
uvicorn server.app:app --reload --host 0.0.0.0 --port 8000
"""
import inspect
from openenv.core.env_server.http_server import create_app
from ..models import OverflowAction, OverflowObservation
from .overflow_environment import OverflowEnvironment
def _create_overflow_app():
"""Build app across create_app variants that may expect a factory or an instance."""
try:
first_param = next(iter(inspect.signature(create_app).parameters.values()))
annotation_text = str(first_param.annotation)
except (StopIteration, TypeError, ValueError):
annotation_text = "typing.Callable"
expects_instance = (
"Environment" in annotation_text and "Callable" not in annotation_text
)
env_arg = OverflowEnvironment() if expects_instance else OverflowEnvironment
return create_app(
env_arg, OverflowAction, OverflowObservation, env_name="overflow_env"
)
app = _create_overflow_app()
def main():
"""Entry point for direct execution via uv run or python -m."""
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
if __name__ == "__main__":
main()
|