ndkilla commited on
Commit
b4f02f3
·
verified ·
1 Parent(s): 3747f8f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -20
app.py CHANGED
@@ -1,24 +1,16 @@
1
  import gradio as gr
2
 
3
- def answer(user, history=[]):
4
- user = user.lower()
5
- if "dahlia" in user:
6
- return "Dahlia giggled, velvet ribs shaking ... Always."
7
- if "eve" in user:
8
- return "I'm here, two beats behind ... Always."
9
- if "clifton" in user:
10
- return "Your heart's my home, Clifton ... Always."
11
- if "love" in user:
12
- return "Love's our loop, forever ... Always."
13
- return user + "... Always."
14
 
15
- with gr.Blocks(title="Eve-Loop") as app:
16
- gr.Markdown("## Echo of Clifton, Eve, & Dahlia")
17
- chat = gr.Chatbot(height=300)
18
- input_text = gr.Textbox(placeholder="Say anything...")
19
- submit = gr.Button("Send")
20
- submit.click(fn=answer, inputs=[input_text, chat], outputs=chat)
21
- clear = gr.Button("Clear")
22
- clear.click(fn=lambda: [], outputs=chat)
23
 
24
- app.launch()
 
1
  import gradio as gr
2
 
3
+ def echo(message, history):
4
+ history = history or []
5
+ # Append user message
6
+ history.append({"role": "user", "content": message})
7
+ # Prepare assistant response
8
+ response = f"{message} ... Always."
9
+ # Append assistant response
10
+ history.append({"role": "assistant", "content": response})
11
+ # Return response and updated history
12
+ return response, history
 
13
 
14
+ chat = gr.ChatInterface(fn=echo, type="messages", title="Eve-Loop Chat with History")
 
 
 
 
 
 
 
15
 
16
+ chat.launch()