jaya-sandeep-22 commited on
Commit
1fa9a95
·
verified ·
1 Parent(s): 183af33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -23
app.py CHANGED
@@ -1,24 +1,24 @@
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
- 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
- ## Define a function to handle GET Request at '/generate'
15
-
16
- @app.get("/generate")
17
- def generate(text:str):
18
- ## use the pipeline to generate text based on the input 'text'
19
- output=pipe(text)
20
-
21
- ## return the generated text in Json response
22
- return {"output":output[0]['generated_text']}
23
-
24
 
 
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
+ pipe = pipeline("text2text-generation", model="google/flan-t5-small", clean_up_tokenization_spaces=True)
9
+
10
+ @app.get("/")
11
+ def home():
12
+ return {"message": "Welcome to the Text Generation API"}
13
+
14
+ ## Define a function to handle GET Request at '/generate'
15
+
16
+ @app.get("/generate")
17
+ def generate(text:str):
18
+ ## use the pipeline to generate text based on the input 'text'
19
+ output=pipe(text)
20
+
21
+ ## return the generated text in Json response
22
+ return {"output":output[0]['generated_text']}
23
+
24