Spaces:
Sleeping
Sleeping
IliaLarchenko
commited on
Commit
•
453b658
1
Parent(s):
afd89a5
Made elem_id unique
Browse files- ui/coding.py +24 -21
ui/coding.py
CHANGED
@@ -10,7 +10,7 @@ def get_problem_solving_ui(llm, tts, stt, default_audio_params, audio_output, na
|
|
10 |
chat_history = gr.State([])
|
11 |
previous_code = gr.State("")
|
12 |
started_coding = gr.State(False)
|
13 |
-
|
14 |
with gr.Accordion("Settings") as init_acc:
|
15 |
with gr.Row():
|
16 |
with gr.Column():
|
@@ -23,10 +23,10 @@ def get_problem_solving_ui(llm, tts, stt, default_audio_params, audio_output, na
|
|
23 |
value="Medium",
|
24 |
container=False,
|
25 |
allow_custom_value=True,
|
26 |
-
elem_id="
|
27 |
)
|
28 |
with gr.Row():
|
29 |
-
topics = topic_lists[interview_type
|
30 |
np.random.shuffle(topics)
|
31 |
gr.Markdown("Topic (can type custom value)")
|
32 |
topic_select = gr.Dropdown(
|
@@ -35,43 +35,46 @@ def get_problem_solving_ui(llm, tts, stt, default_audio_params, audio_output, na
|
|
35 |
value=topics[0],
|
36 |
container=False,
|
37 |
allow_custom_value=True,
|
38 |
-
elem_id="
|
39 |
)
|
40 |
with gr.Column(scale=2):
|
41 |
requirements = gr.Textbox(
|
42 |
-
label="Requirements",
|
|
|
|
|
|
|
43 |
)
|
44 |
-
start_btn = gr.Button("Generate a problem", elem_id="
|
45 |
|
46 |
with gr.Accordion("Problem statement", open=True) as problem_acc:
|
47 |
-
description = gr.Markdown(elem_id="
|
48 |
with gr.Accordion("Solution", open=False) as solution_acc:
|
49 |
with gr.Row() as content:
|
50 |
with gr.Column(scale=2):
|
51 |
-
if interview_type
|
52 |
code = gr.Code(
|
53 |
label="Please write your code here. You can use any language, but only Python syntax highlighting is available.",
|
54 |
language="python",
|
55 |
lines=46,
|
56 |
-
elem_id="
|
57 |
)
|
58 |
-
elif interview_type
|
59 |
code = gr.Code(
|
60 |
label="Please write your query here.",
|
61 |
language="sql",
|
62 |
lines=46,
|
63 |
-
elem_id="
|
64 |
)
|
65 |
else:
|
66 |
code = gr.Code(
|
67 |
label="Please write any notes for your solution here.",
|
68 |
language=None,
|
69 |
lines=46,
|
70 |
-
elem_id="
|
71 |
)
|
72 |
with gr.Column(scale=1):
|
73 |
-
end_btn = gr.Button("Finish the interview", interactive=False, variant="stop", elem_id="
|
74 |
-
chat = gr.Chatbot(label="Chat", show_label=False, show_share_button=False, elem_id="
|
75 |
message = gr.Textbox(
|
76 |
label="Message",
|
77 |
show_label=False,
|
@@ -79,16 +82,16 @@ def get_problem_solving_ui(llm, tts, stt, default_audio_params, audio_output, na
|
|
79 |
max_lines=3,
|
80 |
interactive=True,
|
81 |
container=False,
|
82 |
-
elem_id="
|
83 |
)
|
84 |
-
send_btn = gr.Button("Send", interactive=False, elem_id="
|
85 |
-
audio_input = gr.Audio(interactive=False, **default_audio_params, elem_id="
|
86 |
|
87 |
audio_buffer = gr.State(np.array([], dtype=np.int16))
|
88 |
transcript = gr.State({"words": [], "not_confirmed": 0, "last_cutoff": 0, "text": ""})
|
89 |
|
90 |
with gr.Accordion("Feedback", open=True) as feedback_acc:
|
91 |
-
feedback = gr.Markdown(elem_id="
|
92 |
|
93 |
start_btn.click(fn=add_interviewer_message(fixed_messages["start"]), inputs=[chat], outputs=[chat]).success(
|
94 |
fn=lambda: True, outputs=[started_coding]
|
@@ -96,11 +99,11 @@ def get_problem_solving_ui(llm, tts, stt, default_audio_params, audio_output, na
|
|
96 |
fn=lambda: (gr.update(open=False), gr.update(interactive=False)), outputs=[init_acc, start_btn]
|
97 |
).success(
|
98 |
fn=llm.get_problem,
|
99 |
-
inputs=[requirements, difficulty_select, topic_select,
|
100 |
outputs=[description],
|
101 |
scroll_to_output=True,
|
102 |
).success(
|
103 |
-
fn=llm.init_bot, inputs=[description,
|
104 |
).success(
|
105 |
fn=lambda: (gr.update(open=True), gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True)),
|
106 |
outputs=[solution_acc, end_btn, audio_input, send_btn],
|
@@ -120,7 +123,7 @@ def get_problem_solving_ui(llm, tts, stt, default_audio_params, audio_output, na
|
|
120 |
),
|
121 |
outputs=[solution_acc, end_btn, problem_acc, audio_input, send_btn],
|
122 |
).success(
|
123 |
-
fn=llm.end_interview, inputs=[description, chat_history,
|
124 |
)
|
125 |
|
126 |
send_btn.click(fn=add_candidate_message, inputs=[message, chat], outputs=[chat]).success(
|
|
|
10 |
chat_history = gr.State([])
|
11 |
previous_code = gr.State("")
|
12 |
started_coding = gr.State(False)
|
13 |
+
interview_type_var = gr.State(interview_type)
|
14 |
with gr.Accordion("Settings") as init_acc:
|
15 |
with gr.Row():
|
16 |
with gr.Column():
|
|
|
23 |
value="Medium",
|
24 |
container=False,
|
25 |
allow_custom_value=True,
|
26 |
+
elem_id=f"{interview_type}_difficulty_select",
|
27 |
)
|
28 |
with gr.Row():
|
29 |
+
topics = topic_lists[interview_type].copy()
|
30 |
np.random.shuffle(topics)
|
31 |
gr.Markdown("Topic (can type custom value)")
|
32 |
topic_select = gr.Dropdown(
|
|
|
35 |
value=topics[0],
|
36 |
container=False,
|
37 |
allow_custom_value=True,
|
38 |
+
elem_id=f"{interview_type}_topic_select",
|
39 |
)
|
40 |
with gr.Column(scale=2):
|
41 |
requirements = gr.Textbox(
|
42 |
+
label="Requirements",
|
43 |
+
placeholder="Specify additional requirements",
|
44 |
+
lines=5,
|
45 |
+
elem_id=f"{interview_type}_requirements",
|
46 |
)
|
47 |
+
start_btn = gr.Button("Generate a problem", elem_id=f"{interview_type}_start_btn")
|
48 |
|
49 |
with gr.Accordion("Problem statement", open=True) as problem_acc:
|
50 |
+
description = gr.Markdown(elem_id=f"{interview_type}_problem_description")
|
51 |
with gr.Accordion("Solution", open=False) as solution_acc:
|
52 |
with gr.Row() as content:
|
53 |
with gr.Column(scale=2):
|
54 |
+
if interview_type == "coding":
|
55 |
code = gr.Code(
|
56 |
label="Please write your code here. You can use any language, but only Python syntax highlighting is available.",
|
57 |
language="python",
|
58 |
lines=46,
|
59 |
+
elem_id=f"{interview_type}_code",
|
60 |
)
|
61 |
+
elif interview_type == "sql":
|
62 |
code = gr.Code(
|
63 |
label="Please write your query here.",
|
64 |
language="sql",
|
65 |
lines=46,
|
66 |
+
elem_id=f"{interview_type}_code",
|
67 |
)
|
68 |
else:
|
69 |
code = gr.Code(
|
70 |
label="Please write any notes for your solution here.",
|
71 |
language=None,
|
72 |
lines=46,
|
73 |
+
elem_id=f"{interview_type}_code",
|
74 |
)
|
75 |
with gr.Column(scale=1):
|
76 |
+
end_btn = gr.Button("Finish the interview", interactive=False, variant="stop", elem_id=f"{interview_type}_end_btn")
|
77 |
+
chat = gr.Chatbot(label="Chat", show_label=False, show_share_button=False, elem_id=f"{interview_type}_chat")
|
78 |
message = gr.Textbox(
|
79 |
label="Message",
|
80 |
show_label=False,
|
|
|
82 |
max_lines=3,
|
83 |
interactive=True,
|
84 |
container=False,
|
85 |
+
elem_id=f"{interview_type}_message",
|
86 |
)
|
87 |
+
send_btn = gr.Button("Send", interactive=False, elem_id=f"{interview_type}_send_btn")
|
88 |
+
audio_input = gr.Audio(interactive=False, **default_audio_params, elem_id=f"{interview_type}_audio_input")
|
89 |
|
90 |
audio_buffer = gr.State(np.array([], dtype=np.int16))
|
91 |
transcript = gr.State({"words": [], "not_confirmed": 0, "last_cutoff": 0, "text": ""})
|
92 |
|
93 |
with gr.Accordion("Feedback", open=True) as feedback_acc:
|
94 |
+
feedback = gr.Markdown(elem_id=f"{interview_type}_feedback")
|
95 |
|
96 |
start_btn.click(fn=add_interviewer_message(fixed_messages["start"]), inputs=[chat], outputs=[chat]).success(
|
97 |
fn=lambda: True, outputs=[started_coding]
|
|
|
99 |
fn=lambda: (gr.update(open=False), gr.update(interactive=False)), outputs=[init_acc, start_btn]
|
100 |
).success(
|
101 |
fn=llm.get_problem,
|
102 |
+
inputs=[requirements, difficulty_select, topic_select, interview_type_var],
|
103 |
outputs=[description],
|
104 |
scroll_to_output=True,
|
105 |
).success(
|
106 |
+
fn=llm.init_bot, inputs=[description, interview_type_var], outputs=[chat_history]
|
107 |
).success(
|
108 |
fn=lambda: (gr.update(open=True), gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True)),
|
109 |
outputs=[solution_acc, end_btn, audio_input, send_btn],
|
|
|
123 |
),
|
124 |
outputs=[solution_acc, end_btn, problem_acc, audio_input, send_btn],
|
125 |
).success(
|
126 |
+
fn=llm.end_interview, inputs=[description, chat_history, interview_type_var], outputs=[feedback]
|
127 |
)
|
128 |
|
129 |
send_btn.click(fn=add_candidate_message, inputs=[message, chat], outputs=[chat]).success(
|