kouki321 commited on
Commit
c33cb17
·
verified ·
1 Parent(s): c3325d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -1,16 +1,16 @@
1
- from transformers import pipeline
2
- from fastapi import FastAPI, Request, HTTPException
3
 
4
- app = FastAPI()
5
 
6
- generator = pipeline('text2text-generation', model='google/flan-t5-small')
7
 
8
- @app.post("/")
9
- async def generate(request: Request):
10
- try:
11
- data = await request.json()
12
- text = data["text"]
13
- output = generator(text)
14
- return {"output": output[0]["generated_text"]}
15
- except Exception as e:
16
- raise HTTPException(status_code=500, detail=str(e))
 
1
+ from transformers import pipeline
2
+ from fastapi import FastAPI, Request, HTTPException
3
 
4
+ app = FastAPI()
5
 
6
+ generator = pipeline('text2text-generation', model='google/flan-t5-small')
7
 
8
+ @app.post("/")
9
+ async def generate(request: Request):
10
+ try:
11
+ data = await request.json()
12
+ text = data["text"]
13
+ output = generator(text)
14
+ return {"output": output[0]["generated_text"]}
15
+ except Exception as e:
16
+ raise HTTPException(status_code=500, detail=str(e))