Spaces:
Sleeping
Sleeping
Commit
·
15f2bc2
1
Parent(s):
bd6074b
Fixed repeated message issue
Browse files- app.py +10 -5
- utils/ui.py +3 -2
app.py
CHANGED
|
@@ -52,7 +52,8 @@ with gr.Blocks(title="AI Interviewer") as demo:
|
|
| 52 |
if os.getenv("IS_DEMO"):
|
| 53 |
gr.Markdown(instruction["demo"])
|
| 54 |
|
| 55 |
-
|
|
|
|
| 56 |
with gr.Tab("Instruction") as instruction_tab:
|
| 57 |
with gr.Row():
|
| 58 |
with gr.Column(scale=2):
|
|
@@ -135,14 +136,18 @@ with gr.Blocks(title="AI Interviewer") as demo:
|
|
| 135 |
feedback = gr.Markdown()
|
| 136 |
|
| 137 |
# Events
|
| 138 |
-
coding_tab.select(fn=add_interviewer_message(fixed_messages["intro"]), inputs=[chat], outputs=[chat])
|
| 139 |
|
| 140 |
start_btn.click(fn=add_interviewer_message(fixed_messages["start"]), inputs=[chat], outputs=[chat]).then(
|
|
|
|
|
|
|
| 141 |
fn=llm.get_problem,
|
| 142 |
inputs=[requirements, difficulty_select, topic_select],
|
| 143 |
outputs=[description, chat_history],
|
| 144 |
scroll_to_output=True,
|
| 145 |
-
).then(
|
|
|
|
|
|
|
| 146 |
fn=show_solution, inputs=None, outputs=[solution_acc, end_btn, audio_input]
|
| 147 |
)
|
| 148 |
|
|
@@ -162,8 +167,8 @@ with gr.Blocks(title="AI Interviewer") as demo:
|
|
| 162 |
outputs=[chat_history, chat, message, previous_code],
|
| 163 |
)
|
| 164 |
|
| 165 |
-
chat.change(fn=tts.read_last_message, inputs=[chat], outputs=[audio_output])
|
| 166 |
|
| 167 |
-
audio_output.stop(fn=lambda: None, inputs=None, outputs=[audio_output])
|
| 168 |
|
| 169 |
demo.launch(show_api=False)
|
|
|
|
| 52 |
if os.getenv("IS_DEMO"):
|
| 53 |
gr.Markdown(instruction["demo"])
|
| 54 |
|
| 55 |
+
started_coding = gr.State(False)
|
| 56 |
+
audio_output = gr.Audio(label="Play audio", autoplay=True, visible=False, interactive=False)
|
| 57 |
with gr.Tab("Instruction") as instruction_tab:
|
| 58 |
with gr.Row():
|
| 59 |
with gr.Column(scale=2):
|
|
|
|
| 136 |
feedback = gr.Markdown()
|
| 137 |
|
| 138 |
# Events
|
| 139 |
+
coding_tab.select(fn=add_interviewer_message(fixed_messages["intro"]), inputs=[chat, started_coding], outputs=[chat])
|
| 140 |
|
| 141 |
start_btn.click(fn=add_interviewer_message(fixed_messages["start"]), inputs=[chat], outputs=[chat]).then(
|
| 142 |
+
fn=lambda: True, inputs=None, outputs=[started_coding]
|
| 143 |
+
).then(
|
| 144 |
fn=llm.get_problem,
|
| 145 |
inputs=[requirements, difficulty_select, topic_select],
|
| 146 |
outputs=[description, chat_history],
|
| 147 |
scroll_to_output=True,
|
| 148 |
+
).then(
|
| 149 |
+
fn=hide_settings, inputs=None, outputs=[init_acc, start_btn]
|
| 150 |
+
).then(
|
| 151 |
fn=show_solution, inputs=None, outputs=[solution_acc, end_btn, audio_input]
|
| 152 |
)
|
| 153 |
|
|
|
|
| 167 |
outputs=[chat_history, chat, message, previous_code],
|
| 168 |
)
|
| 169 |
|
| 170 |
+
chat.change(fn=tts.read_last_message, inputs=[chat], outputs=[audio_output], trigger_mode="once")
|
| 171 |
|
| 172 |
+
# audio_output.stop(fn=lambda: None, inputs=None, outputs=[audio_output])
|
| 173 |
|
| 174 |
demo.launch(show_api=False)
|
utils/ui.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
def add_interviewer_message(message):
|
| 2 |
-
def f(chat):
|
| 3 |
-
|
|
|
|
| 4 |
return chat
|
| 5 |
|
| 6 |
return f
|
|
|
|
| 1 |
def add_interviewer_message(message):
|
| 2 |
+
def f(chat, skip=False):
|
| 3 |
+
if not skip:
|
| 4 |
+
chat.append((None, message))
|
| 5 |
return chat
|
| 6 |
|
| 7 |
return f
|