Upload app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
from transformers import pipeline# Use a pipeline as a high-level helper
|
2 |
-
from fastapi import FastAPI
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
app = FastAPI()
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
@app.get("generate")
|
16 |
-
def generate(text:str):
|
17 |
-
output = pipe(text)
|
18 |
-
|
19 |
-
return {"output":output[0]['generated_text']}
|
20 |
-
|
|
|
1 |
+
from transformers import pipeline# Use a pipeline as a high-level helper
|
2 |
+
from fastapi import FastAPI
|
3 |
+
|
4 |
+
|
5 |
+
|
6 |
+
app = FastAPI()
|
7 |
+
|
8 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-small")
|
9 |
+
|
10 |
+
@app.get("/")
|
11 |
+
def home():
|
12 |
+
return {"message":"Hello World"}
|
13 |
+
|
14 |
+
|
15 |
+
@app.get("generate")
|
16 |
+
def generate(text:str):
|
17 |
+
output = pipe(text)
|
18 |
+
|
19 |
+
return {"output":output[0]['generated_text']}
|
20 |
+
|