adyaprasad commited on
Commit
da7e57f
·
verified ·
1 Parent(s): 3056ba4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -23
app.py CHANGED
@@ -1,23 +1,23 @@
1
- from fastapi import FastAPI
2
- from transformers import pipeline
3
-
4
- #creating a new FastAPI app instance
5
- app=FastAPI()
6
-
7
- # calling Hugging Face Model from pipeline
8
- # here I am using, google/flan-t5-small (Text2Text Generating Model)
9
- pipe = pipeline("text2text-generation", model="google/flan-t5-small")
10
-
11
- #creating routes
12
- @app.get("/")
13
- def home():
14
- return {"Gearing Up! at Homepage"}
15
-
16
- #define a function to handle the GET request at '/generate'
17
-
18
- @app.get("/generate")
19
- def generate(text:str):
20
- # use the pipeline to generate text from given input text
21
- output = pipe(text)
22
- #returning generated text in json response
23
- return {"output":output[0]['generated_response']}
 
1
+ from fastapi import FastAPI
2
+ from transformers import pipeline
3
+
4
+ #creating a new FastAPI app instance
5
+ app=FastAPI()
6
+
7
+ # calling Hugging Face Model from pipeline
8
+ # here I am using, google/flan-t5-small (Text2Text Generating Model)
9
+ pipe = pipeline("text2text-generation", model="google/flan-t5-small")
10
+
11
+ #creating routes
12
+ @app.get("/")
13
+ def home():
14
+ return {"Gearing Up! at Homepage"}
15
+
16
+ #define a function to handle the GET request at '/generate'
17
+
18
+ @app.get("/generate")
19
+ def generate(text:str):
20
+ # use the pipeline to generate text from given input text
21
+ output = pipe(text)
22
+ #returning generated text in json response
23
+ return {"output": output[0]['generated_text']}