Spaces:
Runtime error
Runtime error
Delete app.py
Browse files
app.py
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
from fastapi import FastAPI
|
2 |
-
from transformers import pipeline
|
3 |
-
|
4 |
-
|
5 |
-
#create a new FASTAPI App instances
|
6 |
-
app=FastAPI()
|
7 |
-
|
8 |
-
|
9 |
-
##create a new pipeline instances
|
10 |
-
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
|
11 |
-
|
12 |
-
@app.get("/")
|
13 |
-
def home():
|
14 |
-
return{"message":"Hello World !"}
|
15 |
-
|
16 |
-
|
17 |
-
#Define a function o handle the GET request at '/generate'
|
18 |
-
|
19 |
-
|
20 |
-
@app.get("/generate")
|
21 |
-
def generate(text:str):
|
22 |
-
###use the pipeline to generate text from given input text
|
23 |
-
|
24 |
-
output=pipe(text)
|
25 |
-
|
26 |
-
|
27 |
-
##return the generate text in Json response
|
28 |
-
|
29 |
-
return{"output":output[0][' ']}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|