Spaces:
Sleeping
Sleeping
add default save in respond func
Browse files- app_drive.py +12 -8
app_drive.py
CHANGED
@@ -62,11 +62,12 @@ def respond(message, chat_history):
|
|
62 |
time_diff = time.time() - start_time
|
63 |
model_response = output
|
64 |
input_question = question
|
65 |
-
|
|
|
66 |
bot_message = output
|
67 |
chat_history.append((message, bot_message))
|
68 |
|
69 |
-
time.sleep(
|
70 |
return " ", chat_history
|
71 |
|
72 |
############################# Feedback Specific functions #############################
|
@@ -167,24 +168,26 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="emerald", neutral_hue="slate"))
|
|
167 |
feedback_text = gr.Textbox(lines=1, label="Additional comments on the current response...")
|
168 |
|
169 |
|
170 |
-
#
|
171 |
msg.submit(
|
172 |
fn = respond,
|
173 |
inputs = [msg, chatbot],
|
174 |
outputs = [msg, chatbot],
|
175 |
queue = True)
|
176 |
|
|
|
|
|
177 |
msg.submit(
|
178 |
fn = default_feedback,
|
179 |
outputs=[feedback_radio],
|
180 |
queue = True
|
181 |
)
|
182 |
|
183 |
-
#
|
184 |
-
chatbot.change(
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
|
189 |
# Change whenever some feedback is given (Numeric or Text)
|
190 |
feedback_radio.change(
|
@@ -198,6 +201,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="emerald", neutral_hue="slate"))
|
|
198 |
queue=True
|
199 |
)
|
200 |
|
|
|
201 |
feedback_text.submit(
|
202 |
fn=default_text,
|
203 |
outputs=[feedback_text],
|
|
|
62 |
time_diff = time.time() - start_time
|
63 |
model_response = output
|
64 |
input_question = question
|
65 |
+
save_text_feedback(feedback="Default Conversation Save!!!") # Upload chatlog to drive after every response irrespective of feedback
|
66 |
+
|
67 |
bot_message = output
|
68 |
chat_history.append((message, bot_message))
|
69 |
|
70 |
+
time.sleep(1) # Pause for a second to avoid overloading
|
71 |
return " ", chat_history
|
72 |
|
73 |
############################# Feedback Specific functions #############################
|
|
|
168 |
feedback_text = gr.Textbox(lines=1, label="Additional comments on the current response...")
|
169 |
|
170 |
|
171 |
+
# Get a response when a message is submitted to the chatbot
|
172 |
msg.submit(
|
173 |
fn = respond,
|
174 |
inputs = [msg, chatbot],
|
175 |
outputs = [msg, chatbot],
|
176 |
queue = True)
|
177 |
|
178 |
+
|
179 |
+
# Set default feedback to None after a message is submitted
|
180 |
msg.submit(
|
181 |
fn = default_feedback,
|
182 |
outputs=[feedback_radio],
|
183 |
queue = True
|
184 |
)
|
185 |
|
186 |
+
# Save Chat whenever there is some change in the chatbot
|
187 |
+
# chatbot.change(
|
188 |
+
# fn = save_feedback,
|
189 |
+
# inputs=[feedback_radio],
|
190 |
+
# queue = True)
|
191 |
|
192 |
# Change whenever some feedback is given (Numeric or Text)
|
193 |
feedback_radio.change(
|
|
|
201 |
queue=True
|
202 |
)
|
203 |
|
204 |
+
# Clear the text feedback after it is submitted
|
205 |
feedback_text.submit(
|
206 |
fn=default_text,
|
207 |
outputs=[feedback_text],
|