Spaces:
Running
on
Zero
Running
on
Zero
fix
Browse files
app.py
CHANGED
@@ -54,7 +54,8 @@ with gr.Blocks() as demo:
|
|
54 |
with gr.Row():
|
55 |
gr_radio_mode = gr.Radio(label="Select Mode", choices=["Real-Time Commentary", "Conversation"], elem_id="gr_radio_mode", value='Real-Time Commentary', interactive=True)
|
56 |
|
57 |
-
def gr_chatinterface_fn(message, history, state, mode):
|
|
|
58 |
response, state = gradio_backend(query=message, state=state, mode=mode)
|
59 |
return response, state
|
60 |
def gr_chatinterface_chatbot_clear_fn():
|
@@ -62,7 +63,7 @@ with gr.Blocks() as demo:
|
|
62 |
gr_chatinterface = gr.ChatInterface(
|
63 |
fn=gr_chatinterface_fn,
|
64 |
type="messages",
|
65 |
-
additional_inputs=[gr_state, gr_radio_mode],
|
66 |
additional_outputs=[gr_state],
|
67 |
)
|
68 |
gr_chatinterface.chatbot.clear(fn=gr_chatinterface_chatbot_clear_fn, outputs=[gr_video_state, gr_state, gr_static_trigger, gr_dynamic_trigger])
|
@@ -105,13 +106,18 @@ with gr.Blocks() as demo:
|
|
105 |
return { video_path: videoEl.currentSrc, video_timestamp: videoEl.currentTime };
|
106 |
}
|
107 |
"""
|
108 |
-
gr_video.change(fn=lambda :[1,1], outputs=[gr_static_trigger, gr_dynamic_trigger])
|
109 |
|
110 |
def gr_get_video_state(video_state):
|
111 |
-
print(video_state)
|
112 |
if 'file=' in video_state['video_path']:
|
113 |
video_state['video_path'] = video_state['video_path'].split('file=')[1]
|
114 |
return video_state
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
gr_dynamic_trigger.change(
|
116 |
fn=gr_get_video_state,
|
117 |
inputs=[gr_video_state],
|
|
|
54 |
with gr.Row():
|
55 |
gr_radio_mode = gr.Radio(label="Select Mode", choices=["Real-Time Commentary", "Conversation"], elem_id="gr_radio_mode", value='Real-Time Commentary', interactive=True)
|
56 |
|
57 |
+
def gr_chatinterface_fn(message, history, state, video_path, mode):
|
58 |
+
state['video_path'] = video_path
|
59 |
response, state = gradio_backend(query=message, state=state, mode=mode)
|
60 |
return response, state
|
61 |
def gr_chatinterface_chatbot_clear_fn():
|
|
|
63 |
gr_chatinterface = gr.ChatInterface(
|
64 |
fn=gr_chatinterface_fn,
|
65 |
type="messages",
|
66 |
+
additional_inputs=[gr_state, gr_video, gr_radio_mode],
|
67 |
additional_outputs=[gr_state],
|
68 |
)
|
69 |
gr_chatinterface.chatbot.clear(fn=gr_chatinterface_chatbot_clear_fn, outputs=[gr_video_state, gr_state, gr_static_trigger, gr_dynamic_trigger])
|
|
|
106 |
return { video_path: videoEl.currentSrc, video_timestamp: videoEl.currentTime };
|
107 |
}
|
108 |
"""
|
|
|
109 |
|
110 |
def gr_get_video_state(video_state):
|
|
|
111 |
if 'file=' in video_state['video_path']:
|
112 |
video_state['video_path'] = video_state['video_path'].split('file=')[1]
|
113 |
return video_state
|
114 |
+
def gr_video_change_fn(mode):
|
115 |
+
return [1, 1] if mode == "Real-Time Commentary" else [0, 0]
|
116 |
+
gr_video.change(
|
117 |
+
fn=gr_video_change_fn,
|
118 |
+
inputs=[gr_radio_mode],
|
119 |
+
outputs=[gr_static_trigger, gr_dynamic_trigger]
|
120 |
+
)
|
121 |
gr_dynamic_trigger.change(
|
122 |
fn=gr_get_video_state,
|
123 |
inputs=[gr_video_state],
|