Spaces:
Runtime error
Runtime error
v2
Browse filesSigned-off-by: Dipankar Das <dipankardas0115@gmail.com>
app.py
CHANGED
|
@@ -1,9 +1,14 @@
|
|
| 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 pipeline
|
| 8 |
# This function will be able to generate text
|
| 9 |
# given an input.
|
|
@@ -14,9 +19,9 @@ model="google/flan-t5-small")
|
|
| 14 |
# The generate() function is defined as a FastAPI route that takes a
|
| 15 |
# string parameter called text. The function generates text based on the # input using the pipeline() object, and returns a JSON response
|
| 16 |
# containing the generated text under the key "output"
|
| 17 |
-
@app.get("/")
|
| 18 |
-
async def root():
|
| 19 |
-
|
| 20 |
|
| 21 |
@app.get("/generate")
|
| 22 |
def generate(text: str):
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
+
from fastapi.responses import RedirectResponse
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
# Create a new FastAPI app instance
|
| 6 |
+
|
| 7 |
app = FastAPI()
|
| 8 |
+
|
| 9 |
+
@app.get("/")
|
| 10 |
+
async def docs_redirect():
|
| 11 |
+
return RedirectResponse(url='/docs')
|
| 12 |
# Initialize the text generation pipeline
|
| 13 |
# This function will be able to generate text
|
| 14 |
# given an input.
|
|
|
|
| 19 |
# The generate() function is defined as a FastAPI route that takes a
|
| 20 |
# string parameter called text. The function generates text based on the # input using the pipeline() object, and returns a JSON response
|
| 21 |
# containing the generated text under the key "output"
|
| 22 |
+
# @app.get("/")
|
| 23 |
+
# async def root():
|
| 24 |
+
# return {"message": "Hello World"}
|
| 25 |
|
| 26 |
@app.get("/generate")
|
| 27 |
def generate(text: str):
|