Arafath10 commited on
Commit
a14c65f
·
verified ·
1 Parent(s): 7928596

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -3
main.py CHANGED
@@ -28,13 +28,11 @@ app.add_middleware(
28
 
29
  @app.post("/update_user_guide_data")
30
  async def update_user_guide_data():
31
- global query_engine,index
32
- index = user_guide_sync.update_user_guide()
33
- query_engine = index.as_query_engine()
34
  return "guide updated"
35
 
36
  @app.post("/whatsapp")
37
  async def reply_whatsapp(request: Request):
 
38
  form_data = await request.form()
39
  num_media = int(form_data.get("NumMedia", 0))
40
  from_number = form_data.get("From")
@@ -44,6 +42,12 @@ async def reply_whatsapp(request: Request):
44
  response = MessagingResponse()
45
  #msg.media(GOOD_BOY_URL)
46
  try:
 
 
 
 
 
 
47
  gpt_response = query_engine.query(f"""
48
  if you find the answer from provided data then give the realistic(like real human) answer with steps and add the more details link and propper line breaks(\n).
49
  if not find the answer from provided data then say 'please contact our helpdesk'
 
28
 
29
  @app.post("/update_user_guide_data")
30
  async def update_user_guide_data():
 
 
 
31
  return "guide updated"
32
 
33
  @app.post("/whatsapp")
34
  async def reply_whatsapp(request: Request):
35
+
36
  form_data = await request.form()
37
  num_media = int(form_data.get("NumMedia", 0))
38
  from_number = form_data.get("From")
 
42
  response = MessagingResponse()
43
  #msg.media(GOOD_BOY_URL)
44
  try:
45
+ global query_engine,index
46
+ storage_context = StorageContext.from_defaults(persist_dir="llama_index")
47
+ index = load_index_from_storage(storage_context=storage_context)
48
+ query_engine = index.as_query_engine()
49
+ print("loaded")
50
+
51
  gpt_response = query_engine.query(f"""
52
  if you find the answer from provided data then give the realistic(like real human) answer with steps and add the more details link and propper line breaks(\n).
53
  if not find the answer from provided data then say 'please contact our helpdesk'