Chintan Donda commited on
Commit
9d9579e
1 Parent(s): d2ef46d

Automatically translate weather_forecast_summary in the selected language upon change in the language selection

Browse files
Files changed (1) hide show
  1. app.py +18 -3
app.py CHANGED
@@ -416,6 +416,7 @@ with gr.Blocks(title='KKMS-Smart-Search-Demo') as demo:
416
  outputs=[relevant_paragraphs]
417
  )
418
 
 
419
  with gr.Column(scale=1):
420
  with gr.Tab(label='Sources of relevant paragraphs'):
421
  # Get the Sources of relevant paragraphs
@@ -427,6 +428,7 @@ with gr.Blocks(title='KKMS-Smart-Search-Demo') as demo:
427
  sources_relevant_paragraphs
428
  )
429
 
 
430
  # Get the exact answer for the question asked from the retrieved Relevant paragraphs
431
  with gr.Column(scale=1, min_width=600):
432
  with gr.Tab(label='Answer'):
@@ -438,6 +440,7 @@ with gr.Blocks(title='KKMS-Smart-Search-Demo') as demo:
438
  answer
439
  )
440
 
 
441
  # Covert the answer to Indian language
442
  with gr.Column(scale=1, min_width=600):
443
  with gr.Tab(label='Answer in selected language'):
@@ -464,6 +467,7 @@ with gr.Blocks(title='KKMS-Smart-Search-Demo') as demo:
464
  indic_lang_answer
465
  )
466
 
 
467
  with gr.Column(scale=1, min_width=600):
468
  with gr.Tab(label='Feedback'):
469
  # Submit feedback for the answer
@@ -558,6 +562,7 @@ with gr.Blocks(title='KKMS-Smart-Search-Demo') as demo:
558
  commodity
559
  )
560
 
 
561
  with gr.Column(scale=1, min_width=600):
562
  mandi_price = gr.Textbox(label=f"Mandi Price is:", value=dom.mandi_price, interactive=False)
563
 
@@ -605,6 +610,7 @@ with gr.Blocks(title='KKMS-Smart-Search-Demo') as demo:
605
  district_weather
606
  )
607
 
 
608
  with gr.Column(scale=1, min_width=600):
609
  with gr.Tab(label='Weather Forecast Summary'):
610
  # Get the summary of the weather forecast
@@ -616,6 +622,7 @@ with gr.Blocks(title='KKMS-Smart-Search-Demo') as demo:
616
  weather_forecast_summary
617
  )
618
 
 
619
  # Covert the weather forcast summary in Indian language
620
  with gr.Column(scale=1, min_width=600):
621
  with gr.Tab(label='Weather Forecast Summary in selected language'):
@@ -635,10 +642,14 @@ with gr.Blocks(title='KKMS-Smart-Search-Demo') as demo:
635
  indic_weather_forecast_summary
636
  )
637
 
638
- # User can get the weather forecast summary in their preferred language as well
639
- b_indic_weather_forecast_summary = gr.Button("Get answer in selected language").style(size='sm')
640
- b_indic_weather_forecast_summary.click(fn=dom.click_handler_for_get_indic_translation, inputs=[weather_forecast_summary, language], outputs=[indic_weather_forecast_summary])
 
 
 
641
 
 
642
  with gr.Column(scale=1, min_width=600):
643
  with gr.Tab(label='Weather Info'):
644
  weather = gr.Textbox(label=f"Current weather is:", interactive=False)
@@ -666,6 +677,7 @@ with gr.Blocks(title='KKMS-Smart-Search-Demo') as demo:
666
  value="PDF"
667
  )
668
 
 
669
  with gr.Row(visible=True) as rowUploadPdf:
670
  with gr.Column(scale=1, min_width=600):
671
  file_output = gr.File()
@@ -683,6 +695,7 @@ with gr.Blocks(title='KKMS-Smart-Search-Demo') as demo:
683
  inputs=[doc_type, file_output, question_category]
684
  )
685
 
 
686
  with gr.Row(visible=False) as rowUploadOnlinePdf:
687
  with gr.Column(scale=1, min_width=600):
688
  urls = gr.Textbox(label="Enter URLs for Online PDF (Supports uploading from multiple URLs. Enter the URLs in comma (,) separated format.)", placeholder='Type the URLs here')
@@ -693,6 +706,7 @@ with gr.Blocks(title='KKMS-Smart-Search-Demo') as demo:
693
  inputs=[doc_type, urls, question_category]
694
  )
695
 
 
696
  with gr.Row(visible=False) as rowUploadTextFile:
697
  with gr.Column(scale=1, min_width=600):
698
  file_output = gr.File()
@@ -710,6 +724,7 @@ with gr.Blocks(title='KKMS-Smart-Search-Demo') as demo:
710
  inputs=[doc_type, file_output, question_category]
711
  )
712
 
 
713
  with gr.Row(visible=False) as rowUploadUrls:
714
  with gr.Column(scale=1, min_width=600):
715
  urls = gr.Textbox(label="Enter URLs (Supports uploading from multiple URLs. Enter the URLs in comma (,) separated format.)", placeholder='Type the URLs here')
 
416
  outputs=[relevant_paragraphs]
417
  )
418
 
419
+
420
  with gr.Column(scale=1):
421
  with gr.Tab(label='Sources of relevant paragraphs'):
422
  # Get the Sources of relevant paragraphs
 
428
  sources_relevant_paragraphs
429
  )
430
 
431
+
432
  # Get the exact answer for the question asked from the retrieved Relevant paragraphs
433
  with gr.Column(scale=1, min_width=600):
434
  with gr.Tab(label='Answer'):
 
440
  answer
441
  )
442
 
443
+
444
  # Covert the answer to Indian language
445
  with gr.Column(scale=1, min_width=600):
446
  with gr.Tab(label='Answer in selected language'):
 
467
  indic_lang_answer
468
  )
469
 
470
+
471
  with gr.Column(scale=1, min_width=600):
472
  with gr.Tab(label='Feedback'):
473
  # Submit feedback for the answer
 
562
  commodity
563
  )
564
 
565
+
566
  with gr.Column(scale=1, min_width=600):
567
  mandi_price = gr.Textbox(label=f"Mandi Price is:", value=dom.mandi_price, interactive=False)
568
 
 
610
  district_weather
611
  )
612
 
613
+
614
  with gr.Column(scale=1, min_width=600):
615
  with gr.Tab(label='Weather Forecast Summary'):
616
  # Get the summary of the weather forecast
 
622
  weather_forecast_summary
623
  )
624
 
625
+
626
  # Covert the weather forcast summary in Indian language
627
  with gr.Column(scale=1, min_width=600):
628
  with gr.Tab(label='Weather Forecast Summary in selected language'):
 
642
  indic_weather_forecast_summary
643
  )
644
 
645
+ # Automatically translate weather_forecast_summary in the selected language upon change in the language selection
646
+ language.change(
647
+ dom.click_handler_for_get_indic_translation,
648
+ [weather_forecast_summary, language],
649
+ indic_weather_forecast_summary
650
+ )
651
 
652
+
653
  with gr.Column(scale=1, min_width=600):
654
  with gr.Tab(label='Weather Info'):
655
  weather = gr.Textbox(label=f"Current weather is:", interactive=False)
 
677
  value="PDF"
678
  )
679
 
680
+
681
  with gr.Row(visible=True) as rowUploadPdf:
682
  with gr.Column(scale=1, min_width=600):
683
  file_output = gr.File()
 
695
  inputs=[doc_type, file_output, question_category]
696
  )
697
 
698
+
699
  with gr.Row(visible=False) as rowUploadOnlinePdf:
700
  with gr.Column(scale=1, min_width=600):
701
  urls = gr.Textbox(label="Enter URLs for Online PDF (Supports uploading from multiple URLs. Enter the URLs in comma (,) separated format.)", placeholder='Type the URLs here')
 
706
  inputs=[doc_type, urls, question_category]
707
  )
708
 
709
+
710
  with gr.Row(visible=False) as rowUploadTextFile:
711
  with gr.Column(scale=1, min_width=600):
712
  file_output = gr.File()
 
724
  inputs=[doc_type, file_output, question_category]
725
  )
726
 
727
+
728
  with gr.Row(visible=False) as rowUploadUrls:
729
  with gr.Column(scale=1, min_width=600):
730
  urls = gr.Textbox(label="Enter URLs (Supports uploading from multiple URLs. Enter the URLs in comma (,) separated format.)", placeholder='Type the URLs here')