Spaces:
Sleeping
Sleeping
Commit
·
5463029
1
Parent(s):
9b0a748
changes to hide tabs until data is loaded
Browse files
app.py
CHANGED
@@ -294,18 +294,32 @@ with gr.Blocks(theme='aliabid94/new-theme') as demo:
|
|
294 |
openai_api_key = gr.Textbox(label = 'Please provide your OpenAI API Key:', type = 'password', placeholder = 'Note: To use the OpenAI API, you need a paid account')
|
295 |
api_key_output = gr.Textbox(label = 'Result')
|
296 |
load_button = gr.Button('Load TLS Protect Cloud Data')
|
297 |
-
with gr.Tab("Answer Questions"):
|
298 |
#prompt_tlspc_key = gr.Textbox(label = 'Please provide your TLS Protect Cloud API Key:')
|
299 |
prompt_questions = gr.Textbox(label = 'Input prompt here:', placeholder = "Try something like 'What is the name of the issuing template that has been used to request the most certificates?'")
|
300 |
text_output = gr.Textbox(label = 'Response:')
|
301 |
text_button = gr.Button("Submit")
|
302 |
-
with gr.Tab("Create Graphs"):
|
303 |
prompt_reporting = gr.Textbox(label = 'Input prompt here:', placeholder = "Try something like 'Plot a line chart of certificate issuances over time'")
|
304 |
chart_output = gr.Plot(label = 'Output:')
|
305 |
chart_button = gr.Button("Submit")
|
306 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
text_button.click(prompt_analyze_questions, inputs=prompt_questions, outputs=text_output)
|
308 |
chart_button.click(prompt_analyze_reporting, inputs=prompt_reporting, outputs=chart_output)
|
309 |
-
load_button.click(
|
|
|
310 |
|
311 |
demo.launch()
|
|
|
294 |
openai_api_key = gr.Textbox(label = 'Please provide your OpenAI API Key:', type = 'password', placeholder = 'Note: To use the OpenAI API, you need a paid account')
|
295 |
api_key_output = gr.Textbox(label = 'Result')
|
296 |
load_button = gr.Button('Load TLS Protect Cloud Data')
|
297 |
+
with gr.Tab("Answer Questions", visibility=False) as answer_questions:
|
298 |
#prompt_tlspc_key = gr.Textbox(label = 'Please provide your TLS Protect Cloud API Key:')
|
299 |
prompt_questions = gr.Textbox(label = 'Input prompt here:', placeholder = "Try something like 'What is the name of the issuing template that has been used to request the most certificates?'")
|
300 |
text_output = gr.Textbox(label = 'Response:')
|
301 |
text_button = gr.Button("Submit")
|
302 |
+
with gr.Tab("Create Graphs", visibility=False) as create_graphs:
|
303 |
prompt_reporting = gr.Textbox(label = 'Input prompt here:', placeholder = "Try something like 'Plot a line chart of certificate issuances over time'")
|
304 |
chart_output = gr.Plot(label = 'Output:')
|
305 |
chart_button = gr.Button("Submit")
|
306 |
|
307 |
+
def load_data_submit(tlspc_api_key, open_api_key):
|
308 |
+
data_return = getData(tlspc_api_key,openai_api_key)
|
309 |
+
if "Error" in data_return:
|
310 |
+
return {api_key_output: data_return}
|
311 |
+
else:
|
312 |
+
return {
|
313 |
+
api_key_output: data_return,
|
314 |
+
answer_questions: gr.update(visible=True),
|
315 |
+
create_graphs: gr.update(visible=True)
|
316 |
+
}
|
317 |
+
|
318 |
+
|
319 |
+
|
320 |
text_button.click(prompt_analyze_questions, inputs=prompt_questions, outputs=text_output)
|
321 |
chart_button.click(prompt_analyze_reporting, inputs=prompt_reporting, outputs=chart_output)
|
322 |
+
load_button.click(load_data_submit, inputs = [tlspc_api_key, openai_api_key],
|
323 |
+
outputs = [api_key_output, answer_questions, create_graphs])
|
324 |
|
325 |
demo.launch()
|