thekivashyn commited on
Commit
6cf1b6c
·
1 Parent(s): 6fa371f
Files changed (1) hide show
  1. app.py +16 -15
app.py CHANGED
@@ -42,7 +42,6 @@ from langchain.chains.question_answering import load_qa_chain
42
 
43
  news_api_key = os.environ["NEWS_API_KEY"]
44
  tmdb_bearer_token = os.environ["TMDB_BEARER_TOKEN"]
45
- os.environ["OPENAI_API_KEY"] = "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"
46
 
47
  TOOLS_LIST = ['serpapi', 'wolfram-alpha', 'pal-math', 'pal-colored-objects'] #'google-search','news-api','tmdb-api','open-meteo-api'
48
  TOOLS_DEFAULT_LIST = ['serpapi', 'pal-math']
@@ -57,9 +56,9 @@ MAX_TALKING_HEAD_TEXT_LENGTH = 155
57
 
58
  # Pertains to Express-inator functionality
59
  NUM_WORDS_DEFAULT = 0
60
- MAX_WORDS = 4000
61
  FORMALITY_DEFAULT = "N/A"
62
- TEMPERATURE_DEFAULT = 0.9
63
  EMOTION_DEFAULT = "N/A"
64
  LANG_LEVEL_DEFAULT = "N/A"
65
  TRANSLATE_TO_DEFAULT = "N/A"
@@ -607,11 +606,11 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
607
  with gr.Row():
608
  with gr.Column():
609
  gr.HTML(
610
- """<b>Dragon Evolution AI</b>
611
- <p>Model: <b>Điện Lạnh Support</b>/p>""")
612
 
613
- #openai_api_key_textbox = gr.Textbox(placeholder="Paste your OpenAI API key (sk-...)",
614
- #show_label=False, lines=1, type='password')
615
 
616
  with gr.Row():
617
  with gr.Column(scale=1, min_width=TALKING_HEAD_WIDTH, visible=True):
@@ -635,8 +634,10 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
635
  chatbot = gr.Chatbot()
636
 
637
  with gr.Row():
638
- message = gr.Textbox(placeholder="Tôi AI GPT của Siêu Thị Máy Lạnh, bạn cần tư vấn gì ?", lines=1)
639
- submit = gr.Button(value="Gửi", variant="secondary").style(full_width=False)
 
 
640
 
641
  # UNCOMMENT TO USE WHISPER
642
  with gr.Row():
@@ -848,7 +849,7 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
848
  Powered by <a href='https://github.com/hwchase17/langchain'>LangChain 🦜️🔗</a>
849
  </center>""")
850
 
851
- message.submit(chat, inputs=[message, history_state, chain_state, trace_chain_state,
852
  speak_text_state, talking_head_state, monologue_state,
853
  express_chain_state, num_words_state, formality_state,
854
  anticipation_level_state, joy_level_state, trust_level_state, fear_level_state,
@@ -858,7 +859,7 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
858
  outputs=[chatbot, history_state, video_html, my_file, audio_html, tmp_aud_file, message])
859
  # outputs=[chatbot, history_state, audio_html, tmp_aud_file, message])
860
 
861
- submit.click(chat, inputs=[message, history_state, chain_state, trace_chain_state,
862
  speak_text_state, talking_head_state, monologue_state,
863
  express_chain_state, num_words_state, formality_state,
864
  anticipation_level_state, joy_level_state, trust_level_state, fear_level_state,
@@ -868,9 +869,9 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
868
  outputs=[chatbot, history_state, video_html, my_file, audio_html, tmp_aud_file, message])
869
  # outputs=[chatbot, history_state, audio_html, tmp_aud_file, message])
870
 
871
- #openai_api_key_textbox.change(set_openai_api_key,
872
- #inputs=[openai_api_key_textbox],
873
- #outputs=[chain_state, express_chain_state, llm_state, embeddings_state,
874
- #qa_chain_state, memory_state])
875
 
876
  block.launch(debug=True)
 
42
 
43
  news_api_key = os.environ["NEWS_API_KEY"]
44
  tmdb_bearer_token = os.environ["TMDB_BEARER_TOKEN"]
 
45
 
46
  TOOLS_LIST = ['serpapi', 'wolfram-alpha', 'pal-math', 'pal-colored-objects'] #'google-search','news-api','tmdb-api','open-meteo-api'
47
  TOOLS_DEFAULT_LIST = ['serpapi', 'pal-math']
 
56
 
57
  # Pertains to Express-inator functionality
58
  NUM_WORDS_DEFAULT = 0
59
+ MAX_WORDS = 400
60
  FORMALITY_DEFAULT = "N/A"
61
+ TEMPERATURE_DEFAULT = 0.5
62
  EMOTION_DEFAULT = "N/A"
63
  LANG_LEVEL_DEFAULT = "N/A"
64
  TRANSLATE_TO_DEFAULT = "N/A"
 
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
 
615
  with gr.Row():
616
  with gr.Column(scale=1, min_width=TALKING_HEAD_WIDTH, visible=True):
 
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():
 
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,
855
  anticipation_level_state, joy_level_state, trust_level_state, fear_level_state,
 
859
  outputs=[chatbot, history_state, video_html, my_file, audio_html, tmp_aud_file, message])
860
  # outputs=[chatbot, history_state, audio_html, tmp_aud_file, message])
861
 
862
+ submit.click(chat, inputs=[openai_api_key_textbox, message, history_state, chain_state, trace_chain_state,
863
  speak_text_state, talking_head_state, monologue_state,
864
  express_chain_state, num_words_state, formality_state,
865
  anticipation_level_state, joy_level_state, trust_level_state, fear_level_state,
 
869
  outputs=[chatbot, history_state, video_html, my_file, audio_html, tmp_aud_file, message])
870
  # outputs=[chatbot, history_state, audio_html, tmp_aud_file, message])
871
 
872
+ openai_api_key_textbox.change(set_openai_api_key,
873
+ inputs=[openai_api_key_textbox],
874
+ outputs=[chain_state, express_chain_state, llm_state, embeddings_state,
875
+ qa_chain_state, memory_state])
876
 
877
  block.launch(debug=True)