Spaces:
Sleeping
Sleeping
pratham0203
commited on
Commit
•
2030bc2
1
Parent(s):
cead938
update
Browse files
app.py
CHANGED
@@ -5,7 +5,10 @@ from transformers import pipeline
|
|
5 |
app=FastAPI()
|
6 |
|
7 |
# Initialize the text generation pipeline
|
8 |
-
|
|
|
|
|
|
|
9 |
|
10 |
|
11 |
@app.get("/")
|
@@ -17,11 +20,11 @@ def home():
|
|
17 |
|
18 |
@app.get("/generate")
|
19 |
def generate(text:str):
|
20 |
-
|
21 |
-
|
22 |
-
]
|
23 |
## use the pipeline to generate text from given input text
|
24 |
-
output=pipe(
|
25 |
|
26 |
## return the generate text in Json reposne
|
27 |
return {"output":output[0]['generated_text']}
|
|
|
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("/")
|
|
|
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']}
|