Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 3 |
+
from datetime import datetime
|
| 4 |
+
|
| 5 |
+
st.title("Job Interview Preparation Bot")
|
| 6 |
+
|
| 7 |
+
# Function to generate interview questions
|
| 8 |
+
def generate_questions(role, topic, difficulty, num_questions):
|
| 9 |
+
prompt = (
|
| 10 |
+
f"Generate {num_questions} {difficulty} interview questions for a {role} role "
|
| 11 |
+
f"focused on {topic}."
|
| 12 |
+
)
|
| 13 |
+
llm = ChatGoogleGenerativeAI(model='gemini-pro', google_api_key=st.secrets["GOOGLE_API_KEY"])
|
| 14 |
+
answers = llm.invoke(prompt)
|
| 15 |
+
return answers.content if answers else "No questions generated."
|
| 16 |
+
|
| 17 |
+
# Function to analyze responses and give feedback
|
| 18 |
+
def analyze_responses(response):
|
| 19 |
+
prompt = (
|
| 20 |
+
f"Provide constructive feedback on the following interview response:\n\n{response}"
|
| 21 |
+
)
|
| 22 |
+
llm = ChatGoogleGenerativeAI(model='gemini-pro', google_api_key=st.secrets["GOOGLE_API_KEY"])
|
| 23 |
+
feedback = llm.invoke(prompt)
|
| 24 |
+
return feedback.content if feedback else "No feedback available."
|
| 25 |
+
|
| 26 |
+
# Function to provide general and specific interview tips
|
| 27 |
+
def provide_tips(role=None):
|
| 28 |
+
prompt = "Share general interview tips."
|
| 29 |
+
if role:
|
| 30 |
+
prompt += f" Provide specific tips for a {role} role."
|
| 31 |
+
llm = ChatGoogleGenerativeAI(model='gemini-pro', google_api_key=st.secrets["GOOGLE_API_KEY"])
|
| 32 |
+
tips = llm.invoke(prompt)
|
| 33 |
+
return tips.content if tips else "No tips available."
|
| 34 |
+
|
| 35 |
+
# Interface for generating questions
|
| 36 |
+
with st.form('question_form'):
|
| 37 |
+
role = st.selectbox('Select Role', ['Software Developer', 'Data Analyst', 'Marketing Manager'])
|
| 38 |
+
topic = st.selectbox('Select Topic', ['Behavioral', 'Technical', 'Situational'])
|
| 39 |
+
difficulty = st.selectbox('Select Difficulty Level', ['Easy', 'Medium', 'Hard'])
|
| 40 |
+
num_questions = st.slider('Number of Questions', 1, 10, 5)
|
| 41 |
+
question_submitted = st.form_submit_button('Generate Questions')
|
| 42 |
+
|
| 43 |
+
if question_submitted:
|
| 44 |
+
questions = generate_questions(role, topic, difficulty, num_questions)
|
| 45 |
+
st.info(questions)
|
| 46 |
+
|
| 47 |
+
# Interface for feedback on responses
|
| 48 |
+
with st.form('feedback_form'):
|
| 49 |
+
response = st.text_area('Type your interview response')
|
| 50 |
+
feedback_submitted = st.form_submit_button('Get Feedback')
|
| 51 |
+
|
| 52 |
+
if feedback_submitted and response:
|
| 53 |
+
feedback = analyze_responses(response)
|
| 54 |
+
st.info(feedback)
|
| 55 |
+
|
| 56 |
+
# Interface for interview tips
|
| 57 |
+
with st.form('tips_form'):
|
| 58 |
+
role_for_tips = st.selectbox('Select Role for Tips', ['', 'Software Developer', 'Data Analyst', 'Marketing Manager'])
|
| 59 |
+
tips_submitted = st.form_submit_button('Get Tips')
|
| 60 |
+
|
| 61 |
+
if tips_submitted:
|
| 62 |
+
tips = provide_tips(role_for_tips if role_for_tips else None)
|
| 63 |
+
st.info(tips)
|
| 64 |
+
|
| 65 |
+
# Example mock interview scheduling (this is a placeholder for now)
|
| 66 |
+
st.sidebar.header("Mock Interview Scheduler")
|
| 67 |
+
st.sidebar.write("Schedule a mock interview with the bot.")
|
| 68 |
+
mock_date = st.sidebar.date_input("Select Date", datetime.now())
|
| 69 |
+
mock_time = st.sidebar.time_input("Select Time", datetime.now().time())
|
| 70 |
+
st.sidebar.button("Schedule Interview", on_click=lambda: st.sidebar.write("Interview scheduled!"))
|
| 71 |
+
|
| 72 |
+
# Placeholder for engagement metrics and resource recommendations
|
| 73 |
+
st.sidebar.header("Engagement Metrics and Resources")
|
| 74 |
+
st.sidebar.write("Track your progress over time and connect with resources.")
|