Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -162,18 +162,10 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid
|
|
| 162 |
last_message_state = gr.State("")
|
| 163 |
|
| 164 |
def user_interaction(message, history, api_key, max_tokens, top_p, temperature):
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
new_message_html += f"{message}</div><br>"
|
| 170 |
-
|
| 171 |
-
new_message_html += f"<div style='display: flex; align-items: center; margin-bottom: 10px;'>"
|
| 172 |
-
new_message_html += f"<img src='{ASSISTANT_PIC_PATH}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
|
| 173 |
-
new_message_html += f"{assistant_reply}</div><br>"
|
| 174 |
-
|
| 175 |
-
return gr.update(value=new_message_html), history, "", message
|
| 176 |
-
|
| 177 |
|
| 178 |
def regenerate_response(history, last_message, max_tokens, top_p, temperature):
|
| 179 |
return "", []
|
|
@@ -189,12 +181,12 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid
|
|
| 189 |
return render_message(history), history
|
| 190 |
|
| 191 |
msg_input.submit(user_interaction,
|
| 192 |
-
|
| 193 |
-
|
| 194 |
|
| 195 |
send_btn.click(user_interaction,
|
| 196 |
-
|
| 197 |
-
|
| 198 |
|
| 199 |
regen_btn.click(clear_history,
|
| 200 |
inputs=[api_key_input],
|
|
|
|
| 162 |
last_message_state = gr.State("")
|
| 163 |
|
| 164 |
def user_interaction(message, history, api_key, max_tokens, top_p, temperature):
|
| 165 |
+
history, assistant_reply = respond(message, api_key, max_tokens, top_p, temperature)
|
| 166 |
+
history.append((message, assistant_reply, "You", "P-ALPLE", USER_PIC_PATH, ASSISTANT_PIC_PATH))
|
| 167 |
+
full_history_html = render_message(history)
|
| 168 |
+
return full_history_html, history, "", message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
|
| 170 |
def regenerate_response(history, last_message, max_tokens, top_p, temperature):
|
| 171 |
return "", []
|
|
|
|
| 181 |
return render_message(history), history
|
| 182 |
|
| 183 |
msg_input.submit(user_interaction,
|
| 184 |
+
inputs=[msg_input, history_state, api_key_input, max_tokens, top_p, temperature],
|
| 185 |
+
outputs=[chatbot_output, history_state, msg_input, last_message_state])
|
| 186 |
|
| 187 |
send_btn.click(user_interaction,
|
| 188 |
+
inputs=[msg_input, history_state, api_key_input, max_tokens, top_p, temperature],
|
| 189 |
+
outputs=[chatbot_output, history_state, msg_input, last_message_state])
|
| 190 |
|
| 191 |
regen_btn.click(clear_history,
|
| 192 |
inputs=[api_key_input],
|