basantyahya commited on
Commit
a2d2939
Β·
verified Β·
1 Parent(s): b275102

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -51,10 +51,10 @@ custom_js = """
51
  def google_search_query(question):
52
  try:
53
  # πŸ”’ Bulletproof input normalization
54
- # question = "" if question is None else str(question)
55
- # question = question.strip()
56
 
57
- if question is None:
58
  return "Please type a question above πŸ‘†", ""
59
 
60
  google_search_tool = Tool(google_search=GoogleSearch())
@@ -112,12 +112,17 @@ with gr.Blocks(css=custom_css) as app:
112
  # Button click
113
  search_btn.click(
114
  fn=google_search_query,
115
- inputs=question,
116
  outputs=[ai_output, search_output],
117
  js=custom_js
118
  )
119
 
120
-
 
 
 
 
 
121
 
122
  # =========================================================
123
  # Launch (HF SAFE)
 
51
  def google_search_query(question):
52
  try:
53
  # πŸ”’ Bulletproof input normalization
54
+ question = "" if question is None else str(question)
55
+ question = question.strip()
56
 
57
+ if question == "":
58
  return "Please type a question above πŸ‘†", ""
59
 
60
  google_search_tool = Tool(google_search=GoogleSearch())
 
112
  # Button click
113
  search_btn.click(
114
  fn=google_search_query,
115
+ inputs=[question],
116
  outputs=[ai_output, search_output],
117
  js=custom_js
118
  )
119
 
120
+ # Enter key submit
121
+ question.submit(
122
+ fn=google_search_query,
123
+ inputs=[question],
124
+ outputs=[ai_output, search_output],
125
+ )
126
 
127
  # =========================================================
128
  # Launch (HF SAFE)