Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -70,25 +70,29 @@ def render_message(history):
|
|
| 70 |
|
| 71 |
return messages_html
|
| 72 |
|
| 73 |
-
with gr.Blocks() as demo:
|
| 74 |
-
gr.Markdown("## P-MSQ Chat Interface with Profile Pictures")
|
| 75 |
gr.Markdown("""
|
| 76 |
Welcome to the **P-MSQ** (Messaging Service Query) chat interface!
|
| 77 |
You are interacting with a friendly AI chatbot that can assist you in various situations.
|
| 78 |
Use the text input box below to start chatting.
|
| 79 |
""")
|
| 80 |
|
| 81 |
-
|
| 82 |
-
chatbot_output = gr.HTML()
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
system_message = gr.Textbox(value="You are P-MSQ (Messaging Service Query), a friendly AI Chatbot that can help in any situations.", label="System message")
|
| 90 |
|
| 91 |
-
gr.Markdown("### Settings")
|
|
|
|
| 92 |
max_tokens = gr.Slider(minimum=1, maximum=2048, value=1024, step=1, label="Max new tokens")
|
| 93 |
top_p = gr.Slider(minimum=0, maximum=2, value=0.8, step=0.1, label="Top P")
|
| 94 |
temperature = gr.Slider(minimum=0.1, maximum=1, value=0.7, step=0.1, label="Temperature")
|
|
@@ -106,6 +110,10 @@ with gr.Blocks() as demo:
|
|
| 106 |
return render_message(history), history
|
| 107 |
return render_message(history), history
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
send_btn.click(user_interaction,
|
| 110 |
inputs=[msg_input, history_state, system_message, max_tokens, top_p, temperature],
|
| 111 |
outputs=[chatbot_output, history_state, msg_input, last_message_state])
|
|
@@ -114,5 +122,9 @@ with gr.Blocks() as demo:
|
|
| 114 |
inputs=[history_state, last_message_state, system_message, max_tokens, top_p, temperature],
|
| 115 |
outputs=[chatbot_output, history_state])
|
| 116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
if __name__ == "__main__":
|
| 118 |
demo.launch()
|
|
|
|
| 70 |
|
| 71 |
return messages_html
|
| 72 |
|
| 73 |
+
with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto;}") as demo:
|
| 74 |
+
gr.Markdown("## P-MSQ Chat Interface with Profile Pictures")
|
| 75 |
gr.Markdown("""
|
| 76 |
Welcome to the **P-MSQ** (Messaging Service Query) chat interface!
|
| 77 |
You are interacting with a friendly AI chatbot that can assist you in various situations.
|
| 78 |
Use the text input box below to start chatting.
|
| 79 |
""")
|
| 80 |
|
| 81 |
+
chatbot_output = gr.HTML(elem_id="chatbox", label="Chat History")
|
|
|
|
| 82 |
|
| 83 |
+
msg_input = gr.Textbox(
|
| 84 |
+
show_label=False,
|
| 85 |
+
placeholder="Type your message and press Enter...",
|
| 86 |
+
lines=2
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
send_btn = gr.Button("Send")
|
| 90 |
+
regen_btn = gr.Button("Regenerate")
|
| 91 |
|
| 92 |
system_message = gr.Textbox(value="You are P-MSQ (Messaging Service Query), a friendly AI Chatbot that can help in any situations.", label="System message")
|
| 93 |
|
| 94 |
+
gr.Markdown("### Settings")
|
| 95 |
+
|
| 96 |
max_tokens = gr.Slider(minimum=1, maximum=2048, value=1024, step=1, label="Max new tokens")
|
| 97 |
top_p = gr.Slider(minimum=0, maximum=2, value=0.8, step=0.1, label="Top P")
|
| 98 |
temperature = gr.Slider(minimum=0.1, maximum=1, value=0.7, step=0.1, label="Temperature")
|
|
|
|
| 110 |
return render_message(history), history
|
| 111 |
return render_message(history), history
|
| 112 |
|
| 113 |
+
msg_input.submit(user_interaction,
|
| 114 |
+
inputs=[msg_input, history_state, system_message, max_tokens, top_p, temperature],
|
| 115 |
+
outputs=[chatbot_output, history_state, msg_input, last_message_state])
|
| 116 |
+
|
| 117 |
send_btn.click(user_interaction,
|
| 118 |
inputs=[msg_input, history_state, system_message, max_tokens, top_p, temperature],
|
| 119 |
outputs=[chatbot_output, history_state, msg_input, last_message_state])
|
|
|
|
| 122 |
inputs=[history_state, last_message_state, system_message, max_tokens, top_p, temperature],
|
| 123 |
outputs=[chatbot_output, history_state])
|
| 124 |
|
| 125 |
+
with gr.Row():
|
| 126 |
+
send_btn
|
| 127 |
+
regen_btn
|
| 128 |
+
|
| 129 |
if __name__ == "__main__":
|
| 130 |
demo.launch()
|