Spaces:
Sleeping
Sleeping
from fastapi import FastAPI | |
from pydantic import BaseModel | |
from model.model import LLM | |
import torch | |
app = FastAPI(docs_url="/swagger-ui.html") | |
class InputText(BaseModel): | |
text: str | |
# "bigscience/bloomz-1b1" | |
model_tag = "facebook/opt-125m" | |
model = LLM(model_name = model_tag, | |
device = "cuda" if torch.cuda.is_available() else "cpu") | |
""" | |
@app.get("/") | |
async def root(): | |
return {"message": "Technical challenge OK"} | |
""" | |
async def docs_redirect(): | |
response = RedirectResponse(url='/swagger-ui.html') | |
return response | |
def language_detection(text): | |
return {"language": model.language_detection(text)} | |
def ner(text): | |
return model.entity_recognition(text) |