Add validation for API keys in load_sidebar function
Browse files- scripts/setup.py +10 -0
scripts/setup.py
CHANGED
@@ -102,14 +102,24 @@ def load_sidebar(config_file,
|
|
102 |
sb_out['keys']={}
|
103 |
if 'llm_source' in sb_out and sb_out['llm_source'] == 'OpenAI':
|
104 |
sb_out['keys']['OPENAI_API_KEY'] = st.sidebar.text_input('OpenAI API Key', type='password')
|
|
|
|
|
105 |
elif 'query_model' in sb_out and sb_out['query_model'] == 'Openai':
|
106 |
sb_out['keys']['OPENAI_API_KEY'] = st.sidebar.text_input('OpenAI API Key', type='password')
|
|
|
|
|
107 |
if 'llm_source' in sb_out and sb_out['llm_source']=='Hugging Face':
|
108 |
sb_out['keys']['HUGGINGFACEHUB_API_TOKEN'] = st.sidebar.text_input('Hugging Face API Key', type='password')
|
|
|
|
|
109 |
if 'query_model' in sb_out and sb_out['query_model']=='Voyage':
|
110 |
sb_out['keys']['VOYAGE_API_KEY'] = st.sidebar.text_input('Voyage API Key', type='password')
|
|
|
|
|
111 |
if 'index_type' in sb_out and sb_out['index_type']=='Pinecone':
|
112 |
sb_out['keys']['PINECONE_API_KEY']=st.sidebar.text_input('Pinecone API Key',type='password')
|
|
|
|
|
113 |
return sb_out
|
114 |
def set_secrets(sb):
|
115 |
"""
|
|
|
102 |
sb_out['keys']={}
|
103 |
if 'llm_source' in sb_out and sb_out['llm_source'] == 'OpenAI':
|
104 |
sb_out['keys']['OPENAI_API_KEY'] = st.sidebar.text_input('OpenAI API Key', type='password')
|
105 |
+
if sb_out['keys']['OPENAI_API_KEY']=='':
|
106 |
+
raise Exception('OpenAI API Key is required.')
|
107 |
elif 'query_model' in sb_out and sb_out['query_model'] == 'Openai':
|
108 |
sb_out['keys']['OPENAI_API_KEY'] = st.sidebar.text_input('OpenAI API Key', type='password')
|
109 |
+
if sb_out['keys']['OPENAI_API_KEY']=='':
|
110 |
+
raise Exception('OpenAI API Key is required.')
|
111 |
if 'llm_source' in sb_out and sb_out['llm_source']=='Hugging Face':
|
112 |
sb_out['keys']['HUGGINGFACEHUB_API_TOKEN'] = st.sidebar.text_input('Hugging Face API Key', type='password')
|
113 |
+
if sb_out['keys']['HUGGINGFACEHUB_API_TOKEN']=='':
|
114 |
+
raise Exception('Hugging Face API Key is required.')
|
115 |
if 'query_model' in sb_out and sb_out['query_model']=='Voyage':
|
116 |
sb_out['keys']['VOYAGE_API_KEY'] = st.sidebar.text_input('Voyage API Key', type='password')
|
117 |
+
if sb_out['keys']['VOYAGE_API_KEY']=='':
|
118 |
+
raise Exception('Voyage API Key is required.')
|
119 |
if 'index_type' in sb_out and sb_out['index_type']=='Pinecone':
|
120 |
sb_out['keys']['PINECONE_API_KEY']=st.sidebar.text_input('Pinecone API Key',type='password')
|
121 |
+
if sb_out['keys']['PINECONE_API_KEY']=='':
|
122 |
+
raise Exception('Pinecone API Key is required.')
|
123 |
return sb_out
|
124 |
def set_secrets(sb):
|
125 |
"""
|