Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,24 +0,0 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
-
from pydantic import BaseModel
|
| 3 |
-
from transformers import pipeline
|
| 4 |
-
|
| 5 |
-
# Création de l'app FastAPI
|
| 6 |
-
app = FastAPI()
|
| 7 |
-
|
| 8 |
-
# Chargement du modèle Hugging Face (T5 pour text2text)
|
| 9 |
-
model = pipeline("text2text-generation", model="t5-small")
|
| 10 |
-
|
| 11 |
-
# Définition du format d'entrée
|
| 12 |
-
class Prompt(BaseModel):
|
| 13 |
-
prompt: str
|
| 14 |
-
|
| 15 |
-
# Endpoint d'API
|
| 16 |
-
@app.post("/generate")
|
| 17 |
-
def generate_text(prompt: Prompt):
|
| 18 |
-
try:
|
| 19 |
-
output = model(prompt.prompt, max_length=100)
|
| 20 |
-
return {"result": output[0]["generated_text"]}
|
| 21 |
-
except Exception as e:
|
| 22 |
-
return {"error": str(e)}
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|