Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,8 +7,6 @@ import time
|
|
7 |
import json
|
8 |
|
9 |
# Authenticate and authorize with Google Sheets
|
10 |
-
#creds, _ = default()
|
11 |
-
#gc = gspread.authorize(creds)
|
12 |
gc = gspread.service_account(filename='botresponse-6f1a8c749aa0.json')
|
13 |
|
14 |
# Specify your Google Sheets credentials, sheet_id, and worksheet_name
|
@@ -52,6 +50,12 @@ def feedback_response(input_message, feedback, comments):
|
|
52 |
response = 'Inaccurate'
|
53 |
elif feedback == 'Nonsense':
|
54 |
response = 'Nonsense'
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
else:
|
56 |
response = 'NA'
|
57 |
|
@@ -59,7 +63,7 @@ def feedback_response(input_message, feedback, comments):
|
|
59 |
sh = gc.open_by_key(sheet_id)
|
60 |
worksheet = sh.worksheet(worksheet_name)
|
61 |
|
62 |
-
thankyou = "Thank you for your feedback. Your response and feedback
|
63 |
# Append the data to the worksheet only if comments have a value
|
64 |
if comments:
|
65 |
# Create a DataFrame from the response and additional comments
|
@@ -68,7 +72,6 @@ def feedback_response(input_message, feedback, comments):
|
|
68 |
# Append the data to the worksheet
|
69 |
worksheet.append_rows(df.values.tolist())
|
70 |
initial_response = thankyou
|
71 |
-
|
72 |
|
73 |
return initial_response, elapsed_time # Return the initial_response and elapsed_time
|
74 |
|
@@ -77,37 +80,47 @@ feedback_interface = gr.Interface(
|
|
77 |
fn=feedback_response,
|
78 |
inputs=[
|
79 |
gr.Textbox(label="Input Message"),
|
80 |
-
gr.
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
gr.Textbox(label="Additional Comments")
|
88 |
],
|
89 |
outputs=[
|
90 |
gr.Textbox(label="Output", type="text"),
|
91 |
-
gr.Textbox(label="Elapsed Time (s)", type="text")
|
92 |
],
|
93 |
title="Beta: Itell Guide Response Bot",
|
94 |
description="""
|
95 |
# Introduction
|
96 |
This is an interface to test iTELL's guide on the side. Please be aware that responses can take up to 20 seconds
|
97 |
-
|
98 |
# Step by Step Introduction
|
99 |
1. Place a question in the input message textbox
|
100 |
2. Wait roughly 10 ~ 20 seconds for the response and elapsed time to come out on the right
|
101 |
-
3. After looking at the results, click on the feedback options that best
|
102 |
4. After choosing the best option, write down additional comments for more feedback
|
103 |
5. Press submit again and wait for the output to come out again for your feedback to be submitted
|
104 |
-
6. Once the "Thank you for your feedback. Your response and feedback
|
105 |
-
|
106 |
-
**
|
107 |
-
|
108 |
-
** For further questions contact LEAR Labs!
|
109 |
"""
|
110 |
)
|
111 |
|
112 |
# Launch the interface
|
113 |
-
feedback_interface.launch()
|
|
|
7 |
import json
|
8 |
|
9 |
# Authenticate and authorize with Google Sheets
|
|
|
|
|
10 |
gc = gspread.service_account(filename='botresponse-6f1a8c749aa0.json')
|
11 |
|
12 |
# Specify your Google Sheets credentials, sheet_id, and worksheet_name
|
|
|
50 |
response = 'Inaccurate'
|
51 |
elif feedback == 'Nonsense':
|
52 |
response = 'Nonsense'
|
53 |
+
elif feedback == 'Good':
|
54 |
+
response = 'Good'
|
55 |
+
elif feedback == 'Bad':
|
56 |
+
response = 'Bad'
|
57 |
+
elif feedback == 'Inappropriate':
|
58 |
+
response = 'Inappropriate'
|
59 |
else:
|
60 |
response = 'NA'
|
61 |
|
|
|
63 |
sh = gc.open_by_key(sheet_id)
|
64 |
worksheet = sh.worksheet(worksheet_name)
|
65 |
|
66 |
+
thankyou = "Thank you for your feedback. Your response and feedback have been recorded!"
|
67 |
# Append the data to the worksheet only if comments have a value
|
68 |
if comments:
|
69 |
# Create a DataFrame from the response and additional comments
|
|
|
72 |
# Append the data to the worksheet
|
73 |
worksheet.append_rows(df.values.tolist())
|
74 |
initial_response = thankyou
|
|
|
75 |
|
76 |
return initial_response, elapsed_time # Return the initial_response and elapsed_time
|
77 |
|
|
|
80 |
fn=feedback_response,
|
81 |
inputs=[
|
82 |
gr.Textbox(label="Input Message"),
|
83 |
+
gr.Row([
|
84 |
+
gr.ButtonGroup(
|
85 |
+
choices=[
|
86 |
+
"Good",
|
87 |
+
"Bad",
|
88 |
+
"Inappropriate"
|
89 |
+
],
|
90 |
+
label="Feedback (Top Row)",
|
91 |
+
type="radio"
|
92 |
+
),
|
93 |
+
gr.ButtonGroup(
|
94 |
+
choices=[
|
95 |
+
"Informative",
|
96 |
+
"Inaccurate",
|
97 |
+
"Nonsense"
|
98 |
+
],
|
99 |
+
label="Feedback (Bottom Row)",
|
100 |
+
type="radio"
|
101 |
+
)
|
102 |
+
]),
|
103 |
gr.Textbox(label="Additional Comments")
|
104 |
],
|
105 |
outputs=[
|
106 |
gr.Textbox(label="Output", type="text"),
|
107 |
+
gr.Textbox(label="Elapsed Time (s)", type="text")
|
108 |
],
|
109 |
title="Beta: Itell Guide Response Bot",
|
110 |
description="""
|
111 |
# Introduction
|
112 |
This is an interface to test iTELL's guide on the side. Please be aware that responses can take up to 20 seconds
|
|
|
113 |
# Step by Step Introduction
|
114 |
1. Place a question in the input message textbox
|
115 |
2. Wait roughly 10 ~ 20 seconds for the response and elapsed time to come out on the right
|
116 |
+
3. After looking at the results, click on the feedback options that best describe the output: Good, Bad, Inappropriate, Informative, Inaccurate, Nonsense
|
117 |
4. After choosing the best option, write down additional comments for more feedback
|
118 |
5. Press submit again and wait for the output to come out again for your feedback to be submitted
|
119 |
+
6. Once the "Thank you for your feedback. Your response and feedback have been recorded!" message is shown, you are done
|
120 |
+
** DISCLAIMER: You have to type an input message, click on the feedback buttons, and type in additional comments for your responses to be recorded
|
121 |
+
** For further questions, contact LEAR Labs!
|
|
|
|
|
122 |
"""
|
123 |
)
|
124 |
|
125 |
# Launch the interface
|
126 |
+
feedback_interface.launch()
|