Spaces:
Build error
Build error
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
app=FastAPI()
|
| 5 |
+
|
| 6 |
+
pipe=pipeline("text2text-generation", model="google/flan-t5-small")
|
| 7 |
+
|
| 8 |
+
@app.get("/")
|
| 9 |
+
def home():
|
| 10 |
+
return {"message":"Hello World"}
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
@app.get("/generate")
|
| 14 |
+
def generate(text:str):
|
| 15 |
+
output=pipe(text)
|
| 16 |
+
|
| 17 |
+
return {"output":output[0]['generated_text']}
|