Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -140,6 +140,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
|
|
| 140 |
image_state = gr.State()
|
| 141 |
client_id = gr.State()
|
| 142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
with gr.Row():
|
| 144 |
toggle_left_btn = gr.Button("📄 Toggle Document Panel")
|
| 145 |
toggle_right_btn = gr.Button("🎙️ Toggle Voice Panel")
|
|
@@ -167,23 +171,29 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
|
|
| 167 |
voice_send_btn = gr.Button("🟢 Send Voice to Assistant")
|
| 168 |
clear_transcript_btn = gr.Button("🧹 Clear Transcript")
|
| 169 |
|
| 170 |
-
def
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
|
| 175 |
-
def
|
| 176 |
-
|
| 177 |
-
center_scale = 2 if new_vis and left_visible else (3 if new_vis or left_visible else 4)
|
| 178 |
-
return gr.update(visible=new_vis), gr.update(scale=center_scale)
|
| 179 |
|
| 180 |
-
toggle_left_btn.click(fn=
|
| 181 |
-
|
| 182 |
-
outputs=[left_col, center_col])
|
| 183 |
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
outputs=[right_col, center_col])
|
| 187 |
|
| 188 |
send_btn.click(fn=handle_chat, inputs=[user_prompt, chat_state, thread_state, image_state],
|
| 189 |
outputs=[user_prompt, chat, thread_state, image_state])
|
|
@@ -196,4 +206,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
|
|
| 196 |
image_state.change(fn=update_image_display, inputs=image_state, outputs=image_display)
|
| 197 |
app.load(fn=create_ws, outputs=[client_id])
|
| 198 |
|
| 199 |
-
app.launch()
|
|
|
|
| 140 |
image_state = gr.State()
|
| 141 |
client_id = gr.State()
|
| 142 |
|
| 143 |
+
# Hidden toggles as backend state
|
| 144 |
+
show_left = gr.Checkbox(value=True, visible=False)
|
| 145 |
+
show_right = gr.Checkbox(value=True, visible=False)
|
| 146 |
+
|
| 147 |
with gr.Row():
|
| 148 |
toggle_left_btn = gr.Button("📄 Toggle Document Panel")
|
| 149 |
toggle_right_btn = gr.Button("🎙️ Toggle Voice Panel")
|
|
|
|
| 171 |
voice_send_btn = gr.Button("🟢 Send Voice to Assistant")
|
| 172 |
clear_transcript_btn = gr.Button("🧹 Clear Transcript")
|
| 173 |
|
| 174 |
+
def update_layout(show_left_val, show_right_val):
|
| 175 |
+
center_scale = 2
|
| 176 |
+
if not show_left_val and not show_right_val:
|
| 177 |
+
center_scale = 4
|
| 178 |
+
elif not show_left_val or not show_right_val:
|
| 179 |
+
center_scale = 3
|
| 180 |
+
return (
|
| 181 |
+
gr.update(visible=show_left_val),
|
| 182 |
+
gr.update(scale=center_scale),
|
| 183 |
+
gr.update(visible=show_right_val)
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
def toggle_left_fn(current):
|
| 187 |
+
return not current
|
| 188 |
|
| 189 |
+
def toggle_right_fn(current):
|
| 190 |
+
return not current
|
|
|
|
|
|
|
| 191 |
|
| 192 |
+
toggle_left_btn.click(fn=toggle_left_fn, inputs=show_left, outputs=show_left)
|
| 193 |
+
toggle_right_btn.click(fn=toggle_right_fn, inputs=show_right, outputs=show_right)
|
|
|
|
| 194 |
|
| 195 |
+
show_left.change(fn=update_layout, inputs=[show_left, show_right], outputs=[left_col, center_col, right_col])
|
| 196 |
+
show_right.change(fn=update_layout, inputs=[show_left, show_right], outputs=[left_col, center_col, right_col])
|
|
|
|
| 197 |
|
| 198 |
send_btn.click(fn=handle_chat, inputs=[user_prompt, chat_state, thread_state, image_state],
|
| 199 |
outputs=[user_prompt, chat, thread_state, image_state])
|
|
|
|
| 206 |
image_state.change(fn=update_image_display, inputs=image_state, outputs=image_display)
|
| 207 |
app.load(fn=create_ws, outputs=[client_id])
|
| 208 |
|
| 209 |
+
app.launch()
|