pratham0203 commited on
Commit
27f42a2
1 Parent(s): 6af8266

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -32
app.py CHANGED
@@ -1,32 +1,33 @@
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
- # Use a pipeline as a high-level helper
9
-
10
-
11
- pipe = pipeline("text2text-generation", model="Salesforce/codet5-small")
12
-
13
-
14
- @app.get("/")
15
- def home():
16
- return {"message":"Welcome DFE team"}
17
-
18
- # Define a function to handle the GET request at `/generate`
19
-
20
-
21
- @app.get("/generate")
22
- def generate(text:str):
23
- # messages = [
24
- # {"role": "user", "content": text},
25
- # ]
26
- ## use the pipeline to generate text from given input text
27
- output=pipe(text)
28
-
29
- ## return the generate text in Json reposne
30
- return {"output":output[0]['generated_text']}
31
-
32
-
 
 
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
+ # Use a pipeline as a high-level helper
9
+
10
+
11
+ pipe = pipeline("text2text-generation", model="Salesforce/codet5-small")
12
+
13
+
14
+ @app.get("/")
15
+ def home():
16
+ return {"message":"Welcome DFE team"}
17
+
18
+ # Define a function to handle the GET request at `/generate`
19
+
20
+
21
+ @app.get("/generate")
22
+ def generate(text:str):
23
+ # messages = [
24
+ # {"role": "user", "content": text},
25
+ # ]
26
+ ## use the pipeline to generate text from given input text
27
+ output=pipe(text)
28
+
29
+ ## return the generate text in Json reposne
30
+ # return {"output":output[0]['generated_text']}
31
+ return output
32
+
33
+