File size: 600 Bytes
b295d62 a54cb5b b295d62 4164b83 83ec4f2 b295d62 a88e9cf a54cb5b a88e9cf b295d62 8f6137e a54cb5b b295d62 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from functools import lru_cache
from models import CheckResponse
from completions import check_text, load_model
app = FastAPI()
model, tokenizer, device = load_model()
@lru_cache(maxsize=100)
def cached_check_text(text: str):
return check_text(text, model, tokenizer, device)
@app.get("/check", response_model=CheckResponse)
def check(text: str):
print(f"Checking text: {text}")
return CheckResponse(text=text, words=cached_check_text(text))
app.mount("/", StaticFiles(directory="frontend/public", html=True))
|