nischaypar commited on
Commit
a0d8cc7
Β·
1 Parent(s): e923eaa

update app

Browse files
Files changed (1) hide show
  1. app.py +15 -18
app.py CHANGED
@@ -9,29 +9,26 @@ def run_search(query, depth, api_key):
9
  except Exception as e:
10
  return f"❌ Error: {str(e)}"
11
 
 
 
 
 
 
12
  with gr.Blocks() as demo:
13
- gr.Markdown("## πŸ” Linkup Web Search Tool\nEnter your query and API key below.")
14
 
15
- with gr.Row():
16
- query_input = gr.Textbox(label="Search Query", placeholder="e.g. AI trends in 2024")
17
- depth_input = gr.Dropdown(label="Search Depth", choices=["standard", "deep"])
18
- api_key_input = gr.Textbox(label="Linkup API Key", type="password", placeholder="Required")
19
 
20
  output = gr.Markdown()
21
- btn = gr.Button("Search", interactive=False) # Start disabled
22
-
23
- btn.click(
24
- fn=run_search,
25
- inputs=[query_input, depth_input, api_key_input],
26
- outputs=output
27
- )
28
 
29
- def enable_submit(q, d, k):
30
- return gr.Button.update(interactive=bool(q and d and k))
31
 
32
- # βœ… Use .input() instead of .change()
33
- query_input.input(enable_submit, [query_input, depth_input, api_key_input], [btn])
34
- depth_input.input(enable_submit, [query_input, depth_input, api_key_input], [btn])
35
- api_key_input.input(enable_submit, [query_input, depth_input, api_key_input], [btn])
36
 
37
  demo.launch()
 
9
  except Exception as e:
10
  return f"❌ Error: {str(e)}"
11
 
12
+ def check_inputs(query, depth, api_key):
13
+ if query and depth and api_key:
14
+ return gr.Button.update(interactive=True)
15
+ return gr.Button.update(interactive=False)
16
+
17
  with gr.Blocks() as demo:
18
+ gr.Markdown("## πŸ” Linkup Web Search Tool")
19
 
20
+ query = gr.Textbox(label="Search Query", placeholder="e.g. AI trends in 2024")
21
+ depth = gr.Dropdown(label="Search Depth", choices=["standard", "deep"])
22
+ api_key = gr.Textbox(label="Linkup API Key", type="password")
 
23
 
24
  output = gr.Markdown()
25
+ search_btn = gr.Button("Search", interactive=False)
 
 
 
 
 
 
26
 
27
+ search_btn.click(run_search, inputs=[query, depth, api_key], outputs=output)
 
28
 
29
+ # Dynamically update button interactivity
30
+ query.input(check_inputs, [query, depth, api_key], [search_btn])
31
+ depth.input(check_inputs, [query, depth, api_key], [search_btn])
32
+ api_key.input(check_inputs, [query, depth, api_key], [search_btn])
33
 
34
  demo.launch()