Display down for maintenance message
Browse files
app.py
CHANGED
|
@@ -417,193 +417,197 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
|
|
| 417 |
translate_to_state = gr.State(TRANSLATE_TO_DEFAULT)
|
| 418 |
literary_style_state = gr.State(LITERARY_STYLE_DEFAULT)
|
| 419 |
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 608 |
|
| 609 |
block.launch(debug=True)
|
|
|
|
| 417 |
translate_to_state = gr.State(TRANSLATE_TO_DEFAULT)
|
| 418 |
literary_style_state = gr.State(LITERARY_STYLE_DEFAULT)
|
| 419 |
|
| 420 |
+
gr.Markdown("<h4><center>Conversational Agent using GPT-3.5 & LangChain</center></h4>")
|
| 421 |
+
gr.Markdown(
|
| 422 |
+
"<b><i><center>Down while implementing some great feedback gathered from the last few days</center></i></b>")
|
| 423 |
+
|
| 424 |
+
# with gr.Tab("Chat"):
|
| 425 |
+
# with gr.Row():
|
| 426 |
+
# with gr.Column():
|
| 427 |
+
# gr.Markdown("<h4><center>Conversational Agent using GPT-3.5 & LangChain</center></h4>")
|
| 428 |
+
#
|
| 429 |
+
# openai_api_key_textbox = gr.Textbox(placeholder="Paste your OpenAI API key (sk-...)",
|
| 430 |
+
# show_label=False, lines=1, type='password')
|
| 431 |
+
#
|
| 432 |
+
# with gr.Row():
|
| 433 |
+
# with gr.Column(scale=1, min_width=100, visible=False):
|
| 434 |
+
# my_file = gr.File(label="Upload a file", type="file", visible=False)
|
| 435 |
+
# tmp_file = gr.File("videos/Masahiro.mp4", visible=False)
|
| 436 |
+
# tmp_file_url = "/file=" + tmp_file.value['name']
|
| 437 |
+
# htm_video = f'<video width="256" height="256" autoplay muted loop><source src={tmp_file_url} type="video/mp4" poster="Masahiro.png"></video>'
|
| 438 |
+
# video_html = gr.HTML(htm_video)
|
| 439 |
+
#
|
| 440 |
+
# # my_aud_file = gr.File(label="Audio file", type="file", visible=True)
|
| 441 |
+
# tmp_aud_file = gr.File("audios/tempfile.mp3", visible=False)
|
| 442 |
+
# tmp_aud_file_url = "/file=" + tmp_aud_file.value['name']
|
| 443 |
+
# htm_audio = f'<audio><source src={tmp_aud_file_url} type="audio/mp3"></audio>'
|
| 444 |
+
# audio_html = gr.HTML(htm_audio)
|
| 445 |
+
#
|
| 446 |
+
# with gr.Column(scale=3):
|
| 447 |
+
# chatbot = gr.Chatbot()
|
| 448 |
+
#
|
| 449 |
+
# with gr.Row():
|
| 450 |
+
# message = gr.Textbox(label="What's on your mind??",
|
| 451 |
+
# placeholder="What's the answer to life, the universe, and everything?",
|
| 452 |
+
# lines=1)
|
| 453 |
+
# submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
|
| 454 |
+
#
|
| 455 |
+
# # UNCOMMENT TO USE WHISPER
|
| 456 |
+
# # with gr.Row():
|
| 457 |
+
# # audio_comp = gr.Microphone(source="microphone", type="filepath", label="Just say it!",
|
| 458 |
+
# # interactive=True, streaming=False)
|
| 459 |
+
# # audio_comp.change(transcribe, inputs=[audio_comp], outputs=[message])
|
| 460 |
+
#
|
| 461 |
+
# gr.Examples(
|
| 462 |
+
# examples=["How many people live in Canada?",
|
| 463 |
+
# "What is 2 to the 30th power?",
|
| 464 |
+
# "How much did it rain in SF today?",
|
| 465 |
+
# "Get me information about the movie 'Avatar'",
|
| 466 |
+
# "What are the top tech headlines in the US?",
|
| 467 |
+
# "On the desk, you see two blue booklets, two purple booklets, and two yellow pairs of sunglasses - "
|
| 468 |
+
# "if I remove all the pairs of sunglasses from the desk, how many purple items remain on it?"],
|
| 469 |
+
# inputs=message
|
| 470 |
+
# )
|
| 471 |
+
#
|
| 472 |
+
# with gr.Tab("Settings"):
|
| 473 |
+
# tools_cb_group = gr.CheckboxGroup(label="Tools:", choices=TOOLS_LIST,
|
| 474 |
+
# value=TOOLS_DEFAULT_LIST)
|
| 475 |
+
# tools_cb_group.change(update_selected_tools,
|
| 476 |
+
# inputs=[tools_cb_group, tools_list_state, llm_state],
|
| 477 |
+
# outputs=[tools_list_state, llm_state, chain_state, express_chain_state])
|
| 478 |
+
#
|
| 479 |
+
# trace_chain_cb = gr.Checkbox(label="Show reasoning chain in chat bubble", value=False)
|
| 480 |
+
# trace_chain_cb.change(update_foo, inputs=[trace_chain_cb, trace_chain_state],
|
| 481 |
+
# outputs=[trace_chain_state])
|
| 482 |
+
#
|
| 483 |
+
# speak_text_cb = gr.Checkbox(label="Speak text from agent", value=False)
|
| 484 |
+
# speak_text_cb.change(update_foo, inputs=[speak_text_cb, speak_text_state],
|
| 485 |
+
# outputs=[speak_text_state])
|
| 486 |
+
#
|
| 487 |
+
# with gr.Tab("Formality"):
|
| 488 |
+
# formality_radio = gr.Radio(label="Formality:",
|
| 489 |
+
# choices=[FORMALITY_DEFAULT, "Casual", "Polite", "Honorific"],
|
| 490 |
+
# value=FORMALITY_DEFAULT)
|
| 491 |
+
# formality_radio.change(update_foo,
|
| 492 |
+
# inputs=[formality_radio, formality_state],
|
| 493 |
+
# outputs=[formality_state])
|
| 494 |
+
#
|
| 495 |
+
# with gr.Tab("Translate to"):
|
| 496 |
+
# translate_to_radio = gr.Radio(label="Translate to:", choices=[
|
| 497 |
+
# TRANSLATE_TO_DEFAULT, "Arabic", "Arabic (Gulf)", "Catalan", "Chinese (Cantonese)", "Chinese (Mandarin)",
|
| 498 |
+
# "Danish", "Dutch", "English (Australian)", "English (British)", "English (Indian)", "English (New Zealand)",
|
| 499 |
+
# "English (South African)", "English (US)", "English (Welsh)", "Finnish", "French", "French (Canadian)",
|
| 500 |
+
# "German", "German (Austrian)", "Hindi", "Icelandic", "Italian", "Japanese", "Korean", "Norwegian", "Polish",
|
| 501 |
+
# "Portuguese (Brazilian)", "Portuguese (European)", "Romanian", "Russian", "Spanish (European)",
|
| 502 |
+
# "Spanish (Mexican)", "Spanish (US)", "Swedish", "Turkish", "Ukrainian", "Welsh",
|
| 503 |
+
# "emojis", "Gen Z slang", "how the stereotypical Karen would say it", "Klingon",
|
| 504 |
+
# "Pirate", "Strange Planet expospeak technical talk", "Yoda"],
|
| 505 |
+
# value=TRANSLATE_TO_DEFAULT)
|
| 506 |
+
#
|
| 507 |
+
# translate_to_radio.change(update_foo,
|
| 508 |
+
# inputs=[translate_to_radio, translate_to_state],
|
| 509 |
+
# outputs=[translate_to_state])
|
| 510 |
+
#
|
| 511 |
+
# with gr.Tab("Lit style"):
|
| 512 |
+
# literary_style_radio = gr.Radio(label="Literary style:", choices=[
|
| 513 |
+
# LITERARY_STYLE_DEFAULT, "Prose", "Summary", "Outline", "Bullets", "Poetry", "Haiku", "Limerick", "Joke",
|
| 514 |
+
# "Knock-knock"],
|
| 515 |
+
# value=LITERARY_STYLE_DEFAULT)
|
| 516 |
+
#
|
| 517 |
+
# literary_style_radio.change(update_foo,
|
| 518 |
+
# inputs=[literary_style_radio, literary_style_state],
|
| 519 |
+
# outputs=[literary_style_state])
|
| 520 |
+
#
|
| 521 |
+
# with gr.Tab("Emotions"):
|
| 522 |
+
# anticipation_level_radio = gr.Radio(label="Anticipation level:",
|
| 523 |
+
# choices=[EMOTION_DEFAULT, "Interest", "Anticipation", "Vigilance"],
|
| 524 |
+
# value=EMOTION_DEFAULT)
|
| 525 |
+
# anticipation_level_radio.change(update_foo,
|
| 526 |
+
# inputs=[anticipation_level_radio, anticipation_level_state],
|
| 527 |
+
# outputs=[anticipation_level_state])
|
| 528 |
+
#
|
| 529 |
+
# joy_level_radio = gr.Radio(label="Joy level:",
|
| 530 |
+
# choices=[EMOTION_DEFAULT, "Serenity", "Joy", "Ecstasy"],
|
| 531 |
+
# value=EMOTION_DEFAULT)
|
| 532 |
+
# joy_level_radio.change(update_foo,
|
| 533 |
+
# inputs=[joy_level_radio, joy_level_state],
|
| 534 |
+
# outputs=[joy_level_state])
|
| 535 |
+
#
|
| 536 |
+
# trust_level_radio = gr.Radio(label="Trust level:",
|
| 537 |
+
# choices=[EMOTION_DEFAULT, "Acceptance", "Trust", "Admiration"],
|
| 538 |
+
# value=EMOTION_DEFAULT)
|
| 539 |
+
# trust_level_radio.change(update_foo,
|
| 540 |
+
# inputs=[trust_level_radio, trust_level_state],
|
| 541 |
+
# outputs=[trust_level_state])
|
| 542 |
+
#
|
| 543 |
+
# fear_level_radio = gr.Radio(label="Fear level:",
|
| 544 |
+
# choices=[EMOTION_DEFAULT, "Apprehension", "Fear", "Terror"],
|
| 545 |
+
# value=EMOTION_DEFAULT)
|
| 546 |
+
# fear_level_radio.change(update_foo,
|
| 547 |
+
# inputs=[fear_level_radio, fear_level_state],
|
| 548 |
+
# outputs=[fear_level_state])
|
| 549 |
+
#
|
| 550 |
+
# surprise_level_radio = gr.Radio(label="Surprise level:",
|
| 551 |
+
# choices=[EMOTION_DEFAULT, "Distraction", "Surprise", "Amazement"],
|
| 552 |
+
# value=EMOTION_DEFAULT)
|
| 553 |
+
# surprise_level_radio.change(update_foo,
|
| 554 |
+
# inputs=[surprise_level_radio, surprise_level_state],
|
| 555 |
+
# outputs=[surprise_level_state])
|
| 556 |
+
#
|
| 557 |
+
# sadness_level_radio = gr.Radio(label="Sadness level:",
|
| 558 |
+
# choices=[EMOTION_DEFAULT, "Pensiveness", "Sadness", "Grief"],
|
| 559 |
+
# value=EMOTION_DEFAULT)
|
| 560 |
+
# sadness_level_radio.change(update_foo,
|
| 561 |
+
# inputs=[sadness_level_radio, sadness_level_state],
|
| 562 |
+
# outputs=[sadness_level_state])
|
| 563 |
+
#
|
| 564 |
+
# disgust_level_radio = gr.Radio(label="Disgust level:",
|
| 565 |
+
# choices=[EMOTION_DEFAULT, "Boredom", "Disgust", "Loathing"],
|
| 566 |
+
# value=EMOTION_DEFAULT)
|
| 567 |
+
# disgust_level_radio.change(update_foo,
|
| 568 |
+
# inputs=[disgust_level_radio, disgust_level_state],
|
| 569 |
+
# outputs=[disgust_level_state])
|
| 570 |
+
#
|
| 571 |
+
# anger_level_radio = gr.Radio(label="Anger level:",
|
| 572 |
+
# choices=[EMOTION_DEFAULT, "Annoyance", "Anger", "Rage"],
|
| 573 |
+
# value=EMOTION_DEFAULT)
|
| 574 |
+
# anger_level_radio.change(update_foo,
|
| 575 |
+
# inputs=[anger_level_radio, anger_level_state],
|
| 576 |
+
# outputs=[anger_level_state])
|
| 577 |
+
#
|
| 578 |
+
# with gr.Tab("Max words"):
|
| 579 |
+
# num_words_slider = gr.Slider(label="Max number of words to generate (0 for don't care)",
|
| 580 |
+
# value=NUM_WORDS_DEFAULT, minimum=0, maximum=MAX_WORDS, step=10)
|
| 581 |
+
# num_words_slider.change(update_foo,
|
| 582 |
+
# inputs=[num_words_slider, num_words_state],
|
| 583 |
+
# outputs=[num_words_state])
|
| 584 |
+
#
|
| 585 |
+
# gr.HTML("""
|
| 586 |
+
# This application demonstrates a conversational agent implemented with OpenAI GPT-3.5 and LangChain.
|
| 587 |
+
# When necessary, it leverages tools for complex math, searching the internet, and accessing news and weather.
|
| 588 |
+
# On a desktop, the agent will often speak using using an animated avatar from
|
| 589 |
+
# <a href='https://exh.ai/'>Ex-Human</a>.""")
|
| 590 |
+
#
|
| 591 |
+
# gr.HTML("<center>Powered by <a href='https://github.com/hwchase17/langchain'>LangChain 🦜️🔗</a></center>")
|
| 592 |
+
#
|
| 593 |
+
# message.submit(chat, inputs=[message, history_state, chain_state, trace_chain_state, speak_text_state,
|
| 594 |
+
# express_chain_state, num_words_state, formality_state,
|
| 595 |
+
# anticipation_level_state, joy_level_state, trust_level_state, fear_level_state,
|
| 596 |
+
# surprise_level_state, sadness_level_state, disgust_level_state, anger_level_state,
|
| 597 |
+
# translate_to_state, literary_style_state],
|
| 598 |
+
# # outputs=[chatbot, history_state, video_html, my_file, message])
|
| 599 |
+
# outputs=[chatbot, history_state, audio_html, tmp_aud_file, message])
|
| 600 |
+
#
|
| 601 |
+
# submit.click(chat, inputs=[message, history_state, chain_state, trace_chain_state, speak_text_state,
|
| 602 |
+
# express_chain_state, num_words_state, formality_state,
|
| 603 |
+
# anticipation_level_state, joy_level_state, trust_level_state, fear_level_state,
|
| 604 |
+
# surprise_level_state, sadness_level_state, disgust_level_state, anger_level_state,
|
| 605 |
+
# translate_to_state, literary_style_state],
|
| 606 |
+
# # outputs=[chatbot, history_state, video_html, my_file, message])
|
| 607 |
+
# outputs=[chatbot, history_state, audio_html, tmp_aud_file, message])
|
| 608 |
+
#
|
| 609 |
+
# openai_api_key_textbox.change(set_openai_api_key,
|
| 610 |
+
# inputs=[openai_api_key_textbox],
|
| 611 |
+
# outputs=[chain_state, express_chain_state, llm_state])
|
| 612 |
|
| 613 |
block.launch(debug=True)
|