File size: 909 Bytes
3dc648e
 
 
fe446a2
3dc648e
 
fe446a2
 
9947ee1
8e8898f
fe446a2
 
3dc648e
 
8e8898f
e4eaca6
 
8e8898f
 
3dc648e
 
 
 
8e8898f
 
fe446a2
3dc648e
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
import os
from transformers import pipeline

varibale = os.getenv('test_variable')
secret = os.getenv('test_secret')
token_model = os.getenv('HF_Token')



app = FastAPI()

# pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
# pipe_flan = pipeline("text2text-generation", model="GooooGLE/testVulModel",token = token_model)
pipe_flan = pipeline("text2text-generation", model="GooooGLE/testVulModel")



@app.get("/infer_t5")
def t5(input):
    output = pipe_flan(input)
    return {"output": output[0]["generated_text"]}
    # return {"output": str(varibale)+str(secret)}


app.mount("/", StaticFiles(directory="static", html=True), name="static")

@app.get("/")
def index() -> FileResponse:
    return FileResponse(path="/app/static/index.html", media_type="text/html")