nischaypar commited on
Commit
e923eaa
·
1 Parent(s): 86537bd

update app

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -4,9 +4,6 @@ from tool import LinkupSearchTool
4
  tool = LinkupSearchTool()
5
 
6
  def run_search(query, depth, api_key):
7
- if not query or not depth or not api_key:
8
- return "❌ All fields are required."
9
-
10
  try:
11
  return tool.forward(query=query, depth=depth, api_key=api_key)
12
  except Exception as e:
@@ -17,11 +14,11 @@ with gr.Blocks() as demo:
17
 
18
  with gr.Row():
19
  query_input = gr.Textbox(label="Search Query", placeholder="e.g. AI trends in 2024")
20
- depth_input = gr.Dropdown(label="Search Depth", choices=["standard", "deep"], value="standard") # Added default value
21
- api_key_input = gr.Textbox(label="Linkup API Key", type="password")
22
 
23
  output = gr.Markdown()
24
- btn = gr.Button("Search", interactive=False) # Disabled by default
25
 
26
  btn.click(
27
  fn=run_search,
@@ -30,11 +27,11 @@ with gr.Blocks() as demo:
30
  )
31
 
32
  def enable_submit(q, d, k):
33
- return gr.Button.update(interactive=bool(q.strip() and d and k.strip())) # Check for non-empty strings
34
 
35
- # Update button state when any input changes
36
- query_input.change(enable_submit, [query_input, depth_input, api_key_input], [btn])
37
- depth_input.change(enable_submit, [query_input, depth_input, api_key_input], [btn])
38
- api_key_input.change(enable_submit, [query_input, depth_input, api_key_input], [btn])
39
 
40
- demo.launch()
 
4
  tool = LinkupSearchTool()
5
 
6
  def run_search(query, depth, api_key):
 
 
 
7
  try:
8
  return tool.forward(query=query, depth=depth, api_key=api_key)
9
  except Exception as e:
 
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,
 
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()