kghamilton89 commited on
Commit
96f2039
·
1 Parent(s): 641ecfc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -2,18 +2,18 @@ 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.
10
- pipe = pipeline("text2text-generation",
11
- model="google/flan-t5-small")
12
 
13
  # Define a function to handle the GET request at `/generate`
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("/generate")
18
  def generate(text: str):
19
  """
 
2
  from transformers import pipeline
3
 
4
  # Create a new FastAPI app instance
5
+ app = FastAPI(docs_url="/")
6
 
7
  # Initialize the text generation pipeline
8
  # This function will be able to generate text
9
  # given an input.
10
+ pipe = pipeline("text2text-generation", model="google/flan-t5-small")
 
11
 
12
  # Define a function to handle the GET request at `/generate`
13
  # The generate() function is defined as a FastAPI route that takes a
14
  # string parameter called text. The function generates text based on the # input using the pipeline() object, and returns a JSON response
15
  # containing the generated text under the key "output"
16
+
17
  @app.get("/generate")
18
  def generate(text: str):
19
  """