Redmind commited on
Commit
ae63ea7
·
verified ·
1 Parent(s): 4aa81c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -527,7 +527,7 @@ def answer_question(user_question, chatbot, audio=None):
527
  except sr.RequestError:
528
  user_question = "Could not request results from Google Speech Recognition service."
529
 
530
- #while iterations < max_iterations:
531
 
532
  """if "send email to" in user_question:
533
  email_match = re.search(r"send email to ([\w\.-]+@[\w\.-]+)", user_question)
@@ -543,9 +543,9 @@ def answer_question(user_question, chatbot, audio=None):
543
  response_text = response.get("output", "")
544
  else:
545
  response_text = response
546
- #if "invalid" not in response_text.lower():
547
- # break
548
- #iterations += 1
549
 
550
  if iterations == max_iterations:
551
  return "The agent could not generate a valid response within the iteration limit."
@@ -713,21 +713,23 @@ with gr.Blocks(css=css) as demo:
713
 
714
 
715
  with gr.Row():
716
- with gr.Column(scale=1):
717
  message = gr.Textbox(show_label=False, container=False, placeholder="Please enter your question")
718
  with gr.Row():
719
  feedback_textbox = gr.Textbox(visible=False, show_label=False,container=False, placeholder = "Please enter your feedback.")
720
  submit_feedback_button = gr.Button("Submit Feedback", visible=False, elem_classes="gr-button")
721
- with gr.Column(scale=2):
722
  with gr.Row():
723
- audio_input = gr.Audio(sources=["microphone"], show_label=False, container=False,
724
  waveform_options=gr.WaveformOptions(show_controls=False))
725
  button = gr.Button("Submit", elem_classes="gr-button")
726
  gr.ClearButton(message, elem_classes="gr-button")
727
 
728
- button.click(answer_question, [message, chatbot, audio_input], [chatbot])
 
729
 
730
- message.submit(answer_question, [message, chatbot, audio_input], [chatbot])
 
731
  message.submit(lambda x: gr.update(value=""), None, [message], queue=False)
732
  button.click(lambda x: gr.update(value=''), [], [message])
733
 
 
527
  except sr.RequestError:
528
  user_question = "Could not request results from Google Speech Recognition service."
529
 
530
+ while iterations < max_iterations:
531
 
532
  """if "send email to" in user_question:
533
  email_match = re.search(r"send email to ([\w\.-]+@[\w\.-]+)", user_question)
 
543
  response_text = response.get("output", "")
544
  else:
545
  response_text = response
546
+ if "invalid" not in response_text.lower():
547
+ break
548
+ iterations += 1
549
 
550
  if iterations == max_iterations:
551
  return "The agent could not generate a valid response within the iteration limit."
 
713
 
714
 
715
  with gr.Row():
716
+ with gr.Column(scale=2):
717
  message = gr.Textbox(show_label=False, container=False, placeholder="Please enter your question")
718
  with gr.Row():
719
  feedback_textbox = gr.Textbox(visible=False, show_label=False,container=False, placeholder = "Please enter your feedback.")
720
  submit_feedback_button = gr.Button("Submit Feedback", visible=False, elem_classes="gr-button")
721
+ with gr.Column(scale=1):
722
  with gr.Row():
723
+ #audio_input = gr.Audio(sources=["microphone"], show_label=False, container=False,
724
  waveform_options=gr.WaveformOptions(show_controls=False))
725
  button = gr.Button("Submit", elem_classes="gr-button")
726
  gr.ClearButton(message, elem_classes="gr-button")
727
 
728
+ #button.click(answer_question, [message, chatbot, audio_input], [chatbot])
729
+ button.click(answer_question, [message, chatbot], [chatbot])
730
 
731
+ message.submit(answer_question, [message, chatbot], [chatbot])
732
+ #message.submit(answer_question, [message, chatbot, audio_input], [chatbot])
733
  message.submit(lambda x: gr.update(value=""), None, [message], queue=False)
734
  button.click(lambda x: gr.update(value=''), [], [message])
735