File size: 1,333 Bytes
6851411 a750766 772dd21 6851411 772dd21 6851411 9c71bb7 6851411 772dd21 ee07ed2 a750766 ee07ed2 afd6869 9c71bb7 ee07ed2 6851411 772dd21 cc88da6 772dd21 cc88da6 9c71bb7 772dd21 a750766 6851411 |
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 |
from fastapi import FastAPI
from app.middleware import api_key_guard
from app.routers import openai_api
import logging
# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
app = FastAPI(title="LLM Pro Finance API (Transformers)")
# Mount routers
app.include_router(openai_api.router, prefix="/v1")
# Optional API key middleware
app.middleware("http")(api_key_guard)
@app.on_event("startup")
async def startup_event():
"""Startup event - initialize model in background"""
import threading
logger.info("Starting LLM Pro Finance API...")
logger.info("Initializing model in background thread...")
def load_model():
from app.providers.transformers_provider import initialize_model
initialize_model()
# Start model loading in background thread
thread = threading.Thread(target=load_model, daemon=True)
thread.start()
logger.info("Model initialization started in background")
@app.get("/")
async def root():
return {
"status": "ok",
"service": "Qwen Open Finance R 8B Inference",
"version": "1.0.0",
"model": "DragonLLM/qwen3-8b-fin-v1.0",
"backend": "Transformers"
}
@app.get("/health")
async def health():
return {"status": "healthy", "service": "LLM Pro Finance API"}
|