Spaces:
Running
on
T4
Running
on
T4
show similarity map
Browse files
pages/Multimodal_Conversational_Search.py
CHANGED
@@ -41,6 +41,7 @@ s3_bucket_ = "pdf-repo-uploads"
|
|
41 |
polly_client = boto3.client('polly',aws_access_key_id=st.secrets['user_access_key'],
|
42 |
aws_secret_access_key=st.secrets['user_secret_key'], region_name = 'us-east-1')
|
43 |
|
|
|
44 |
# Check if the user ID is already stored in the session state
|
45 |
if 'user_id' in st.session_state:
|
46 |
user_id = st.session_state['user_id']
|
@@ -298,6 +299,16 @@ def render_answer(question,answer,index,res_img):
|
|
298 |
audio_col1, audio_col2 = st.columns([50,50])
|
299 |
with audio_col1:
|
300 |
st.audio(polly_response['AudioStream'].read(), format="audio/ogg")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
|
302 |
|
303 |
|
@@ -358,15 +369,15 @@ def render_answer(question,answer,index,res_img):
|
|
358 |
st.table(df)
|
359 |
#with st.expander("Raw sources:"):
|
360 |
st.write(answer["source"])
|
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 |
-
|
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():
|
@@ -378,12 +389,12 @@ def render_answer(question,answer,index,res_img):
|
|
378 |
handle_input()
|
379 |
with placeholder.container():
|
380 |
render_all()
|
381 |
-
def show_maxsim():
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
if("currentValue" in st.session_state):
|
388 |
del st.session_state["currentValue"]
|
389 |
|
@@ -393,7 +404,7 @@ def render_answer(question,answer,index,res_img):
|
|
393 |
pass
|
394 |
placeholder__ = st.empty()
|
395 |
placeholder__.button("🔄",key=rdn_key,on_click=on_button_click)
|
396 |
-
|
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):
|
|
|
41 |
polly_client = boto3.client('polly',aws_access_key_id=st.secrets['user_access_key'],
|
42 |
aws_secret_access_key=st.secrets['user_secret_key'], region_name = 'us-east-1')
|
43 |
|
44 |
+
|
45 |
# Check if the user ID is already stored in the session state
|
46 |
if 'user_id' in st.session_state:
|
47 |
user_id = st.session_state['user_id']
|
|
|
299 |
audio_col1, audio_col2 = st.columns([50,50])
|
300 |
with audio_col1:
|
301 |
st.audio(polly_response['AudioStream'].read(), format="audio/ogg")
|
302 |
+
rdn_key_1 = ''.join([random.choice(string.ascii_letters)
|
303 |
+
for _ in range(10)])
|
304 |
+
def show_maxsim():
|
305 |
+
st.session_state.show_columns = True
|
306 |
+
st.session_state.maxSimImages = colpali.img_highlight(st.session_state.top_img, st.session_state.query_token_vectors, st.session_state.query_tokens)
|
307 |
+
handle_input()
|
308 |
+
with placeholder.container():
|
309 |
+
render_all()
|
310 |
+
if(st.session_state.input_is_colpali):
|
311 |
+
st.button("Show similarity map",key=rdn_key_1,on_click = show_maxsim)
|
312 |
|
313 |
|
314 |
|
|
|
369 |
st.table(df)
|
370 |
#with st.expander("Raw sources:"):
|
371 |
st.write(answer["source"])
|
372 |
+
|
373 |
|
374 |
with col_3:
|
375 |
if(index == len(st.session_state.questions_)):
|
376 |
|
377 |
rdn_key = ''.join([random.choice(string.ascii_letters)
|
378 |
for _ in range(10)])
|
379 |
+
# rdn_key_1 = ''.join([random.choice(string.ascii_letters)
|
380 |
+
# for _ in range(10)])
|
381 |
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
|
382 |
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"])
|
383 |
def on_button_click():
|
|
|
389 |
handle_input()
|
390 |
with placeholder.container():
|
391 |
render_all()
|
392 |
+
# def show_maxsim():
|
393 |
+
# st.session_state.show_columns = True
|
394 |
+
# st.session_state.maxSimImages = colpali.img_highlight(st.session_state.top_img, st.session_state.query_token_vectors, st.session_state.query_tokens)
|
395 |
+
# handle_input()
|
396 |
+
# with placeholder.container():
|
397 |
+
# render_all()
|
398 |
if("currentValue" in st.session_state):
|
399 |
del st.session_state["currentValue"]
|
400 |
|
|
|
404 |
pass
|
405 |
placeholder__ = st.empty()
|
406 |
placeholder__.button("🔄",key=rdn_key,on_click=on_button_click)
|
407 |
+
|
408 |
|
409 |
#Each answer will have context of the question asked in order to associate the provided feedback with the respective question
|
410 |
def write_chat_message(md, q,index):
|