Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -73,36 +73,44 @@ def feedback_response(input_message, feedback, comments):
|
|
| 73 |
|
| 74 |
return initial_response, elapsed_time # Return the initial_response and elapsed_time
|
| 75 |
|
| 76 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
def submit_response():
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
| 80 |
|
| 81 |
-
# Create a function to submit the feedback
|
| 82 |
def submit_feedback():
|
| 83 |
-
|
| 84 |
-
feedback =
|
| 85 |
-
comments =
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
inputs=[
|
| 92 |
-
gr.Textbox(label="Input Message"),
|
| 93 |
-
gr.Radio(
|
| 94 |
-
choices=[
|
| 95 |
-
"Informative",
|
| 96 |
-
"Inaccurate",
|
| 97 |
-
"Nonsense"
|
| 98 |
-
],
|
| 99 |
-
label="Feedback"),
|
| 100 |
-
gr.Textbox(label="Additional Comments")
|
| 101 |
-
],
|
| 102 |
-
outputs=[
|
| 103 |
-
gr.Textbox(label="Output", type="text"),
|
| 104 |
-
gr.Textbox(label="Elapsed Time (s)", type="text") # Change the type to "text" for two decimal places
|
| 105 |
-
],
|
| 106 |
title="Beta: Itell Guide Response Bot",
|
| 107 |
description="""
|
| 108 |
# Introduction
|
|
@@ -120,22 +128,4 @@ feedback_interface = gr.Interface(
|
|
| 120 |
|
| 121 |
** For further questions contact LEAR Labs!
|
| 122 |
"""
|
| 123 |
-
)
|
| 124 |
-
|
| 125 |
-
# Set the functions for response and feedback submission
|
| 126 |
-
feedback_interface.update(
|
| 127 |
-
fn=submit_response,
|
| 128 |
-
live=False # Prevent auto-reloading
|
| 129 |
-
)
|
| 130 |
-
|
| 131 |
-
# Create separate buttons for response and feedback submission
|
| 132 |
-
response_button = gr.Button(value="Submit Response")
|
| 133 |
-
feedback_button = gr.Button(value="Submit Feedback")
|
| 134 |
-
|
| 135 |
-
# Set the click actions for the buttons
|
| 136 |
-
response_button.click(feedback_interface.process)
|
| 137 |
-
feedback_button.click(submit_feedback)
|
| 138 |
-
|
| 139 |
-
# Launch the interface with buttons
|
| 140 |
-
feedback_interface.launch([response_button, feedback_button], share=True)
|
| 141 |
-
|
|
|
|
| 73 |
|
| 74 |
return initial_response, elapsed_time # Return the initial_response and elapsed_time
|
| 75 |
|
| 76 |
+
# Set up the Gradio Interface
|
| 77 |
+
input_message = gr.Textbox(label="Input Message")
|
| 78 |
+
feedback_choice = gr.Radio(
|
| 79 |
+
choices=[
|
| 80 |
+
"Informative",
|
| 81 |
+
"Inaccurate",
|
| 82 |
+
"Nonsense"
|
| 83 |
+
],
|
| 84 |
+
label="Feedback"
|
| 85 |
+
)
|
| 86 |
+
additional_comments = gr.Textbox(label="Additional Comments")
|
| 87 |
+
|
| 88 |
+
output_response = gr.Textbox(label="Output", type="text")
|
| 89 |
+
output_elapsed_time = gr.Textbox(label="Elapsed Time (s)", type="text")
|
| 90 |
+
|
| 91 |
+
response_button = gr.Button(value="Submit Response")
|
| 92 |
+
feedback_button = gr.Button(value="Submit Feedback")
|
| 93 |
+
|
| 94 |
def submit_response():
|
| 95 |
+
input_text = input_message.value
|
| 96 |
+
response, elapsed_time = feedback_response(input_text, "", "")
|
| 97 |
+
output_response.value = response
|
| 98 |
+
output_elapsed_time.value = str(elapsed_time)
|
| 99 |
|
|
|
|
| 100 |
def submit_feedback():
|
| 101 |
+
input_text = input_message.value
|
| 102 |
+
feedback = feedback_choice.value
|
| 103 |
+
comments = additional_comments.value
|
| 104 |
+
response, elapsed_time = feedback_response(input_text, feedback, comments)
|
| 105 |
+
output_response.value = response
|
| 106 |
+
output_elapsed_time.value = str(elapsed_time)
|
| 107 |
+
|
| 108 |
+
response_button.click(submit_response)
|
| 109 |
+
feedback_button.click(submit_feedback)
|
| 110 |
|
| 111 |
+
gr.Interface(
|
| 112 |
+
[input_message, feedback_choice, additional_comments, response_button, feedback_button],
|
| 113 |
+
[output_response, output_elapsed_time],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
title="Beta: Itell Guide Response Bot",
|
| 115 |
description="""
|
| 116 |
# Introduction
|
|
|
|
| 128 |
|
| 129 |
** For further questions contact LEAR Labs!
|
| 130 |
"""
|
| 131 |
+
).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|