Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -200,14 +200,19 @@ with gr.Blocks(css=css) as demo:
|
|
| 200 |
history_state = gr.State([])
|
| 201 |
last_message_state = gr.State("")
|
| 202 |
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
|
| 213 |
|
|
|
|
| 200 |
history_state = gr.State([])
|
| 201 |
last_message_state = gr.State("")
|
| 202 |
|
| 203 |
+
def user_interaction(message, history, api_key, max_tokens, top_p, temperature):
|
| 204 |
+
loading_message = history + [(message, "Loading...", "You", "P-ALPLE", sessions[api_key]["avatar"], ASSISTANT_PIC_PATH)]
|
| 205 |
+
yield render_message(loading_message), loading_message, ""
|
| 206 |
+
|
| 207 |
+
assistant_response = ""
|
| 208 |
+
for partial_reply in respond(message, api_key, max_tokens, top_p, temperature):
|
| 209 |
+
assistant_response = partial_reply # Accumulate streamed response
|
| 210 |
+
partial_history = history + [(message, assistant_response, "You", "P-ALPLE", sessions[api_key]["avatar"], ASSISTANT_PIC_PATH)]
|
| 211 |
+
yield render_message(partial_history), partial_history, ""
|
| 212 |
+
|
| 213 |
+
final_history = history + [(message, assistant_response, "You", "P-ALPLE", sessions[api_key]["avatar"], ASSISTANT_PIC_PATH)]
|
| 214 |
+
yield render_message(final_history), final_history, ""
|
| 215 |
+
|
| 216 |
|
| 217 |
|
| 218 |
|