Spaces:
Sleeping
Sleeping
Commit
·
70bf9cc
1
Parent(s):
3667c7a
UI clean up
Browse files
app.py
CHANGED
|
@@ -28,10 +28,14 @@ default_audio_params = {
|
|
| 28 |
def hide_settings():
|
| 29 |
init_acc = gr.Accordion("Settings", open=False)
|
| 30 |
start_btn = gr.Button("Generate a problem", interactive=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
solution_acc = gr.Accordion("Solution", open=True)
|
| 32 |
end_btn = gr.Button("Finish the interview", interactive=True)
|
| 33 |
audio_input = gr.Audio(interactive=True, **default_audio_params)
|
| 34 |
-
return
|
| 35 |
|
| 36 |
|
| 37 |
def hide_solution():
|
|
@@ -42,7 +46,11 @@ def hide_solution():
|
|
| 42 |
return solution_acc, end_btn, problem_acc, audio_input
|
| 43 |
|
| 44 |
|
|
|
|
|
|
|
| 45 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
| 46 |
with gr.Tab("Instruction") as instruction_tab:
|
| 47 |
with gr.Row():
|
| 48 |
with gr.Column(scale=10):
|
|
@@ -81,8 +89,6 @@ with gr.Blocks() as demo:
|
|
| 81 |
with gr.Tab("Coding") as coding_tab:
|
| 82 |
chat_history = gr.State([])
|
| 83 |
previous_code = gr.State("")
|
| 84 |
-
client = gr.State(None)
|
| 85 |
-
client_started = gr.State(False)
|
| 86 |
with gr.Accordion("Settings") as init_acc:
|
| 87 |
with gr.Row():
|
| 88 |
with gr.Column():
|
|
@@ -111,7 +117,7 @@ with gr.Blocks() as demo:
|
|
| 111 |
with gr.Row() as content:
|
| 112 |
with gr.Column(scale=2):
|
| 113 |
code = gr.Code(
|
| 114 |
-
label="Please write your code here.
|
| 115 |
language="python",
|
| 116 |
lines=35,
|
| 117 |
)
|
|
@@ -119,12 +125,12 @@ with gr.Blocks() as demo:
|
|
| 119 |
end_btn = gr.Button("Finish the interview", interactive=False)
|
| 120 |
chat = gr.Chatbot(label="Chat", show_label=False, show_share_button=False)
|
| 121 |
audio_input = gr.Audio(interactive=False, **default_audio_params)
|
| 122 |
-
audio_output = gr.Audio(label="Play audio", autoplay=True, visible=False)
|
| 123 |
message = gr.Textbox(label="Message", lines=3, visible=False)
|
| 124 |
|
| 125 |
with gr.Accordion("Feedback", open=True) as feedback_acc:
|
| 126 |
feedback = gr.Markdown()
|
| 127 |
|
|
|
|
| 128 |
coding_tab.select(fn=add_interviewer_message(fixed_messages["intro"]), inputs=[chat], outputs=[chat])
|
| 129 |
|
| 130 |
start_btn.click(fn=add_interviewer_message(fixed_messages["start"]), inputs=[chat], outputs=[chat]).then(
|
|
@@ -132,12 +138,8 @@ with gr.Blocks() as demo:
|
|
| 132 |
inputs=[requirements, difficulty_select, topic_select],
|
| 133 |
outputs=[description, chat_history],
|
| 134 |
scroll_to_output=True,
|
| 135 |
-
).then(fn=hide_settings, inputs=None, outputs=[init_acc, start_btn
|
| 136 |
-
|
| 137 |
-
message.submit(
|
| 138 |
-
fn=llm.send_request,
|
| 139 |
-
inputs=[code, previous_code, message, chat_history, chat],
|
| 140 |
-
outputs=[chat_history, chat, message, previous_code],
|
| 141 |
)
|
| 142 |
|
| 143 |
end_btn.click(
|
|
|
|
| 28 |
def hide_settings():
|
| 29 |
init_acc = gr.Accordion("Settings", open=False)
|
| 30 |
start_btn = gr.Button("Generate a problem", interactive=False)
|
| 31 |
+
return init_acc, start_btn
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def show_solution():
|
| 35 |
solution_acc = gr.Accordion("Solution", open=True)
|
| 36 |
end_btn = gr.Button("Finish the interview", interactive=True)
|
| 37 |
audio_input = gr.Audio(interactive=True, **default_audio_params)
|
| 38 |
+
return solution_acc, end_btn, audio_input
|
| 39 |
|
| 40 |
|
| 41 |
def hide_solution():
|
|
|
|
| 46 |
return solution_acc, end_btn, problem_acc, audio_input
|
| 47 |
|
| 48 |
|
| 49 |
+
# Interface
|
| 50 |
+
|
| 51 |
with gr.Blocks() as demo:
|
| 52 |
+
audio_output = gr.Audio(label="Play audio", autoplay=True, visible=False)
|
| 53 |
+
|
| 54 |
with gr.Tab("Instruction") as instruction_tab:
|
| 55 |
with gr.Row():
|
| 56 |
with gr.Column(scale=10):
|
|
|
|
| 89 |
with gr.Tab("Coding") as coding_tab:
|
| 90 |
chat_history = gr.State([])
|
| 91 |
previous_code = gr.State("")
|
|
|
|
|
|
|
| 92 |
with gr.Accordion("Settings") as init_acc:
|
| 93 |
with gr.Row():
|
| 94 |
with gr.Column():
|
|
|
|
| 117 |
with gr.Row() as content:
|
| 118 |
with gr.Column(scale=2):
|
| 119 |
code = gr.Code(
|
| 120 |
+
label="Please write your code here. You can use any language, but only Python syntax highlighting is available.",
|
| 121 |
language="python",
|
| 122 |
lines=35,
|
| 123 |
)
|
|
|
|
| 125 |
end_btn = gr.Button("Finish the interview", interactive=False)
|
| 126 |
chat = gr.Chatbot(label="Chat", show_label=False, show_share_button=False)
|
| 127 |
audio_input = gr.Audio(interactive=False, **default_audio_params)
|
|
|
|
| 128 |
message = gr.Textbox(label="Message", lines=3, visible=False)
|
| 129 |
|
| 130 |
with gr.Accordion("Feedback", open=True) as feedback_acc:
|
| 131 |
feedback = gr.Markdown()
|
| 132 |
|
| 133 |
+
# Events
|
| 134 |
coding_tab.select(fn=add_interviewer_message(fixed_messages["intro"]), inputs=[chat], outputs=[chat])
|
| 135 |
|
| 136 |
start_btn.click(fn=add_interviewer_message(fixed_messages["start"]), inputs=[chat], outputs=[chat]).then(
|
|
|
|
| 138 |
inputs=[requirements, difficulty_select, topic_select],
|
| 139 |
outputs=[description, chat_history],
|
| 140 |
scroll_to_output=True,
|
| 141 |
+
).then(fn=hide_settings, inputs=None, outputs=[init_acc, start_btn]).then(
|
| 142 |
+
fn=show_solution, inputs=None, outputs=[solution_acc, end_btn, audio_input]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
)
|
| 144 |
|
| 145 |
end_btn.click(
|