Spaces:
Runtime error
Runtime error
Delete app.py
Browse files
app.py
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
from fastapi import FastAPI
|
2 |
-
from transformers import pipeline
|
3 |
-
|
4 |
-
|
5 |
-
#create a new fastapi app instance
|
6 |
-
app = FastAPI()
|
7 |
-
|
8 |
-
#initialize text generation pipeline
|
9 |
-
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
|
10 |
-
|
11 |
-
@app.get("/")
|
12 |
-
def home():
|
13 |
-
return {"Message": "Hello World"}
|
14 |
-
|
15 |
-
#def a function that handle a get request to the /generate endpoint
|
16 |
-
@app.get("/generate")
|
17 |
-
def generate(text: str):
|
18 |
-
#use the pipeline to generate the text from given input text
|
19 |
-
output = pipe(text)
|
20 |
-
#return the generated text in json response
|
21 |
-
return {"generated_text": output[0]["generated_text"]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|