sohamagarwal00 commited on
Commit
7f80716
·
1 Parent(s): a6f354b

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -254,7 +254,7 @@ def set_openai_api_key(api_key):
254
  If no api_key, then None is returned.
255
  """
256
  if api_key and api_key.startswith("sk-") and len(api_key) > 50:
257
- os.environ["OPENAI_API_KEY"] = api_key
258
  print("\n\n ++++++++++++++ Setting OpenAI API key ++++++++++++++ \n\n")
259
  print(str(datetime.datetime.now()) + ": Before OpenAI, OPENAI_API_KEY length: " + str(
260
  len(os.environ["OPENAI_API_KEY"])))
@@ -594,15 +594,15 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
594
  use_embeddings_state = gr.State(False)
595
 
596
  with gr.Tab("Chat"):
597
- with gr.Row():
598
 
599
  # with gr.Column():
600
  # gr.HTML(
601
  # """<b><center>GPT + WolframAlpha + Whisper</center></b>
602
  # <p><center>New feature: <b>Embeddings</b></center></p>""")
603
 
604
- openai_api_key_textbox = gr.Textbox(placeholder="Paste your OpenAI API key (sk-...)",
605
- show_label=False, lines=1, type='password')
606
 
607
  with gr.Row():
608
  with gr.Column(scale=1, min_width=TALKING_HEAD_WIDTH, visible=True):
@@ -845,7 +845,7 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
845
  Powered by <a href='https://github.com/hwchase17/langchain'>LangChain 🦜️🔗</a>
846
  </center>""")
847
 
848
- message.submit(chat, inputs=[openai_api_key_textbox, message, history_state, chain_state, trace_chain_state,
849
  speak_text_state, talking_head_state, monologue_state,
850
  express_chain_state, num_words_state, formality_state,
851
  anticipation_level_state, joy_level_state, trust_level_state, fear_level_state,
@@ -855,7 +855,7 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
855
  outputs=[chatbot, history_state, video_html, my_file, audio_html, tmp_aud_file, message])
856
  # outputs=[chatbot, history_state, audio_html, tmp_aud_file, message])
857
 
858
- submit.click(chat, inputs=[openai_api_key_textbox, message, history_state, chain_state, trace_chain_state,
859
  speak_text_state, talking_head_state, monologue_state,
860
  express_chain_state, num_words_state, formality_state,
861
  anticipation_level_state, joy_level_state, trust_level_state, fear_level_state,
@@ -864,10 +864,10 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
864
  qa_chain_state, docsearch_state, use_embeddings_state],
865
  outputs=[chatbot, history_state, video_html, my_file, audio_html, tmp_aud_file, message])
866
  # outputs=[chatbot, history_state, audio_html, tmp_aud_file, message])
867
-
868
  openai_api_key_textbox.change(set_openai_api_key,
869
  inputs=[openai_api_key_textbox],
870
  outputs=[chain_state, express_chain_state, llm_state, embeddings_state,
871
  qa_chain_state, memory_state])
872
-
873
  block.launch(debug=True)
 
254
  If no api_key, then None is returned.
255
  """
256
  if api_key and api_key.startswith("sk-") and len(api_key) > 50:
257
+ os.environ["OPENAI_API_KEY"] = "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" # api_key
258
  print("\n\n ++++++++++++++ Setting OpenAI API key ++++++++++++++ \n\n")
259
  print(str(datetime.datetime.now()) + ": Before OpenAI, OPENAI_API_KEY length: " + str(
260
  len(os.environ["OPENAI_API_KEY"])))
 
594
  use_embeddings_state = gr.State(False)
595
 
596
  with gr.Tab("Chat"):
597
+ # with gr.Row():
598
 
599
  # with gr.Column():
600
  # gr.HTML(
601
  # """<b><center>GPT + WolframAlpha + Whisper</center></b>
602
  # <p><center>New feature: <b>Embeddings</b></center></p>""")
603
 
604
+ #openai_api_key_textbox = gr.Textbox(placeholder="Paste your OpenAI API key (sk-...)",
605
+ # show_label=False, lines=1, type='password')
606
 
607
  with gr.Row():
608
  with gr.Column(scale=1, min_width=TALKING_HEAD_WIDTH, visible=True):
 
845
  Powered by <a href='https://github.com/hwchase17/langchain'>LangChain 🦜️🔗</a>
846
  </center>""")
847
 
848
+ message.submit(chat, inputs=[ message, history_state, chain_state, trace_chain_state,
849
  speak_text_state, talking_head_state, monologue_state,
850
  express_chain_state, num_words_state, formality_state,
851
  anticipation_level_state, joy_level_state, trust_level_state, fear_level_state,
 
855
  outputs=[chatbot, history_state, video_html, my_file, audio_html, tmp_aud_file, message])
856
  # outputs=[chatbot, history_state, audio_html, tmp_aud_file, message])
857
 
858
+ submit.click(chat, inputs=[ message, history_state, chain_state, trace_chain_state,
859
  speak_text_state, talking_head_state, monologue_state,
860
  express_chain_state, num_words_state, formality_state,
861
  anticipation_level_state, joy_level_state, trust_level_state, fear_level_state,
 
864
  qa_chain_state, docsearch_state, use_embeddings_state],
865
  outputs=[chatbot, history_state, video_html, my_file, audio_html, tmp_aud_file, message])
866
  # outputs=[chatbot, history_state, audio_html, tmp_aud_file, message])
867
+ """
868
  openai_api_key_textbox.change(set_openai_api_key,
869
  inputs=[openai_api_key_textbox],
870
  outputs=[chain_state, express_chain_state, llm_state, embeddings_state,
871
  qa_chain_state, memory_state])
872
+ """
873
  block.launch(debug=True)