Spaces:
Runtime error
Runtime error
rohitjakkam
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
from fastapi import FastAPI
|
2 |
-
from transformers import
|
3 |
-
|
4 |
-
# create a new FASTAPI app instance
|
5 |
-
app = Fastapi()
|
6 |
-
|
7 |
-
# Initialize the text generation pipleline
|
8 |
-
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
|
9 |
-
|
10 |
-
@app.get("/")
|
11 |
-
def home():
|
12 |
-
return {"message": "Welcome to the Text Generation API"}
|
13 |
-
|
14 |
-
@app.get("/generate")
|
15 |
-
def generate(text:str):
|
16 |
-
# use pipelibe to generate text from given text as input param
|
17 |
-
output = pipe(text)
|
18 |
-
|
19 |
-
# return the generated text in Json response
|
20 |
return {"output":output[0]['generated_text']}
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# create a new FASTAPI app instance
|
5 |
+
app = Fastapi()
|
6 |
+
|
7 |
+
# Initialize the text generation pipleline
|
8 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
|
9 |
+
|
10 |
+
@app.get("/")
|
11 |
+
def home():
|
12 |
+
return {"message": "Welcome to the Text Generation API"}
|
13 |
+
|
14 |
+
@app.get("/generate")
|
15 |
+
def generate(text:str):
|
16 |
+
# use pipelibe to generate text from given text as input param
|
17 |
+
output = pipe(text)
|
18 |
+
|
19 |
+
# return the generated text in Json response
|
20 |
return {"output":output[0]['generated_text']}
|