GhulamJillani commited on
Commit
2f3c12c
·
verified ·
1 Parent(s): 79e31c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -24
app.py CHANGED
@@ -1,24 +1,24 @@
1
- from fastapi import FastAPI
2
- from transformers import pipeline
3
-
4
-
5
- ## create a new FastAPI App instance
6
- app = FastAPI()
7
-
8
- # Initialize the text generation pipeline
9
- pipe = pipeline('text2text-generation', model='google/fan-t5-small')
10
-
11
-
12
- @app.get("/")
13
- def home():
14
- return {"message": "Hello World"}
15
-
16
- # Define a function to hancle the GET request as '/generate'
17
- @app.get("/generate")
18
- def generate_text(prompt: str):
19
- ## use the pipeline to generate text from given input prompt
20
- output = pipe(prompt, max_length=50, do_sample=True, temperature=0.6)
21
-
22
- ## return the generate text in JSON format
23
- return {"output": output[0]['generated_text']}
24
-
 
1
+ from fastapi import FastAPI
2
+ from transformers import pipeline
3
+
4
+
5
+ ## create a new FastAPI App instance
6
+ app = FastAPI()
7
+
8
+ # Initialize the text generation pipeline
9
+ pipe = pipeline('text2text-generation', model='google/fan-t5-small')
10
+
11
+
12
+ @app.get("/")
13
+ def home():
14
+ return {"message": "Hello World"}
15
+
16
+ # Define a function to hancle the GET request as '/generate'
17
+ @app.get("/generate")
18
+ def generate_text(prompt: str):
19
+ ## use the pipeline to generate text from given input prompt
20
+ output = pipe(prompt, max_length=50, do_sample=True, temperature=0.6)
21
+
22
+ ## return the generate text in JSON format
23
+ return {"output": output[0]['generated_text']}
24
+