Spaces:
Runtime error
Runtime error
save api key
Browse files
app.py
CHANGED
@@ -40,14 +40,15 @@ from langchain.vectorstores.faiss import FAISS
|
|
40 |
from langchain.docstore.document import Document
|
41 |
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 |
|
46 |
-
TOOLS_LIST = ['serpapi', 'wolfram-alpha', 'pal-math', 'pal-colored-objects', 'news-api',
|
47 |
-
|
48 |
-
|
49 |
-
'open-meteo-api'] # 'google-search'
|
50 |
-
BUG_FOUND_MSG = "You have found a bug in the data. We will review the logs. Please try again. "
|
51 |
# AUTH_ERR_MSG = "Please paste your OpenAI key from openai.com to use this application. It is not necessary to hit a button or key after pasting it."
|
52 |
AUTH_ERR_MSG = "Please paste your OpenAI key from openai.com to use this application. "
|
53 |
MAX_TOKENS = 1024
|
@@ -58,7 +59,7 @@ MAX_TALKING_HEAD_TEXT_LENGTH = 155
|
|
58 |
|
59 |
# Pertains to Express-inator functionality
|
60 |
NUM_WORDS_DEFAULT = 0
|
61 |
-
MAX_WORDS =
|
62 |
FORMALITY_DEFAULT = "N/A"
|
63 |
TEMPERATURE_DEFAULT = 0.5
|
64 |
EMOTION_DEFAULT = "N/A"
|
@@ -566,6 +567,8 @@ def update_use_embeddings(widget, state):
|
|
566 |
if widget:
|
567 |
state = widget
|
568 |
return state
|
|
|
|
|
569 |
|
570 |
|
571 |
with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
|
@@ -612,7 +615,7 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
|
|
612 |
<p><center>New feature: <b>Embeddings</b></center></p>""")
|
613 |
|
614 |
openai_api_key_textbox = gr.Textbox(placeholder="Paste your OpenAI API key (sk-...)",
|
615 |
-
show_label=False, lines=1, type='password')
|
616 |
|
617 |
with gr.Row():
|
618 |
with gr.Column(scale=1, min_width=TALKING_HEAD_WIDTH, visible=True):
|
@@ -871,9 +874,16 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
|
|
871 |
outputs=[chatbot, history_state, video_html, my_file, audio_html, tmp_aud_file, message])
|
872 |
# outputs=[chatbot, history_state, audio_html, tmp_aud_file, message])
|
873 |
|
|
|
|
|
|
|
|
|
874 |
openai_api_key_textbox.change(set_openai_api_key,
|
875 |
inputs=[openai_api_key_textbox],
|
876 |
outputs=[chain_state, express_chain_state, llm_state, embeddings_state,
|
877 |
qa_chain_state, memory_state])
|
|
|
|
|
|
|
878 |
|
879 |
block.launch(debug=True)
|
|
|
40 |
from langchain.docstore.document import Document
|
41 |
from langchain.chains.question_answering import load_qa_chain
|
42 |
|
43 |
+
os.environ["NEWS_API_KEY"] = ""
|
44 |
+
os.environ["TMDB_BEARER_TOKEN"] = ""
|
45 |
+
|
46 |
news_api_key = os.environ["NEWS_API_KEY"]
|
47 |
tmdb_bearer_token = os.environ["TMDB_BEARER_TOKEN"]
|
48 |
|
49 |
+
TOOLS_LIST = ['serpapi', 'wolfram-alpha', 'pal-math', 'pal-colored-objects', 'news-api'] #'google-search','news-api','tmdb-api','open-meteo-api'
|
50 |
+
TOOLS_DEFAULT_LIST = ['serpapi', 'wolfram-alpha', 'pal-math', 'pal-colored-objects', 'news-api']
|
51 |
+
BUG_FOUND_MSG = "Congratulations, you've found a bug in this application!"
|
|
|
|
|
52 |
# AUTH_ERR_MSG = "Please paste your OpenAI key from openai.com to use this application. It is not necessary to hit a button or key after pasting it."
|
53 |
AUTH_ERR_MSG = "Please paste your OpenAI key from openai.com to use this application. "
|
54 |
MAX_TOKENS = 1024
|
|
|
59 |
|
60 |
# Pertains to Express-inator functionality
|
61 |
NUM_WORDS_DEFAULT = 0
|
62 |
+
MAX_WORDS = 400
|
63 |
FORMALITY_DEFAULT = "N/A"
|
64 |
TEMPERATURE_DEFAULT = 0.5
|
65 |
EMOTION_DEFAULT = "N/A"
|
|
|
567 |
if widget:
|
568 |
state = widget
|
569 |
return state
|
570 |
+
|
571 |
+
|
572 |
|
573 |
|
574 |
with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
|
|
|
615 |
<p><center>New feature: <b>Embeddings</b></center></p>""")
|
616 |
|
617 |
openai_api_key_textbox = gr.Textbox(placeholder="Paste your OpenAI API key (sk-...)",
|
618 |
+
show_label=False, lines=1, type='password', elem_id="openai_api_key_textbox")
|
619 |
|
620 |
with gr.Row():
|
621 |
with gr.Column(scale=1, min_width=TALKING_HEAD_WIDTH, visible=True):
|
|
|
874 |
outputs=[chatbot, history_state, video_html, my_file, audio_html, tmp_aud_file, message])
|
875 |
# outputs=[chatbot, history_state, audio_html, tmp_aud_file, message])
|
876 |
|
877 |
+
openai_api_key_textbox.change(None,
|
878 |
+
inputs=[openai_api_key_textbox],
|
879 |
+
outputs=None, _js="(api_key) => localStorage.setItem('open_api_key', api_key)")
|
880 |
+
|
881 |
openai_api_key_textbox.change(set_openai_api_key,
|
882 |
inputs=[openai_api_key_textbox],
|
883 |
outputs=[chain_state, express_chain_state, llm_state, embeddings_state,
|
884 |
qa_chain_state, memory_state])
|
885 |
+
|
886 |
+
block.load(None, inputs=None, outputs=openai_api_key_textbox, _js="()=> localStorage.getItem('open_api_key')")
|
887 |
+
|
888 |
|
889 |
block.launch(debug=True)
|