prasadnu commited on
Commit
63c9f19
·
1 Parent(s): 475ff3a

RAG changes

Browse files
pages/Multimodal_Conversational_Search.py CHANGED
@@ -309,55 +309,55 @@ def render_answer(question,answer,index,res_img):
309
  with st.expander("Relevant Sources:"):
310
  with st.container():
311
  if(len(res_img)>0):
312
- with st.expander("Images:"):
313
 
314
- idx = 0
315
- print(res_img)
316
- for i in range(0,len(res_img)):
317
-
318
- if(st.session_state.input_is_colpali):
319
- if(st.session_state.show_columns == True):
320
- cols_per_row = 3
321
- st.session_state.image_placeholder=st.empty()
322
- with st.session_state.image_placeholder.container():
323
- row = st.columns(cols_per_row)
324
- for j, item in enumerate(res_img[i:i+cols_per_row]):
325
- with row[j]:
326
- st.image(item['file'])
327
-
328
- else:
329
- st.session_state.image_placeholder = st.empty()
330
- with st.session_state.image_placeholder.container():
331
- col3_,col4_,col5_ = st.columns([33,33,33])
332
- with col3_:
333
- st.image(res_img[i]['file'])
334
-
335
-
336
-
337
-
338
 
339
  else:
340
- if(res_img[i]['file'].lower()!='none' and idx < 2):
341
- col3,col4,col5 = st.columns([33,33,33])
342
- cols = [col3,col4]
343
- img = res_img[i]['file'].split(".")[0]
344
- caption = res_img[i]['caption']
345
 
346
- with cols[idx]:
347
-
348
- st.image(parent_dirname+"/figures/"+st.session_state.input_index+"/"+img+".jpg")
349
- #st.write(caption)
350
- idx = idx+1
351
- if(st.session_state.show_columns == True):
352
- st.session_state.show_columns = False
 
 
 
 
 
 
 
 
 
 
 
353
  #st.markdown("<div style='color:#e28743';padding:3px 7px 3px 7px;borderWidth: 0px;borderColor: red;borderStyle: solid;width: fit-content;height: fit-content;border-radius: 10px;'><b>Sources from the document:</b></div>", unsafe_allow_html = True)
354
  if(len(answer["table"] )>0):
355
- with st.expander("Table:"):
356
- df = pd.read_csv(answer["table"][0]['name'],skipinitialspace = True, on_bad_lines='skip',delimiter='`')
357
- df.fillna(method='pad', inplace=True)
358
- st.table(df)
359
- with st.expander("Raw sources:"):
360
- st.write(answer["source"])
361
 
362
 
363
  with col_3:
 
309
  with st.expander("Relevant Sources:"):
310
  with st.container():
311
  if(len(res_img)>0):
312
+ #with st.expander("Images:"):
313
 
314
+ idx = 0
315
+ print(res_img)
316
+ for i in range(0,len(res_img)):
317
+
318
+ if(st.session_state.input_is_colpali):
319
+ if(st.session_state.show_columns == True):
320
+ cols_per_row = 3
321
+ st.session_state.image_placeholder=st.empty()
322
+ with st.session_state.image_placeholder.container():
323
+ row = st.columns(cols_per_row)
324
+ for j, item in enumerate(res_img[i:i+cols_per_row]):
325
+ with row[j]:
326
+ st.image(item['file'])
 
 
 
 
 
 
 
 
 
 
 
327
 
328
  else:
329
+ st.session_state.image_placeholder = st.empty()
330
+ with st.session_state.image_placeholder.container():
331
+ col3_,col4_,col5_ = st.columns([33,33,33])
332
+ with col3_:
333
+ st.image(res_img[i]['file'])
334
 
335
+
336
+
337
+
338
+
339
+ else:
340
+ if(res_img[i]['file'].lower()!='none' and idx < 2):
341
+ col3,col4,col5 = st.columns([33,33,33])
342
+ cols = [col3,col4]
343
+ img = res_img[i]['file'].split(".")[0]
344
+ caption = res_img[i]['caption']
345
+
346
+ with cols[idx]:
347
+
348
+ st.image(parent_dirname+"/figures/"+st.session_state.input_index+"/"+img+".jpg")
349
+ #st.write(caption)
350
+ idx = idx+1
351
+ if(st.session_state.show_columns == True):
352
+ st.session_state.show_columns = False
353
  #st.markdown("<div style='color:#e28743';padding:3px 7px 3px 7px;borderWidth: 0px;borderColor: red;borderStyle: solid;width: fit-content;height: fit-content;border-radius: 10px;'><b>Sources from the document:</b></div>", unsafe_allow_html = True)
354
  if(len(answer["table"] )>0):
355
+ #with st.expander("Table:"):
356
+ df = pd.read_csv(answer["table"][0]['name'],skipinitialspace = True, on_bad_lines='skip',delimiter='`')
357
+ df.fillna(method='pad', inplace=True)
358
+ st.table(df)
359
+ #with st.expander("Raw sources:"):
360
+ st.write(answer["source"])
361
 
362
 
363
  with col_3: