Alfie Grace commited on
Commit
281454a
·
1 Parent(s): 37acf54

Removed additional Gradio tabs

Browse files
Files changed (1) hide show
  1. app.py +1 -216
app.py CHANGED
@@ -604,11 +604,6 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
604
 
605
  with gr.Tab("Chat"):
606
  with gr.Row():
607
- with gr.Column():
608
- gr.HTML(
609
- """<b><center>GPT + WolframAlpha + Whisper</center></b>
610
- <p><center>New feature: <b>Embeddings</b></center></p>""")
611
-
612
  openai_api_key_textbox = gr.Textbox(placeholder="Paste your OpenAI API key (sk-...)",
613
  show_label=False, lines=1, type='password')
614
 
@@ -634,221 +629,11 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
634
  chatbot = gr.Chatbot()
635
 
636
  with gr.Row():
637
- message = gr.Textbox(label="What's on your mind??",
638
  placeholder="What's the answer to life, the universe, and everything?",
639
  lines=1)
640
  submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
641
 
642
- # UNCOMMENT TO USE WHISPER
643
- with gr.Row():
644
- audio_comp = gr.Microphone(source="microphone", type="filepath", label="Just say it!",
645
- interactive=True, streaming=False)
646
- audio_comp.change(transcribe, inputs=[audio_comp, whisper_lang_state], outputs=[message])
647
-
648
- # TEMPORARY FOR TESTING
649
- # with gr.Row():
650
- # audio_comp_tb = gr.Textbox(label="Just say it!", lines=1)
651
- # audio_comp_tb.submit(transcribe_dummy, inputs=[audio_comp_tb, whisper_lang_state], outputs=[message])
652
-
653
- gr.Examples(
654
- examples=["How many people live in Canada?",
655
- "What is 2 to the 30th power?",
656
- "If x+y=10 and x-y=4, what are x and y?",
657
- "How much did it rain in SF today?",
658
- "Get me information about the movie 'Avatar'",
659
- "What are the top tech headlines in the US?",
660
- "On the desk, you see two blue booklets, two purple booklets, and two yellow pairs of sunglasses - "
661
- "if I remove all the pairs of sunglasses from the desk, how many purple items remain on it?"],
662
- inputs=message
663
- )
664
-
665
- with gr.Tab("Settings"):
666
- tools_cb_group = gr.CheckboxGroup(label="Tools:", choices=TOOLS_LIST,
667
- value=TOOLS_DEFAULT_LIST)
668
- tools_cb_group.change(update_selected_tools,
669
- inputs=[tools_cb_group, tools_list_state, llm_state],
670
- outputs=[tools_list_state, llm_state, chain_state, express_chain_state])
671
-
672
- trace_chain_cb = gr.Checkbox(label="Show reasoning chain in chat bubble", value=False)
673
- trace_chain_cb.change(update_foo, inputs=[trace_chain_cb, trace_chain_state],
674
- outputs=[trace_chain_state])
675
-
676
- # speak_text_cb = gr.Checkbox(label="Speak text from agent", value=False)
677
- # speak_text_cb.change(update_foo, inputs=[speak_text_cb, speak_text_state],
678
- # outputs=[speak_text_state])
679
-
680
- talking_head_cb = gr.Checkbox(label="Show talking head", value=True)
681
- talking_head_cb.change(update_talking_head, inputs=[talking_head_cb, talking_head_state],
682
- outputs=[talking_head_state, video_html])
683
-
684
- monologue_cb = gr.Checkbox(label="Babel fish mode (translate/restate what you enter, no conversational agent)",
685
- value=False)
686
- monologue_cb.change(update_foo, inputs=[monologue_cb, monologue_state],
687
- outputs=[monologue_state])
688
-
689
- reset_btn = gr.Button(value="Reset chat", variant="secondary").style(full_width=False)
690
- reset_btn.click(reset_memory, inputs=[history_state, memory_state], outputs=[chatbot, history_state, memory_state])
691
-
692
- with gr.Tab("Whisper STT"):
693
- whisper_lang_radio = gr.Radio(label="Whisper speech-to-text language:", choices=[
694
- WHISPER_DETECT_LANG, "Arabic", "Arabic (Gulf)", "Catalan", "Chinese (Cantonese)", "Chinese (Mandarin)",
695
- "Danish", "Dutch", "English (Australian)", "English (British)", "English (Indian)", "English (New Zealand)",
696
- "English (South African)", "English (US)", "English (Welsh)", "Finnish", "French", "French (Canadian)",
697
- "German", "German (Austrian)", "Georgian", "Hindi", "Icelandic", "Indonesian", "Italian", "Japanese",
698
- "Korean", "Norwegian", "Polish",
699
- "Portuguese (Brazilian)", "Portuguese (European)", "Romanian", "Russian", "Spanish (European)",
700
- "Spanish (Mexican)", "Spanish (US)", "Swedish", "Turkish", "Ukrainian", "Welsh"],
701
- value=WHISPER_DETECT_LANG)
702
-
703
- whisper_lang_radio.change(update_foo,
704
- inputs=[whisper_lang_radio, whisper_lang_state],
705
- outputs=[whisper_lang_state])
706
-
707
- with gr.Tab("Translate to"):
708
- lang_level_radio = gr.Radio(label="Language level:", choices=[
709
- LANG_LEVEL_DEFAULT, "1st grade", "2nd grade", "3rd grade", "4th grade", "5th grade", "6th grade",
710
- "7th grade", "8th grade", "9th grade", "10th grade", "11th grade", "12th grade", "University"],
711
- value=LANG_LEVEL_DEFAULT)
712
- lang_level_radio.change(update_foo, inputs=[lang_level_radio, lang_level_state],
713
- outputs=[lang_level_state])
714
-
715
- translate_to_radio = gr.Radio(label="Language:", choices=[
716
- TRANSLATE_TO_DEFAULT, "Arabic", "Arabic (Gulf)", "Catalan", "Chinese (Cantonese)", "Chinese (Mandarin)",
717
- "Danish", "Dutch", "English (Australian)", "English (British)", "English (Indian)", "English (New Zealand)",
718
- "English (South African)", "English (US)", "English (Welsh)", "Finnish", "French", "French (Canadian)",
719
- "German", "German (Austrian)", "Georgian", "Hindi", "Icelandic", "Indonesian", "Italian", "Japanese",
720
- "Korean", "Norwegian", "Polish",
721
- "Portuguese (Brazilian)", "Portuguese (European)", "Romanian", "Russian", "Spanish (European)",
722
- "Spanish (Mexican)", "Spanish (US)", "Swedish", "Turkish", "Ukrainian", "Welsh",
723
- "emojis", "Gen Z slang", "how the stereotypical Karen would say it", "Klingon", "Neanderthal",
724
- "Pirate", "Strange Planet expospeak technical talk", "Yoda"],
725
- value=TRANSLATE_TO_DEFAULT)
726
-
727
- translate_to_radio.change(update_foo,
728
- inputs=[translate_to_radio, translate_to_state],
729
- outputs=[translate_to_state])
730
-
731
- with gr.Tab("Formality"):
732
- formality_radio = gr.Radio(label="Formality:",
733
- choices=[FORMALITY_DEFAULT, "Casual", "Polite", "Honorific"],
734
- value=FORMALITY_DEFAULT)
735
- formality_radio.change(update_foo,
736
- inputs=[formality_radio, formality_state],
737
- outputs=[formality_state])
738
-
739
- with gr.Tab("Lit style"):
740
- literary_style_radio = gr.Radio(label="Literary style:", choices=[
741
- LITERARY_STYLE_DEFAULT, "Prose", "Story", "Summary", "Outline", "Bullets", "Poetry", "Haiku", "Limerick", "Rap",
742
- "Joke", "Knock-knock", "FAQ"],
743
- value=LITERARY_STYLE_DEFAULT)
744
-
745
- literary_style_radio.change(update_foo,
746
- inputs=[literary_style_radio, literary_style_state],
747
- outputs=[literary_style_state])
748
-
749
- with gr.Tab("Emotions"):
750
- anticipation_level_radio = gr.Radio(label="Anticipation level:",
751
- choices=[EMOTION_DEFAULT, "Interest", "Anticipation", "Vigilance"],
752
- value=EMOTION_DEFAULT)
753
- anticipation_level_radio.change(update_foo,
754
- inputs=[anticipation_level_radio, anticipation_level_state],
755
- outputs=[anticipation_level_state])
756
-
757
- joy_level_radio = gr.Radio(label="Joy level:",
758
- choices=[EMOTION_DEFAULT, "Serenity", "Joy", "Ecstasy"],
759
- value=EMOTION_DEFAULT)
760
- joy_level_radio.change(update_foo,
761
- inputs=[joy_level_radio, joy_level_state],
762
- outputs=[joy_level_state])
763
-
764
- trust_level_radio = gr.Radio(label="Trust level:",
765
- choices=[EMOTION_DEFAULT, "Acceptance", "Trust", "Admiration"],
766
- value=EMOTION_DEFAULT)
767
- trust_level_radio.change(update_foo,
768
- inputs=[trust_level_radio, trust_level_state],
769
- outputs=[trust_level_state])
770
-
771
- fear_level_radio = gr.Radio(label="Fear level:",
772
- choices=[EMOTION_DEFAULT, "Apprehension", "Fear", "Terror"],
773
- value=EMOTION_DEFAULT)
774
- fear_level_radio.change(update_foo,
775
- inputs=[fear_level_radio, fear_level_state],
776
- outputs=[fear_level_state])
777
-
778
- surprise_level_radio = gr.Radio(label="Surprise level:",
779
- choices=[EMOTION_DEFAULT, "Distraction", "Surprise", "Amazement"],
780
- value=EMOTION_DEFAULT)
781
- surprise_level_radio.change(update_foo,
782
- inputs=[surprise_level_radio, surprise_level_state],
783
- outputs=[surprise_level_state])
784
-
785
- sadness_level_radio = gr.Radio(label="Sadness level:",
786
- choices=[EMOTION_DEFAULT, "Pensiveness", "Sadness", "Grief"],
787
- value=EMOTION_DEFAULT)
788
- sadness_level_radio.change(update_foo,
789
- inputs=[sadness_level_radio, sadness_level_state],
790
- outputs=[sadness_level_state])
791
-
792
- disgust_level_radio = gr.Radio(label="Disgust level:",
793
- choices=[EMOTION_DEFAULT, "Boredom", "Disgust", "Loathing"],
794
- value=EMOTION_DEFAULT)
795
- disgust_level_radio.change(update_foo,
796
- inputs=[disgust_level_radio, disgust_level_state],
797
- outputs=[disgust_level_state])
798
-
799
- anger_level_radio = gr.Radio(label="Anger level:",
800
- choices=[EMOTION_DEFAULT, "Annoyance", "Anger", "Rage"],
801
- value=EMOTION_DEFAULT)
802
- anger_level_radio.change(update_foo,
803
- inputs=[anger_level_radio, anger_level_state],
804
- outputs=[anger_level_state])
805
-
806
- with gr.Tab("Max words"):
807
- num_words_slider = gr.Slider(label="Max number of words to generate (0 for don't care)",
808
- value=NUM_WORDS_DEFAULT, minimum=0, maximum=MAX_WORDS, step=10)
809
- num_words_slider.change(update_foo,
810
- inputs=[num_words_slider, num_words_state],
811
- outputs=[num_words_state])
812
-
813
- with gr.Tab("Embeddings"):
814
- embeddings_text_box = gr.Textbox(label="Enter text for embeddings and hit Create:",
815
- lines=20)
816
-
817
- with gr.Row():
818
- use_embeddings_cb = gr.Checkbox(label="Use embeddings", value=False)
819
- use_embeddings_cb.change(update_use_embeddings, inputs=[use_embeddings_cb, use_embeddings_state],
820
- outputs=[use_embeddings_state])
821
-
822
- embeddings_text_submit = gr.Button(value="Create", variant="secondary").style(full_width=False)
823
- embeddings_text_submit.click(update_embeddings,
824
- inputs=[embeddings_text_box, embeddings_state, qa_chain_state],
825
- outputs=[docsearch_state])
826
-
827
- gr.HTML("""
828
- <p>This application, developed by <a href='https://www.linkedin.com/in/javafxpert/'>James L. Weaver</a>,
829
- demonstrates a conversational agent implemented with OpenAI GPT-3.5 and LangChain.
830
- When necessary, it leverages tools for complex math, searching the internet, and accessing news and weather.
831
- Uses talking heads from <a href='https://exh.ai/'>Ex-Human</a>.
832
- For faster inference without waiting in queue, you may duplicate the space.
833
- </p>""")
834
-
835
- gr.HTML("""
836
- <form action="https://www.paypal.com/donate" method="post" target="_blank">
837
- <input type="hidden" name="business" value="AK8BVNALBXSPQ" />
838
- <input type="hidden" name="no_recurring" value="0" />
839
- <input type="hidden" name="item_name" value="Please consider helping to defray the cost of APIs such as SerpAPI and WolframAlpha that this app uses." />
840
- <input type="hidden" name="currency_code" value="USD" />
841
- <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />
842
- <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
843
- </form>
844
- """)
845
-
846
- gr.HTML("""<center>
847
- <a href="https://huggingface.co/spaces/JavaFXpert/Chat-GPT-LangChain?duplicate=true">
848
- <img style="margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>
849
- Powered by <a href='https://github.com/hwchase17/langchain'>LangChain 🦜️🔗</a>
850
- </center>""")
851
-
852
  message.submit(chat, inputs=[openai_api_key_textbox, message, history_state, chain_state, trace_chain_state,
853
  speak_text_state, talking_head_state, monologue_state,
854
  express_chain_state, num_words_state, formality_state,
 
604
 
605
  with gr.Tab("Chat"):
606
  with gr.Row():
 
 
 
 
 
607
  openai_api_key_textbox = gr.Textbox(placeholder="Paste your OpenAI API key (sk-...)",
608
  show_label=False, lines=1, type='password')
609
 
 
629
  chatbot = gr.Chatbot()
630
 
631
  with gr.Row():
632
+ message = gr.Textbox(label="What's on your mind?",
633
  placeholder="What's the answer to life, the universe, and everything?",
634
  lines=1)
635
  submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
636
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
637
  message.submit(chat, inputs=[openai_api_key_textbox, message, history_state, chain_state, trace_chain_state,
638
  speak_text_state, talking_head_state, monologue_state,
639
  express_chain_state, num_words_state, formality_state,