"""Entry point into the server.""" import logging import os import sys from pathlib import Path from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from langserve import add_routes from api import examples, extractor """ from server.extraction_runnable import ( ExtractRequest, ExtractResponse, extraction_runnable, ) """ logger = logging.getLogger(__name__) app = FastAPI( title="Cygnus Server", version="0.0.1", description="extraction service for drilling related reports", openapi_tags=[ { "name": "cygnus", "description": "Operations related to extracting information from drilling related reports.", } ], ) ROOT = Path(__file__).parent.parent ORIGINS = os.environ.get("CORS_ORIGINS", "").split(",") if ORIGINS: app.add_middleware( CORSMiddleware, allow_origins=ORIGINS, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) @app.get("/ready") def ready() -> str: return "ok" # Include API endpoints for extractor definitions app.include_router(examples.router) app.include_router(extractor.router) """ add_routes( app, extraction_runnable.with_types( input_type=ExtractRequest, output_type=ExtractResponse ), path="/extract_text", enabled_endpoints=["invoke", "batch"], ) """ if __name__ == "__main__": import uvicorn uvicorn.run(app, host="localhost", port=8000)