Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
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 |
-
|
547 |
-
|
548 |
-
|
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=
|
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=
|
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
|
|
|
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 |
|