prasadnu commited on
Commit
22d4b16
ยท
1 Parent(s): a45c09b

RAG changes

Browse files
pages/Multimodal_Conversational_Search.py CHANGED
@@ -361,24 +361,16 @@ def render_answer(question,answer,index,res_img):
361
 
362
 
363
  with col_3:
364
-
365
- #st.markdown("<div style='color:#e28743;borderWidth: 0px;borderColor: red;borderStyle: solid;width: fit-content;height: fit-content;border-radius: 5px;'><b>"+",".join(st.session_state.input_rag_searchType)+"</b></div>", unsafe_allow_html = True)
366
-
367
-
368
-
369
  if(index == len(st.session_state.questions_)):
370
 
371
  rdn_key = ''.join([random.choice(string.ascii_letters)
372
  for _ in range(10)])
 
 
373
  currentValue = ''.join(st.session_state.input_rag_searchType)+str(st.session_state.input_is_rerank)+str(st.session_state.input_table_with_sql)+st.session_state.input_index
374
  oldValue = ''.join(st.session_state.inputs_["rag_searchType"])+str(st.session_state.inputs_["is_rerank"])+str(st.session_state.inputs_["table_with_sql"])+str(st.session_state.inputs_["index"])
375
- #print("changing values-----------------")
376
  def on_button_click():
377
- # print("button clicked---------------")
378
- # print(currentValue)
379
- # print(oldValue)
380
  if(currentValue!=oldValue or 1==1):
381
- #print("----------regenerate----------------")
382
  st.session_state.input_query = st.session_state.questions_[-1]["question"]
383
  st.session_state.answers_.pop()
384
  st.session_state.questions_.pop()
@@ -399,23 +391,15 @@ def render_answer(question,answer,index,res_img):
399
  del regenerate
400
  except:
401
  pass
402
-
403
- #print("------------------------")
404
- #print(st.session_state)
405
-
406
  placeholder__ = st.empty()
407
-
408
  placeholder__.button("๐Ÿ”„",key=rdn_key,on_click=on_button_click)
409
  placeholder__.button("Show similarity map",key=rdn_key_1,on_click = show_maxsim)
410
 
411
  #Each answer will have context of the question asked in order to associate the provided feedback with the respective question
412
  def write_chat_message(md, q,index):
413
  res_img = md['image']
414
- #st.session_state['session_id'] = res['session_id'] to be added in memory
415
  chat = st.container()
416
  with chat:
417
- #print("st.session_state.input_index------------------")
418
- #print(st.session_state.input_index)
419
  render_answer(q,md,index,res_img)
420
 
421
  def render_all():
@@ -431,11 +415,7 @@ with placeholder.container():
431
  render_all()
432
 
433
  st.markdown("")
434
- col_2, col_3 = st.columns([75,20])
435
- #col_1, col_2, col_3 = st.columns([7.5,71.5,22])
436
- # with col_1:
437
- # st.markdown("<p style='padding:0px 0px 0px 0px; color:#FF9900;font-size:120%'><b>Ask:</b></p>",unsafe_allow_html=True, help = 'Enter the questions and click on "GO"')
438
-
439
  with col_2:
440
  #st.markdown("")
441
  input = st.text_input( "Ask here",label_visibility = "collapsed",key="input_query")
@@ -446,12 +426,6 @@ with st.sidebar:
446
  st.page_link("app.py", label=":orange[Home]", icon="๐Ÿ ")
447
  st.subheader(":blue[Sample Data]")
448
  coln_1,coln_2 = st.columns([70,30])
449
- # index_select = st.radio("Choose one index",["UK Housing","Covid19 impacts on Ireland","Environmental Global Warming","BEIR Research"],
450
- # captions = ['[preview](https://github.com/aws-samples/AI-search-with-amazon-opensearch-service/blob/b559f82c07dfcca973f457c0a15d6444752553ab/rag/sample_pdfs/HPI-Jan-2024-Hometrack.pdf)',
451
- # '[preview](https://github.com/aws-samples/AI-search-with-amazon-opensearch-service/blob/b559f82c07dfcca973f457c0a15d6444752553ab/rag/sample_pdfs/covid19_ie.pdf)',
452
- # '[preview](https://github.com/aws-samples/AI-search-with-amazon-opensearch-service/blob/b559f82c07dfcca973f457c0a15d6444752553ab/rag/sample_pdfs/global_warming.pdf)',
453
- # '[preview](https://github.com/aws-samples/AI-search-with-amazon-opensearch-service/blob/b559f82c07dfcca973f457c0a15d6444752553ab/rag/sample_pdfs/BEIR.pdf)'],
454
- # key="input_rad_index")
455
  with coln_1:
456
  index_select = st.radio("Choose one index",["UK Housing","Global Warming stats","Covid19 impacts on Ireland"],key="input_rad_index")
457
  with coln_2:
@@ -459,7 +433,6 @@ with st.sidebar:
459
  st.write("[:eyes:](https://github.com/aws-samples/AI-search-with-amazon-opensearch-service/blob/b559f82c07dfcca973f457c0a15d6444752553ab/rag/sample_pdfs/HPI-Jan-2024-Hometrack.pdf)")
460
  st.write("[:eyes:](https://github.com/aws-samples/AI-search-with-amazon-opensearch-service/blob/b559f82c07dfcca973f457c0a15d6444752553ab/rag/sample_pdfs/global_warming.pdf)")
461
  st.write("[:eyes:](https://github.com/aws-samples/AI-search-with-amazon-opensearch-service/blob/b559f82c07dfcca973f457c0a15d6444752553ab/rag/sample_pdfs/covid19_ie.pdf)")
462
- #st.write("[:eyes:](https://github.com/aws-samples/AI-search-with-amazon-opensearch-service/blob/b559f82c07dfcca973f457c0a15d6444752553ab/rag/sample_pdfs/BEIR.pdf)")
463
  st.markdown("""
464
  <style>
465
  [data-testid=column]:nth-of-type(2) [data-testid=stVerticalBlock]{
 
361
 
362
 
363
  with col_3:
 
 
 
 
 
364
  if(index == len(st.session_state.questions_)):
365
 
366
  rdn_key = ''.join([random.choice(string.ascii_letters)
367
  for _ in range(10)])
368
+ rdn_key_1 = ''.join([random.choice(string.ascii_letters)
369
+ for _ in range(10)])
370
  currentValue = ''.join(st.session_state.input_rag_searchType)+str(st.session_state.input_is_rerank)+str(st.session_state.input_table_with_sql)+st.session_state.input_index
371
  oldValue = ''.join(st.session_state.inputs_["rag_searchType"])+str(st.session_state.inputs_["is_rerank"])+str(st.session_state.inputs_["table_with_sql"])+str(st.session_state.inputs_["index"])
 
372
  def on_button_click():
 
 
 
373
  if(currentValue!=oldValue or 1==1):
 
374
  st.session_state.input_query = st.session_state.questions_[-1]["question"]
375
  st.session_state.answers_.pop()
376
  st.session_state.questions_.pop()
 
391
  del regenerate
392
  except:
393
  pass
 
 
 
 
394
  placeholder__ = st.empty()
 
395
  placeholder__.button("๐Ÿ”„",key=rdn_key,on_click=on_button_click)
396
  placeholder__.button("Show similarity map",key=rdn_key_1,on_click = show_maxsim)
397
 
398
  #Each answer will have context of the question asked in order to associate the provided feedback with the respective question
399
  def write_chat_message(md, q,index):
400
  res_img = md['image']
 
401
  chat = st.container()
402
  with chat:
 
 
403
  render_answer(q,md,index,res_img)
404
 
405
  def render_all():
 
415
  render_all()
416
 
417
  st.markdown("")
418
+ col_2, col_3 = st.columns([75,20])
 
 
 
 
419
  with col_2:
420
  #st.markdown("")
421
  input = st.text_input( "Ask here",label_visibility = "collapsed",key="input_query")
 
426
  st.page_link("app.py", label=":orange[Home]", icon="๐Ÿ ")
427
  st.subheader(":blue[Sample Data]")
428
  coln_1,coln_2 = st.columns([70,30])
 
 
 
 
 
 
429
  with coln_1:
430
  index_select = st.radio("Choose one index",["UK Housing","Global Warming stats","Covid19 impacts on Ireland"],key="input_rad_index")
431
  with coln_2:
 
433
  st.write("[:eyes:](https://github.com/aws-samples/AI-search-with-amazon-opensearch-service/blob/b559f82c07dfcca973f457c0a15d6444752553ab/rag/sample_pdfs/HPI-Jan-2024-Hometrack.pdf)")
434
  st.write("[:eyes:](https://github.com/aws-samples/AI-search-with-amazon-opensearch-service/blob/b559f82c07dfcca973f457c0a15d6444752553ab/rag/sample_pdfs/global_warming.pdf)")
435
  st.write("[:eyes:](https://github.com/aws-samples/AI-search-with-amazon-opensearch-service/blob/b559f82c07dfcca973f457c0a15d6444752553ab/rag/sample_pdfs/covid19_ie.pdf)")
 
436
  st.markdown("""
437
  <style>
438
  [data-testid=column]:nth-of-type(2) [data-testid=stVerticalBlock]{