sadafwalliyani commited on
Commit
b57fe64
1 Parent(s): ac54181

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 instance
5
- app=FastAPI()
6
-
7
- # Initialize the text generation pipeline
8
- pipe=pipeline("text2text-generation", model="google/lan-t5-small")
9
-
10
- # Create routes
11
-
12
- @app.get("/")
13
- def home():
14
- return {"message": "Hello, World!"}
15
-
16
- # Deine a unction to handle the GET request at / generate
17
-
18
- @app.get("/generate")
19
- def generate(text: str):
20
- # Use the pipeline to generate text
21
- output=pipe(text, max_length=100)
22
-
23
- # return the generated text in son response
24
  return {"output": output[0]["generated_text"]}
 
1
+ from fastapi import FastAPI
2
+ from transformers import pipeline
3
+
4
+ ## Create a new fastAPI instance
5
+ app=FastAPI()
6
+
7
+ # Initialize the text generation pipeline
8
+ pipe=pipeline("text2text-generation", model="google/flan-t5-small")
9
+
10
+ # Create routes
11
+
12
+ @app.get("/")
13
+ def home():
14
+ return {"message": "Hello, World!"}
15
+
16
+ # Deine a unction to handle the GET request at / generate
17
+
18
+ @app.get("/generate")
19
+ def generate(text: str):
20
+ # Use the pipeline to generate text
21
+ output=pipe(text, max_length=100)
22
+
23
+ # return the generated text in son response
24
  return {"output": output[0]["generated_text"]}