prasadnu commited on
Commit
0b90a76
·
1 Parent(s): 1fd73d7

rerank model

Browse files
pages/Multimodal_Conversational_Search.py CHANGED
@@ -42,8 +42,8 @@ AI_ICON = "images/opensearch-twitter-card.png"
42
  REGENERATE_ICON = "images/regenerate.png"
43
  s3_bucket_ = "pdf-repo-uploads"
44
  #"pdf-repo-uploads"
45
- polly_client = boto3.Session(
46
- region_name='us-east-1').client('polly')
47
 
48
  # Check if the user ID is already stored in the session state
49
  if 'user_id' in st.session_state:
@@ -110,11 +110,6 @@ if "input_rag_searchType" not in st.session_state:
110
 
111
 
112
 
113
-
114
- region = 'us-east-1'
115
- bedrock_runtime_client = boto3.client('bedrock-runtime',region_name=region)
116
- output = []
117
- service = 'es'
118
 
119
  st.markdown("""
120
  <style>
@@ -143,10 +138,7 @@ st.markdown("""
143
 
144
  ################# using boto3 credentials ###################
145
 
146
-
147
- credentials = boto3.Session().get_credentials()
148
- awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, 'us-west-2', service, session_token=credentials.token)
149
- service = 'es'
150
 
151
 
152
  ################# using boto3 credentials ####################
@@ -323,14 +315,14 @@ def render_answer(question,answer,index,res_img):
323
  # st.write(ans_)
324
 
325
 
326
- polly_response = polly_client.synthesize_speech(VoiceId='Joanna',
327
- OutputFormat='ogg_vorbis',
328
- Text = ans_,
329
- Engine = 'neural')
330
 
331
- audio_col1, audio_col2 = st.columns([50,50])
332
- with audio_col1:
333
- st.audio(polly_response['AudioStream'].read(), format="audio/ogg")
334
 
335
  rdn_key_1 = ''.join([random.choice(string.ascii_letters)
336
  for _ in range(10)])
@@ -519,33 +511,6 @@ with st.sidebar:
519
  st.markdown("<span style = 'color:#FF9900;'>Global Warming stats</span> - What is the projected energy percentage from renewable sources in future?",unsafe_allow_html=True)
520
  st.markdown("<span style = 'color:#FF9900;'>Covid19 impacts</span> - How many aged above 85 years died due to covid ?",unsafe_allow_html=True)
521
 
522
- # Initialize boto3 to use the S3 client.
523
- s3_client = boto3.resource('s3')
524
- bucket=s3_client.Bucket(s3_bucket_)
525
-
526
- objects = bucket.objects.filter(Prefix="sample_pdfs/")
527
- urls = []
528
-
529
- client = boto3.client('s3')
530
-
531
- for obj in objects:
532
- if obj.key.endswith('.pdf'):
533
-
534
- # Generate the S3 presigned URL
535
- s3_presigned_url = client.generate_presigned_url(
536
- ClientMethod='get_object',
537
- Params={
538
- 'Bucket': s3_bucket_,
539
- 'Key': obj.key
540
- },
541
- ExpiresIn=3600
542
- )
543
-
544
- # Print the created S3 presigned URL
545
- print(s3_presigned_url)
546
- urls.append(s3_presigned_url)
547
- #st.write("["+obj.key.split('/')[1]+"]("+s3_presigned_url+")")
548
- st.link_button(obj.key.split('/')[1], s3_presigned_url)
549
 
550
 
551
  # st.subheader(":blue[Your multi-modal documents]")
 
42
  REGENERATE_ICON = "images/regenerate.png"
43
  s3_bucket_ = "pdf-repo-uploads"
44
  #"pdf-repo-uploads"
45
+ # polly_client = boto3.Session(
46
+ # region_name='us-east-1').client('polly')
47
 
48
  # Check if the user ID is already stored in the session state
49
  if 'user_id' in st.session_state:
 
110
 
111
 
112
 
 
 
 
 
 
113
 
114
  st.markdown("""
115
  <style>
 
138
 
139
  ################# using boto3 credentials ###################
140
 
141
+ awsauth = HTTPBasicAuth('master',st.secrets['ml_search_demo_api_access'])
 
 
 
142
 
143
 
144
  ################# using boto3 credentials ####################
 
315
  # st.write(ans_)
316
 
317
 
318
+ # polly_response = polly_client.synthesize_speech(VoiceId='Joanna',
319
+ # OutputFormat='ogg_vorbis',
320
+ # Text = ans_,
321
+ # Engine = 'neural')
322
 
323
+ # audio_col1, audio_col2 = st.columns([50,50])
324
+ # with audio_col1:
325
+ # st.audio(polly_response['AudioStream'].read(), format="audio/ogg")
326
 
327
  rdn_key_1 = ''.join([random.choice(string.ascii_letters)
328
  for _ in range(10)])
 
511
  st.markdown("<span style = 'color:#FF9900;'>Global Warming stats</span> - What is the projected energy percentage from renewable sources in future?",unsafe_allow_html=True)
512
  st.markdown("<span style = 'color:#FF9900;'>Covid19 impacts</span> - How many aged above 85 years died due to covid ?",unsafe_allow_html=True)
513
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
514
 
515
 
516
  # st.subheader(":blue[Your multi-modal documents]")