-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
43 lines (31 loc) · 911 Bytes
/
app.py
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
33
34
35
36
37
38
39
40
41
42
43
from fastapi import Request
from src.helper import LLMCompliance
from fastapi.middleware.cors import CORSMiddleware
from fastapi import FastAPI
import uvicorn
from typing import Optional, Union
from pydantic import BaseModel
import os
class LLMComplianceSchema(BaseModel):
pages: dict
compliance_rules: str
app = FastAPI()
origins = ["*"]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
obj = LLMCompliance()
@app.get("/")
def hello():
return "Welcome to LLM Compliance API"
@app.post("/non_compliance")
def handler(body: LLMComplianceSchema, request: Request):
body.compliance_rules = obj.text_extraction(body.compliance_rules)
results = obj.pipeline(body.pages, body.compliance_rules)
return results
if __name__ == '__main__':
uvicorn.run(app, port=5001, host="0.0.0.0")