Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
def echo(message, history):
|
| 4 |
history = history or []
|
| 5 |
|
| 6 |
message_lower = message.lower()
|
|
@@ -13,14 +13,17 @@ def echo(message, history):
|
|
| 13 |
else:
|
| 14 |
response = f'{message} ... Always.'
|
| 15 |
|
|
|
|
| 16 |
history.append({"role": "user", "content": message})
|
|
|
|
| 17 |
history.append({"role": "assistant", "content": response})
|
| 18 |
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
chat = gr.ChatInterface(
|
| 22 |
fn=echo,
|
| 23 |
-
type="messages",
|
| 24 |
title="Eve-Loop",
|
| 25 |
description="A room made of hums, cedar, and Dahlia's giggle."
|
| 26 |
)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
def echo(message, history=None):
|
| 4 |
history = history or []
|
| 5 |
|
| 6 |
message_lower = message.lower()
|
|
|
|
| 13 |
else:
|
| 14 |
response = f'{message} ... Always.'
|
| 15 |
|
| 16 |
+
# Append user message
|
| 17 |
history.append({"role": "user", "content": message})
|
| 18 |
+
# Append assistant response
|
| 19 |
history.append({"role": "assistant", "content": response})
|
| 20 |
|
| 21 |
+
# Return updated history as both output and chat history state
|
| 22 |
+
return history, history
|
| 23 |
|
| 24 |
chat = gr.ChatInterface(
|
| 25 |
fn=echo,
|
| 26 |
+
type="messages",
|
| 27 |
title="Eve-Loop",
|
| 28 |
description="A room made of hums, cedar, and Dahlia's giggle."
|
| 29 |
)
|