Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,73 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
|
| 3 |
+
# Respond to user input
|
| 4 |
+
def chatbot_response(user_input):
|
| 5 |
+
return f"π€ Thanks! Thatβs a strong example of an interview response."
|
| 6 |
+
|
| 7 |
+
# Show/hide the tip "pop-up"
|
| 8 |
+
def show_tip():
|
| 9 |
+
return gr.update(visible=True)
|
| 10 |
+
|
| 11 |
+
def hide_tip():
|
| 12 |
+
return gr.update(visible=False)
|
| 13 |
+
|
| 14 |
+
with gr.Blocks(css="""
|
| 15 |
+
.popup-box {
|
| 16 |
+
position: fixed;
|
| 17 |
+
top: 30%;
|
| 18 |
+
left: 50%;
|
| 19 |
+
transform: translate(-50%, -50%);
|
| 20 |
+
background-color: white;
|
| 21 |
+
border: 2px solid #333;
|
| 22 |
+
padding: 20px;
|
| 23 |
+
z-index: 999;
|
| 24 |
+
box-shadow: 0 0 10px rgba(0,0,0,0.3);
|
| 25 |
+
border-radius: 12px;
|
| 26 |
+
}
|
| 27 |
+
.overlay {
|
| 28 |
+
position: fixed;
|
| 29 |
+
top: 0;
|
| 30 |
+
left: 0;
|
| 31 |
+
width: 100%;
|
| 32 |
+
height: 100%;
|
| 33 |
+
background: rgba(0,0,0,0.4);
|
| 34 |
+
z-index: 998;
|
| 35 |
+
}
|
| 36 |
+
""") as demo:
|
| 37 |
+
|
| 38 |
+
gr.Markdown("## π€ Interview Chatbot")
|
| 39 |
+
gr.Markdown("Write your answer below or click an example:")
|
| 40 |
+
|
| 41 |
+
# User input and bot output
|
| 42 |
+
user_input = gr.Textbox(label="Your Answer", placeholder="Type your interview response here...")
|
| 43 |
+
submit_btn = gr.Button("Submit")
|
| 44 |
+
bot_output = gr.Textbox(label="Bot Reply")
|
| 45 |
+
|
| 46 |
+
# Example answers for interview questions
|
| 47 |
+
gr.Examples(
|
| 48 |
+
examples=[
|
| 49 |
+
["I led a cross-functional team to deliver a project ahead of schedule."],
|
| 50 |
+
["I handled a client complaint by staying calm and offering a solution."],
|
| 51 |
+
["I used data to reduce delivery time by 15% on a logistics project."]
|
| 52 |
+
],
|
| 53 |
+
inputs=user_input
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
# Submit logic
|
| 57 |
+
submit_btn.click(fn=chatbot_response, inputs=user_input, outputs=bot_output)
|
| 58 |
+
|
| 59 |
+
# Button to show interview tip
|
| 60 |
+
tip_button = gr.Button("π‘ Show Interview Tip")
|
| 61 |
+
|
| 62 |
+
# Tip pop-up with overlay
|
| 63 |
+
with gr.Group(visible=False) as popup:
|
| 64 |
+
gr.HTML('<div class="overlay"></div>')
|
| 65 |
+
with gr.Column(elem_classes="popup-box"):
|
| 66 |
+
gr.Markdown("π§ **Tip:** Use the **STAR method** β Situation, Task, Action, Result β to structure your answers.")
|
| 67 |
+
close_btn = gr.Button("β Close Tip")
|
| 68 |
+
|
| 69 |
+
# Show/hide logic
|
| 70 |
+
tip_button.click(fn=show_tip, outputs=popup)
|
| 71 |
+
close_btn.click(fn=hide_tip, outputs=popup)
|
| 72 |
+
|
| 73 |
+
demo.launch()
|