ishmeet-yo commited on
Commit
fa81f98
·
verified ·
1 Parent(s): 8b07271

Update app/main.py

Browse files
Files changed (1) hide show
  1. app/main.py +10 -1
app/main.py CHANGED
@@ -12,8 +12,15 @@ app.mount("/static", StaticFiles(directory="static"), name="static")
12
  templates = Jinja2Templates(directory="templates")
13
 
14
  # Load your RAG data once
15
- documents, embeddings= load_data()
16
 
 
 
 
 
 
 
 
17
 
18
  @app.get("/", response_class=HTMLResponse)
19
  async def index(request: Request):
@@ -36,6 +43,8 @@ async def index(request: Request):
36
 
37
 
38
 
 
 
39
  @app.post("/ask")
40
  async def ask(query: str = Form(...)):
41
  retrieved = retrieve_chunks(query, documents, embeddings)
 
12
  templates = Jinja2Templates(directory="templates")
13
 
14
  # Load your RAG data once
15
+ # documents, embeddings= load_data()
16
 
17
+ documents = None
18
+ embeddings = None
19
+
20
+ @app.on_event("startup")
21
+ def startup_event():
22
+ global documents, embeddings
23
+ documents, embeddings = load_data()
24
 
25
  @app.get("/", response_class=HTMLResponse)
26
  async def index(request: Request):
 
43
 
44
 
45
 
46
+
47
+
48
  @app.post("/ask")
49
  async def ask(query: str = Form(...)):
50
  retrieved = retrieve_chunks(query, documents, embeddings)