File size: 865 Bytes
bfb5d08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from fastapi import FastAPI
from fastapi.responses import RedirectResponse
from langchain.globals import set_verbose
from fastapi.middleware.cors import CORSMiddleware
from routers import ask
import warnings

warnings.filterwarnings("ignore", category=DeprecationWarning)

set_verbose(True)

app = FastAPI()

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

app.include_router(ask.router, prefix="/api")


@app.get("/")
def redirect_docs():
    return RedirectResponse(url="/docs")


if __name__ == "__main__":
    try:
        os.system("uvicorn app:app --port 7860 --host 0.0.0.0")
    except KeyboardInterrupt:
        print("\nBye!\n")
    except Exception as e:
        print(f"Error: {e}")
# Codificación de SAML