kaitwithkwk commited on
Commit
0e1ebd8
·
verified ·
1 Parent(s): 6418181

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -13,7 +13,7 @@ def reply(user_msg: str, history: list, name: str):
13
  def set_name_and_greet(name: str):
14
  name = name or "friend"
15
  greeting = [
16
- {"role": "assistant", "content": f"Hi, {name}! How can I help you today?"}
17
  ]
18
  return name, greeting # matches the two outputs
19
 
@@ -24,11 +24,11 @@ with gr.Blocks() as demo:
24
  with gr.Column(scale=1):
25
  gr.Markdown("### Enter your name, then click **Set Name**")
26
  name_input = gr.Textbox(placeholder="Type your name here…")
27
- set_btn = gr.Button("Set Name")
28
  gr.Markdown("_After the greeting appears, start chatting →_")
29
 
30
  with gr.Column(scale=2):
31
- chatbot = gr.Chatbot(label="Chat", type="messages")
32
  user_text = gr.Textbox(placeholder="Ask me something…")
33
 
34
  set_btn.click(
@@ -40,7 +40,7 @@ with gr.Blocks() as demo:
40
 
41
  user_text.submit(
42
  fn=reply,
43
- inputs=[user_text, chatbot, name_state], # latest msg, history, saved name
44
  outputs=[chatbot, user_text], # update history & clear input
45
  )
46
 
 
13
  def set_name_and_greet(name: str):
14
  name = name or "friend"
15
  greeting = [
16
+ {"role": "assistant", "content": f"Hi, {name}! How can I help you?"}
17
  ]
18
  return name, greeting # matches the two outputs
19
 
 
24
  with gr.Column(scale=1):
25
  gr.Markdown("### Enter your name, then click **Set Name**")
26
  name_input = gr.Textbox(placeholder="Type your name here…")
27
+ set_btn = gr.Button("Set Name")
28
  gr.Markdown("_After the greeting appears, start chatting →_")
29
 
30
  with gr.Column(scale=2):
31
+ chatbot = gr.Chatbot(label="Chat", type="messages")
32
  user_text = gr.Textbox(placeholder="Ask me something…")
33
 
34
  set_btn.click(
 
40
 
41
  user_text.submit(
42
  fn=reply,
43
+ inputs=[user_text, chatbot, name_state], # latest msg, history, name
44
  outputs=[chatbot, user_text], # update history & clear input
45
  )
46