Update app.py
Browse files
app.py
CHANGED
@@ -85,7 +85,6 @@ async def websocket_handler(websocket, path):
|
|
85 |
|
86 |
async for message in websocket:
|
87 |
try:
|
88 |
-
# Parse message as simple text (no JSON)
|
89 |
parts = message.split('|', 1)
|
90 |
if len(parts) == 2:
|
91 |
username, content = parts
|
@@ -136,7 +135,12 @@ def create_gradio_interface(initial_username):
|
|
136 |
with gr.Column(scale=3):
|
137 |
chat_display = gr.Code(label="Chat History", language="markdown", lines=15, elem_classes=["chat-box"])
|
138 |
with gr.Column(scale=1):
|
139 |
-
user_list = gr.Dropdown(
|
|
|
|
|
|
|
|
|
|
|
140 |
|
141 |
with gr.Row():
|
142 |
username_input = gr.Textbox(label="Your Name", value=initial_username)
|
@@ -169,8 +173,7 @@ def create_gradio_interface(initial_username):
|
|
169 |
send_button.click(
|
170 |
fn=update_chat,
|
171 |
inputs=[username_input, message_input, chat_state],
|
172 |
-
outputs=[chat_display, user_list]
|
173 |
-
_js="() => ['', document.getElementById('message_input').value, document.getElementById('chat_display').value]"
|
174 |
)
|
175 |
message_input.submit(
|
176 |
fn=update_chat,
|
|
|
85 |
|
86 |
async for message in websocket:
|
87 |
try:
|
|
|
88 |
parts = message.split('|', 1)
|
89 |
if len(parts) == 2:
|
90 |
username, content = parts
|
|
|
135 |
with gr.Column(scale=3):
|
136 |
chat_display = gr.Code(label="Chat History", language="markdown", lines=15, elem_classes=["chat-box"])
|
137 |
with gr.Column(scale=1):
|
138 |
+
user_list = gr.Dropdown(
|
139 |
+
label="Switch User",
|
140 |
+
choices=get_user_list(chat_state.value),
|
141 |
+
value=initial_username,
|
142 |
+
allow_custom_value=True # Let the initial username stick! 🎯
|
143 |
+
)
|
144 |
|
145 |
with gr.Row():
|
146 |
username_input = gr.Textbox(label="Your Name", value=initial_username)
|
|
|
173 |
send_button.click(
|
174 |
fn=update_chat,
|
175 |
inputs=[username_input, message_input, chat_state],
|
176 |
+
outputs=[chat_display, user_list]
|
|
|
177 |
)
|
178 |
message_input.submit(
|
179 |
fn=update_chat,
|