Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from langchain_google_genai import ChatGoogleGenerativeAI | |
| from datetime import datetime | |
| # Custom CSS for styling | |
| st.markdown(""" | |
| <style> | |
| /* Style the title */ | |
| .stApp { | |
| background-color: #8182ae ; | |
| font-family: 'Arial', sans-serif; | |
| } | |
| .stTitle { | |
| color: #2c3e50; | |
| font-size: 32px; | |
| font-weight: bold; | |
| text-align: center; | |
| margin-bottom: 20px; | |
| } | |
| /* Style the buttons and forms */ | |
| .stButton > button { | |
| background-color: #d91515 ; | |
| color: white; | |
| padding: 10px 20px; | |
| border-radius: 5px; | |
| border: none; | |
| font-weight: bold; | |
| } | |
| .stForm { | |
| background-color: #ecf0f1; | |
| } | |
| /* Style the sidebar */ | |
| .stSidebar > div { | |
| background-color: #8182ae; | |
| padding: 15px; | |
| border-radius: 10px; | |
| } | |
| .stSidebar > div > h1 { | |
| color: #2c3e50; | |
| } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| st.markdown("<h1 class='stTitle'>Prepare Smarter, Ace the Interview!</h1>", unsafe_allow_html=True) | |
| # Function to generate interview questions | |
| def generate_questions(role, topic, difficulty, num_questions): | |
| prompt = ( | |
| f"Generate {num_questions} {difficulty} interview questions for a {role} role " | |
| f"focused on {topic}." | |
| ) | |
| llm = ChatGoogleGenerativeAI(model='gemini-pro', google_api_key=st.secrets["GOOGLE_API_KEY"]) | |
| answers = llm.invoke(prompt) | |
| return answers.content if answers else "No questions generated." | |
| # Function to analyze responses and give feedback | |
| def analyze_responses(response): | |
| prompt = ( | |
| f"Provide constructive feedback on the following interview response:\n\n{response}" | |
| ) | |
| llm = ChatGoogleGenerativeAI(model='gemini-pro', google_api_key=st.secrets["GOOGLE_API_KEY"]) | |
| feedback = llm.invoke(prompt) | |
| return feedback.content if feedback else "No feedback available." | |
| # Function to provide general and specific interview tips | |
| def provide_tips(role=None): | |
| prompt = "Share general interview tips." | |
| if role: | |
| prompt += f" Provide specific tips for a {role} role." | |
| llm = ChatGoogleGenerativeAI(model='gemini-pro', google_api_key=st.secrets["GOOGLE_API_KEY"]) | |
| tips = llm.invoke(prompt) | |
| return tips.content if tips else "No tips available." | |
| # Interface for generating questions | |
| with st.form('question_form', clear_on_submit=True): | |
| st.markdown("<div class='stForm'>", unsafe_allow_html=True) | |
| role = st.selectbox('Select Role', ['Software Developer', 'Data Analyst', 'Marketing Manager']) | |
| topic = st.selectbox('Select Topic', ['Behavioral', 'Technical', 'Situational']) | |
| difficulty = st.selectbox('Select Difficulty Level', ['Easy', 'Medium', 'Hard']) | |
| num_questions = st.slider('Number of Questions', 1, 10, 5) | |
| question_submitted = st.form_submit_button('Generate Questions') | |
| if question_submitted: | |
| questions = generate_questions(role, topic, difficulty, num_questions) | |
| st.info(questions) | |
| st.markdown("</div>", unsafe_allow_html=True) | |
| # Interface for feedback on responses | |
| with st.form('feedback_form', clear_on_submit=True): | |
| st.markdown("<div class='stForm'>", unsafe_allow_html=True) | |
| response = st.text_area('Type your interview response') | |
| feedback_submitted = st.form_submit_button('Get Feedback') | |
| if feedback_submitted and response: | |
| feedback = analyze_responses(response) | |
| st.info(feedback) | |
| st.markdown("</div>", unsafe_allow_html=True) | |
| # Interface for interview tips | |
| with st.form('tips_form', clear_on_submit=True): | |
| st.markdown("<div class='stForm'>", unsafe_allow_html=True) | |
| role_for_tips = st.selectbox('Select Role for Tips', ['', 'Software Developer', 'Data Analyst', 'Marketing Manager']) | |
| tips_submitted = st.form_submit_button('Get Tips') | |
| if tips_submitted: | |
| tips = provide_tips(role_for_tips if role_for_tips else None) | |
| st.info(tips) | |
| st.markdown("</div>", unsafe_allow_html=True) | |
| # Sidebar for mock interview scheduling and resources | |
| st.sidebar.header(" Book Your Interview Slot") | |
| st.sidebar.write("Book a Practice Interview with the Bot") | |
| mock_date = st.sidebar.date_input("Select Date", datetime.now()) | |
| mock_time = st.sidebar.time_input("Select Time", datetime.now().time()) | |
| st.sidebar.button("Schedule Interview", on_click=lambda: st.sidebar.write("Interview is Booked!")) | |
| st.sidebar.header("Engagement Metrics and Resources") | |
| st.sidebar.write("Track your progress over time and connect with resources.") | |