Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 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
|
| 28 |
gr.Markdown("_After the greeting appears, start chatting →_")
|
| 29 |
|
| 30 |
with gr.Column(scale=2):
|
| 31 |
-
chatbot
|
| 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,
|
| 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 |
|