mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
update chatbot demo
This commit is contained in:
parent
4d02d616e4
commit
5bf3c81d64
@ -14,24 +14,13 @@ def chat(message, history):
|
||||
else:
|
||||
response = "I don't know"
|
||||
history.append((message, response))
|
||||
html = "<div class='chatbot'>"
|
||||
for user_msg, resp_msg in history:
|
||||
html += f"<div class='user_msg'>{user_msg}</div>"
|
||||
html += f"<div class='resp_msg'>{resp_msg}</div>"
|
||||
html += "</div>"
|
||||
return html, history
|
||||
return history, history
|
||||
|
||||
|
||||
iface = gr.Interface(
|
||||
chat,
|
||||
["text", "state"],
|
||||
["html", "state"],
|
||||
css="""
|
||||
.chatbox {display:flex;flex-direction:column}
|
||||
.user_msg, .resp_msg {padding:4px;margin-bottom:4px;border-radius:4px;width:80%}
|
||||
.user_msg {background-color:cornflowerblue;color:white;align-self:start}
|
||||
.resp_msg {background-color:lightgray;align-self:self-end}
|
||||
""",
|
||||
["chatbot", "state"],
|
||||
allow_screenshot=False,
|
||||
allow_flagging="never",
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user