jcho02 commited on
Commit
1e4655b
·
1 Parent(s): 406203d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -46
app.py CHANGED
@@ -73,64 +73,69 @@ def feedback_response(input_message, feedback, comments):
73
 
74
  return initial_response, elapsed_time # Return the initial_response and elapsed_time
75
 
76
- # Create a Blocks context for the interface
77
- with gr.Blocks() as feedback_interface:
78
- # Set up the Gradio Interface
79
- gr.Interface(
80
- fn=feedback_response,
81
- inputs=[
82
- gr.Textbox(label="Input Message"),
83
- gr.Radio(
84
- choices=[
85
- "Informative",
86
- "Inaccurate",
87
- "Nonsense"
88
- ],
89
- label="Feedback"),
90
- gr.Textbox(label="Additional Comments")
91
- ],
92
- outputs=[
93
- gr.Textbox(label="Output", type="text"),
94
- gr.Textbox(label="Elapsed Time (s)", type="text") # Change the type to "text" for two decimal places
95
- ],
96
- title="Beta: Itell Guide Response Bot",
97
- description="""
98
- # Introduction
99
- This is an interface to test iTELL's guide on the side. Please be aware that responses can take up to 20 seconds
100
-
101
- # Step by Step Introduction
102
- 1. Place a question in the input message textbox
103
- 2. Wait roughly 10 ~ 20 seconds for the response and elapsed time to come out on the right
104
- 3. After looking at the results, select the feedback option that best describes the output: Informative, Inaccurate, Nonsense
105
- 4. After choosing the best option, write down additional comments for more feedback
106
- 5. Press submit again and wait for the output to come out again for your feedback to be submitted
107
- 6. Once the "Thank you for your feedback. Your response and feedback have been recorded!" message is shown, you are done
108
-
109
- ** DISCLAIMER: You have to type an input message, select a feedback option, and type in additional comments for your responses to be recorded
110
-
111
- ** For further questions contact LEAR Labs!
112
- """
113
- )
114
-
115
- # Create a Blocks context for the buttons
116
- with gr.Blocks() as buttons:
117
- response_button = gr.Button(value="Submit Response")
118
- feedback_button = gr.Button(value="Submit Feedback")
119
-
120
- # Define a function for response and feedback submission
121
  def submit_response():
122
  input_message = feedback_interface.inputs[0].value
123
  feedback_interface.outputs[0].value, feedback_interface.outputs[1].value = feedback_response(input_message, "", "")
124
 
 
125
  def submit_feedback():
126
  input_message = feedback_interface.inputs[0].value
127
  feedback = feedback_interface.inputs[1].value
128
  comments = feedback_interface.inputs[2].value
129
  feedback_interface.outputs[0].value, feedback_interface.outputs[1].value = feedback_response(input_message, feedback, comments)
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  # Set the click actions for the buttons
132
- response_button.click(submit_response)
133
  feedback_button.click(submit_feedback)
134
 
135
  # Launch the interface with buttons
136
  feedback_interface.launch([response_button, feedback_button], share=True)
 
 
73
 
74
  return initial_response, elapsed_time # Return the initial_response and elapsed_time
75
 
76
+ # Create a function to submit the response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  def submit_response():
78
  input_message = feedback_interface.inputs[0].value
79
  feedback_interface.outputs[0].value, feedback_interface.outputs[1].value = feedback_response(input_message, "", "")
80
 
81
+ # Create a function to submit the feedback
82
  def submit_feedback():
83
  input_message = feedback_interface.inputs[0].value
84
  feedback = feedback_interface.inputs[1].value
85
  comments = feedback_interface.inputs[2].value
86
  feedback_interface.outputs[0].value, feedback_interface.outputs[1].value = feedback_response(input_message, feedback, comments)
87
 
88
+ # Set up the Gradio Interface
89
+ feedback_interface = gr.Interface(
90
+ fn=None, # Set to None initially
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
109
+ This is an interface to test iTELL's guide on the side. Please be aware that responses can take up to 20 seconds
110
+
111
+ # Step by Step Introduction
112
+ 1. Place a question in the input message textbox
113
+ 2. Wait roughly 10 ~ 20 seconds for the response and elapsed time to come out on the right
114
+ 3. After looking at the results, select the feedback option that best describes the output: Informative, Inaccurate, Nonsense
115
+ 4. After choosing the best option, write down additional comments for more feedback
116
+ 5. Press submit again and wait for the output to come out again for your feedback to be submitted
117
+ 6. Once the "Thank you for your feedback. Your response and feedback have been recorded!" message is shown, you are done
118
+
119
+ ** DISCLAIMER: You have to type an input message, select a feedback option, and type in additional comments for your responses to be recorded
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
+