Spaces:
Sleeping
Sleeping
File size: 3,019 Bytes
df25732 1a47458 a82cf01 a10bc68 df25732 891f3b9 df25732 a10bc68 df25732 a10bc68 f6e34f2 891f3b9 a10bc68 891f3b9 df25732 a10bc68 c8e8be4 891f3b9 df25732 a10bc68 f6e34f2 a10bc68 c8e8be4 df25732 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
import gradio as gr
from llm import end_interview, get_problem, send_request
from options import languages_list, models, topics_list
with gr.Blocks() as demo:
gr.Markdown("Your coding interview practice AI assistant!")
# TODO: add instructions tab
# TODO: add other types of interviews (e.g. system design, ML design, behavioral, etc.)
with gr.Tab("Coding"):
chat_history = gr.State([])
previous_code = gr.State("")
client = gr.State(None)
with gr.Accordion("Settings") as init_acc:
with gr.Row():
with gr.Column():
gr.Markdown("Difficulty")
difficulty_select = gr.Dropdown(
label="Select difficulty", choices=["Easy", "Medium", "Hard"], value="Medium", container=False
)
gr.Markdown("Topic")
topic_select = gr.Dropdown(
label="Select topic", choices=topics_list, value="Arrays", container=False, allow_custom_value=True
)
gr.Markdown("Select LLM model to use")
model_select = gr.Dropdown(label="Select model", choices=models, value="gpt-3.5-turbo", container=False)
with gr.Column():
requirements = gr.Textbox(
label="Requirements", placeholder="Specify requirements: topic, difficulty, language, etc.", lines=5
)
start_btn = gr.Button("Start")
# TODO: select LLM model
with gr.Accordion("Problem statement", open=True) as problem_acc:
description = gr.Markdown()
with gr.Accordion("Solution", open=True) as solution_acc:
with gr.Row() as content:
with gr.Column(scale=2):
language_select = gr.Dropdown(
label="Select language", choices=languages_list, value="python", container=False, interactive=True
)
code = gr.Code(label="Solution", language=language_select.value, lines=20)
message = gr.Textbox(label="Message", lines=1)
# TODO: add voice input and output
with gr.Column(scale=1):
chat = gr.Chatbot(label="Chat history")
end_btn = gr.Button("Finish the interview")
with gr.Accordion("Feedback", open=True) as feedback_acc:
feedback = gr.Markdown()
start_btn.click(
fn=get_problem,
inputs=[requirements, difficulty_select, topic_select, model_select],
outputs=[description, chat_history],
scroll_to_output=True,
)
message.submit(
fn=send_request,
inputs=[code, previous_code, message, chat_history, chat, model_select],
outputs=[chat_history, chat, message, previous_code],
)
end_btn.click(fn=end_interview, inputs=[chat_history, model_select], outputs=feedback)
demo.launch()
|