thinkall commited on
Commit
1f6e4ef
·
1 Parent(s): ef42390

Handle API key

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -132,20 +132,31 @@ with gr.Blocks() as demo:
132
  )
133
  upload_button.upload(upload_file, upload_button)
134
 
 
 
 
 
 
 
 
135
  def set_oai_key(secret):
136
  os.environ["OPENAI_API_KEY"] = secret
 
137
  return secret
138
 
139
  def set_aoai_key(secret):
140
  os.environ["AZURE_OPENAI_API_KEY"] = secret
 
141
  return secret
142
 
143
  def set_aoai_base(secret):
144
  os.environ["AZURE_OPENAI_API_BASE"] = secret
 
145
  return secret
146
 
147
  txt_oai_key = gr.Textbox(
148
  label="OpenAI API Key",
 
149
  max_lines=1,
150
  show_label=True,
151
  value=os.environ.get("OPENAI_API_KEY", ""),
@@ -155,6 +166,7 @@ with gr.Blocks() as demo:
155
  txt_oai_key.submit(set_oai_key, [txt_oai_key], [txt_oai_key])
156
  txt_aoai_key = gr.Textbox(
157
  label="Azure OpenAI API Key",
 
158
  max_lines=1,
159
  show_label=True,
160
  value=os.environ.get("AZURE_OPENAI_API_KEY", ""),
@@ -164,6 +176,7 @@ with gr.Blocks() as demo:
164
  txt_aoai_key.submit(set_aoai_key, [txt_aoai_key], [txt_aoai_key])
165
  txt_aoai_base_url = gr.Textbox(
166
  label="Azure OpenAI API Base",
 
167
  max_lines=1,
168
  show_label=True,
169
  value=os.environ.get("AZURE_OPENAI_API_BASE", ""),
 
132
  )
133
  upload_button.upload(upload_file, upload_button)
134
 
135
+ def update_config():
136
+ global config_list, assistant, ragproxyagent
137
+ config_list = setup_configurations()
138
+ assistant, ragproxyagent = (
139
+ initialize_agents(config_list) if config_list else (None, None)
140
+ )
141
+
142
  def set_oai_key(secret):
143
  os.environ["OPENAI_API_KEY"] = secret
144
+ update_config()
145
  return secret
146
 
147
  def set_aoai_key(secret):
148
  os.environ["AZURE_OPENAI_API_KEY"] = secret
149
+ update_config()
150
  return secret
151
 
152
  def set_aoai_base(secret):
153
  os.environ["AZURE_OPENAI_API_BASE"] = secret
154
+ update_config()
155
  return secret
156
 
157
  txt_oai_key = gr.Textbox(
158
  label="OpenAI API Key",
159
+ placeholder="Enter key and press enter",
160
  max_lines=1,
161
  show_label=True,
162
  value=os.environ.get("OPENAI_API_KEY", ""),
 
166
  txt_oai_key.submit(set_oai_key, [txt_oai_key], [txt_oai_key])
167
  txt_aoai_key = gr.Textbox(
168
  label="Azure OpenAI API Key",
169
+ placeholder="Enter key and press enter",
170
  max_lines=1,
171
  show_label=True,
172
  value=os.environ.get("AZURE_OPENAI_API_KEY", ""),
 
176
  txt_aoai_key.submit(set_aoai_key, [txt_aoai_key], [txt_aoai_key])
177
  txt_aoai_base_url = gr.Textbox(
178
  label="Azure OpenAI API Base",
179
+ placeholder="Enter base url and press enter",
180
  max_lines=1,
181
  show_label=True,
182
  value=os.environ.get("AZURE_OPENAI_API_BASE", ""),