jboat commited on
Commit
8820527
1 Parent(s): c732f07

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +15 -2
main.py CHANGED
@@ -1,7 +1,20 @@
1
  from fastapi import FastAPI
 
 
 
 
2
 
3
  app = FastAPI()
4
 
 
 
 
 
 
 
 
 
 
5
  @app.get("/")
6
- def read_root():
7
- return {"Hello": "World!"}
 
1
  from fastapi import FastAPI
2
+ from fastapi.staticfiles import StaticFiles
3
+ from fastapi.responses import FileResponse
4
+
5
+ from transformers import pipeline
6
 
7
  app = FastAPI()
8
 
9
+ pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
10
+
11
+ @app.get("/infer_t5")
12
+ def t5(input):
13
+ output = pipe_flan(input)
14
+ return {"output": output[0]["generated_text"]}
15
+
16
+ app.mount("/", StaticFiles(directory="static", html=True), name="static")
17
+
18
  @app.get("/")
19
+ def index() -> FileResponse:
20
+ return FileResponse(path="/app/static/index.html", media_type="text/html")