Spaces:
Sleeping
Sleeping
Commit
·
c57cd9a
1
Parent(s):
891f3b9
Added hiding
Browse files
app.py
CHANGED
|
@@ -3,6 +3,21 @@ import gradio as gr
|
|
| 3 |
from llm import end_interview, get_problem, send_request
|
| 4 |
from options import languages_list, models, topics_list
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
with gr.Blocks() as demo:
|
| 7 |
gr.Markdown("Your coding interview practice AI assistant!")
|
| 8 |
# TODO: add instructions tab
|
|
@@ -31,12 +46,12 @@ with gr.Blocks() as demo:
|
|
| 31 |
requirements = gr.Textbox(
|
| 32 |
label="Requirements", placeholder="Specify requirements: topic, difficulty, language, etc.", lines=5
|
| 33 |
)
|
| 34 |
-
start_btn = gr.Button("
|
| 35 |
|
| 36 |
# TODO: select LLM model
|
| 37 |
with gr.Accordion("Problem statement", open=True) as problem_acc:
|
| 38 |
description = gr.Markdown()
|
| 39 |
-
with gr.Accordion("Solution", open=
|
| 40 |
with gr.Row() as content:
|
| 41 |
with gr.Column(scale=2):
|
| 42 |
language_select = gr.Dropdown(
|
|
@@ -56,12 +71,16 @@ with gr.Blocks() as demo:
|
|
| 56 |
inputs=[requirements, difficulty_select, topic_select, model_select],
|
| 57 |
outputs=[description, chat_history],
|
| 58 |
scroll_to_output=True,
|
| 59 |
-
)
|
|
|
|
| 60 |
message.submit(
|
| 61 |
fn=send_request,
|
| 62 |
inputs=[code, previous_code, message, chat_history, chat, model_select],
|
| 63 |
outputs=[chat_history, chat, message, previous_code],
|
| 64 |
)
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
demo.launch()
|
|
|
|
| 3 |
from llm import end_interview, get_problem, send_request
|
| 4 |
from options import languages_list, models, topics_list
|
| 5 |
|
| 6 |
+
|
| 7 |
+
def hide_settings():
|
| 8 |
+
init_acc = gr.Accordion("Settings", open=False)
|
| 9 |
+
start_btn = gr.Button("Generate a problem", interactive=False)
|
| 10 |
+
solution_acc = gr.Accordion("Solution", open=True)
|
| 11 |
+
return init_acc, start_btn, solution_acc
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def hide_solution():
|
| 15 |
+
solution_acc = gr.Accordion("Solution", open=False)
|
| 16 |
+
end_btn = gr.Button("Finish the interview", interactive=False)
|
| 17 |
+
problem_acc = gr.Accordion("Problem statement", open=False)
|
| 18 |
+
return solution_acc, end_btn, problem_acc
|
| 19 |
+
|
| 20 |
+
|
| 21 |
with gr.Blocks() as demo:
|
| 22 |
gr.Markdown("Your coding interview practice AI assistant!")
|
| 23 |
# TODO: add instructions tab
|
|
|
|
| 46 |
requirements = gr.Textbox(
|
| 47 |
label="Requirements", placeholder="Specify requirements: topic, difficulty, language, etc.", lines=5
|
| 48 |
)
|
| 49 |
+
start_btn = gr.Button("Generate a problem")
|
| 50 |
|
| 51 |
# TODO: select LLM model
|
| 52 |
with gr.Accordion("Problem statement", open=True) as problem_acc:
|
| 53 |
description = gr.Markdown()
|
| 54 |
+
with gr.Accordion("Solution", open=False) as solution_acc:
|
| 55 |
with gr.Row() as content:
|
| 56 |
with gr.Column(scale=2):
|
| 57 |
language_select = gr.Dropdown(
|
|
|
|
| 71 |
inputs=[requirements, difficulty_select, topic_select, model_select],
|
| 72 |
outputs=[description, chat_history],
|
| 73 |
scroll_to_output=True,
|
| 74 |
+
).then(fn=hide_settings, inputs=None, outputs=[init_acc, start_btn, solution_acc])
|
| 75 |
+
|
| 76 |
message.submit(
|
| 77 |
fn=send_request,
|
| 78 |
inputs=[code, previous_code, message, chat_history, chat, model_select],
|
| 79 |
outputs=[chat_history, chat, message, previous_code],
|
| 80 |
)
|
| 81 |
+
|
| 82 |
+
end_btn.click(fn=end_interview, inputs=[chat_history, model_select], outputs=feedback).then(
|
| 83 |
+
fn=hide_solution, inputs=None, outputs=[solution_acc, end_btn, problem_acc]
|
| 84 |
+
)
|
| 85 |
|
| 86 |
demo.launch()
|