Spaces:
Sleeping
Sleeping
File size: 1,492 Bytes
f3aae92 | 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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | """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)
|