File size: 703 Bytes
fef8a16
c3e46dc
 
fef8a16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

# Line for test push

from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from starlette.responses import FileResponse
from transformers import pipeline

app = FastAPI()

# Initialiser le pipeline pour Flan T5
pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")

# Route d'inférence
@app.get("/infer_t5")
async def infer_t5(input: str):
    output = pipe_flan(input)
    return {"output": output[0]["generated_text"]}

# Monter les fichiers statiques
app.mount("/", StaticFiles(directory="front/dist", html=True), name="static")

@app.get("/")
async def index() -> FileResponse:
    return FileResponse(path="front/dist/index.html", media_type="text/html")