Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
from fastapi import FastAPI
|
2 |
-
from
|
3 |
-
|
4 |
-
|
5 |
-
#creating a FASTAPI app instance
|
6 |
-
app= FastAPI()
|
7 |
-
|
8 |
-
#
|
9 |
-
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
|
10 |
-
|
11 |
-
@app.get("/")
|
12 |
-
def home():
|
13 |
-
return{"message":"Hello there , How are you ?"}
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
@app.get("/generate")
|
18 |
-
def generate(text:str):
|
19 |
-
##use pipeline to generate text from given input text
|
20 |
-
output = pipe(text)
|
21 |
-
|
22 |
-
#return the generate text in Json
|
23 |
return{'output':output[0]['generated_text']}
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
|
5 |
+
#creating a FASTAPI app instance
|
6 |
+
app= FastAPI()
|
7 |
+
|
8 |
+
#
|
9 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
|
10 |
+
|
11 |
+
@app.get("/")
|
12 |
+
def home():
|
13 |
+
return{"message":"Hello there , How are you ?"}
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
@app.get("/generate")
|
18 |
+
def generate(text:str):
|
19 |
+
##use pipeline to generate text from given input text
|
20 |
+
output = pipe(text)
|
21 |
+
|
22 |
+
#return the generate text in Json
|
23 |
return{'output':output[0]['generated_text']}
|