Update app.py
Browse files
app.py
CHANGED
@@ -184,4 +184,26 @@ with gr.Blocks() as demo:
|
|
184 |
response = ""
|
185 |
for r in gen:
|
186 |
response = r # In a streaming scenario, you might update the UI incrementally.
|
187 |
-
history.append((message,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
response = ""
|
185 |
for r in gen:
|
186 |
response = r # In a streaming scenario, you might update the UI incrementally.
|
187 |
+
history.append((message, response))
|
188 |
+
return history, history
|
189 |
+
|
190 |
+
# Trigger the chat step on button click or when submitting the textbox.
|
191 |
+
send_button.click(
|
192 |
+
chat_step,
|
193 |
+
inputs=[user_input, state, system_prompt, max_tokens_slider, temperature_slider, top_p_slider],
|
194 |
+
outputs=[chatbot, state],
|
195 |
+
)
|
196 |
+
user_input.submit(
|
197 |
+
chat_step,
|
198 |
+
inputs=[user_input, state, system_prompt, max_tokens_slider, temperature_slider, top_p_slider],
|
199 |
+
outputs=[chatbot, state],
|
200 |
+
)
|
201 |
+
|
202 |
+
# Clear memory: resets both the chatbot display and the state.
|
203 |
+
def clear_history():
|
204 |
+
return [], []
|
205 |
+
|
206 |
+
clear_button.click(clear_history, inputs=[], outputs=[chatbot, state])
|
207 |
+
|
208 |
+
if __name__ == "__main__":
|
209 |
+
demo.launch()
|