# import os, types, streamlit as st # import os # os.environ['STREAMLIT_CONFIG_DIR'] = '/tmp/.streamlit' # # Fetch the hidden code from env var # app_code = os.environ.get("APP_CODE", "") # def execute_code(code_str): # module = types.ModuleType("dynamic_app") # try: # exec(code_str, module.__dict__) # if hasattr(module, "main"): # module.main() # except Exception as e: # st.error(f"Error in hidden code: {e}") # if app_code: # execute_code(app_code) # else: # st.error("APP_CODE is empty. Did you set it?") import os, types, streamlit as st import requests # Make sure to import requests if used os.environ['STREAMLIT_CONFIG_DIR'] = '/tmp/.streamlit' app_code = os.environ.get("APP_CODE", "") def execute_code(code_str): module = types.ModuleType("dynamic_app") try: exec(code_str, module.__dict__) if hasattr(module, "main"): module.main() return module except Exception as e: st.error(f"Error in hidden code: {e}") return None def main(): global job_posts, api_endpoint, hf_token, simulated_code_animation, generate_email, generate_phone_number, generate_linkedin if app_code: module = execute_code(app_code) if module: # Extract required variables and functions from the module job_posts = getattr(module, 'job_posts', []) api_endpoint = getattr(module, 'api_endpoint', '') hf_token = getattr(module, 'hf_token', '') simulated_code_animation = getattr(module, 'simulated_code_animation', lambda x: None) generate_email = getattr(module, 'generate_email', lambda x: "email@example.com") generate_phone_number = getattr(module, 'generate_phone_number', lambda: "555-123-4567") generate_linkedin = getattr(module, 'generate_linkedin', lambda x: "linkedin.com/in/example") else: st.error("APP_CODE is empty. Did you set it?") return st.set_page_config(layout="wide") # Sidebar for navigation with st.sidebar: # About section with blue background st.markdown("""

About

This Resume Matching System helps you find the best candidates for your job openings. Simply input your job description and requirements, and our AI-powered system will analyze and rank resumes based on skill match, experience, and overall fit.

""", unsafe_allow_html=True) # How it Works section with light blue background st.markdown("""

How it Works

""", unsafe_allow_html=True) # Sample Job Descriptions section st.markdown("

Sample Job Descriptions

", unsafe_allow_html=True) # Display sample job descriptions in sidebar with smaller font st.write("Click any job to prefill the form:") # Create a container with custom CSS for smaller buttons st.markdown(""" """, unsafe_allow_html=True) # Add horizontal line before job listings st.markdown("
", unsafe_allow_html=True) # Job buttons for i, job in enumerate(job_posts): if st.button(job["title"], key=f"job_{i}"): # This will be used to set the job description text area st.session_state.job_description = job["jd"] # Main content area st.title("Resume Matching System") # Initialize session state for job description if it doesn't exist if 'job_description' not in st.session_state: st.session_state.job_description = "Enter job description here..." # Input fields - using session state for job description job_description = st.text_area("Job Description", value=st.session_state.job_description, height=250) additional_requirements = st.text_area("Additional Requirements", "", height=100) # Create two columns for the numeric inputs limit = st.slider("Number of Results", min_value=1, max_value=10, value=5, step=1) # Search button and animation container search_button = st.button("Search Resumes", type="primary") # Create a container for the code animation code_container = st.container() # Add custom CSS for the code animation box st.markdown(""" """, unsafe_allow_html=True) st.markdown(""" """, unsafe_allow_html=True) if search_button: # Prepare the API request url = f"{api_endpoint}/resumes/search" headers = { "accept": "application/json", "Content-Type": "application/json", "Authorization": hf_token } payload = { "job_description": job_description, "additional_requirements": additional_requirements, "limit": limit, } try: # Display the animation while waiting with code_container: # Create the black box with yellow code animation code_display = simulated_code_animation(code_container) import time strt_time=time.time() # Make the API request response = requests.post(url, headers=headers, json=payload) print(f"total time taken by fast api to generate answer: {time.time()-strt_time}") # Clear the code animation code_container.empty() if response.status_code == 200: # Process successful response data = response.json() st.success(f"Found {data['count']} matching resumes") # Display each resume with the new card-based layout for i, resume in enumerate(data['results']): resume_data = resume['resume_data'] explainability = resume['explainibility'] # Generate synthetic contact information full_name = resume_data.get('full_name', 'No Name') # Add synthetic data to resume_data if not present if 'email' not in resume_data and 'email_id' not in resume_data: resume_data['email'] = generate_email(full_name) if 'phone' not in resume_data: resume_data['phone'] = generate_phone_number() if 'linkedin_profile' not in resume_data and 'linkedin' not in resume_data: resume_data['linkedin'] = generate_linkedin(full_name) # Main card with essential information with st.container(): col1, col2 = st.columns([7, 3]) with col1: # Name with larger font and accent color st.markdown(f"""

{full_name}

""", unsafe_allow_html=True) # Years of experience with an icon years_exp = resume_data.get('total_experience_years', 'Not specified') st.markdown(f"""
Years of Experience: {years_exp}
""", unsafe_allow_html=True) # Summary in a nice box with a border summary = "" if 'overall_summary' in resume: summary = resume.get('overall_summary') elif isinstance(resume_data.get('summary'), str): summary = resume_data.get('summary') st.markdown(explainability) if summary: st.markdown(f"""
SUMMARY
{summary}
""", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) with col2: # Contact card with background st.markdown("""

CONTACT INFORMATION

""", unsafe_allow_html=True) # Email with icon email = resume_data.get('email', resume_data.get('email_id', 'Not provided')) st.markdown(f"""
Email:
{email}
""", unsafe_allow_html=True) # Phone with icon phone = resume_data.get('phone', 'Not provided') st.markdown(f"""
Phone:
{phone}
""", unsafe_allow_html=True) # Location with icon location = resume_data.get('location', 'Not specified') st.markdown(f"""
Location:
{location}
""", unsafe_allow_html=True) # LinkedIn with icon linkedin_url = resume_data.get('linkedin_profile', resume_data.get('linkedin', 'Not provided')) st.markdown(f"""
LinkedIn:
{linkedin_url.replace('https://', '')}
""", unsafe_allow_html=True) # Create expandable sections for details - MOVED INSIDE THE LOOP with st.expander(f"Resume Content for {full_name}", expanded=False): tabs = st.tabs(["All Skills", "Experience", "Projects", "Education"]) # All Skills tab with tabs[0]: st.subheader("Skills") if 'skills' in resume_data and resume_data['skills']: skills_html = "" for skill in resume_data['skills']: # Check if this skill is in matched_skills is_matched = skill in resume.get('matched_skills', []) badge_class = "skill-badge" if is_matched else "missing-skill-badge" skills_html += f'{skill} ' st.markdown(skills_html, unsafe_allow_html=True) else: st.write("No skills listed.") # Experiences tab with tabs[1]: st.subheader("Professional Experience") if 'experience' in resume_data and resume_data['experience']: for exp in resume_data['experience']: with st.container(): st.markdown(f"""
{exp.get('title', 'Position')} at {exp.get('company', 'Company')}
{exp.get('duration', '')}

{exp.get('description', '')}

""", unsafe_allow_html=True) elif 'professional_experiences' in resume_data and resume_data['professional_experiences']: for exp in resume_data['professional_experiences']: with st.container(): st.markdown(f"""
{exp.get('title', 'Position')} at {exp.get('company', 'Company')}
{exp.get('duration', '')}

{exp.get('description', '')}

""", unsafe_allow_html=True) else: st.write("No experience information available.") # Projects tab with tabs[2]: st.subheader("Projects") if 'projects' in resume_data and resume_data['projects']: for project in resume_data['projects']: if isinstance(project, dict): project_name = project.get('name', project.get('title', 'Project')) project_desc = project.get('description', '') st.markdown(f"**{project_name}**") st.markdown(f"{project_desc}") st.markdown("---") else: st.markdown(f"- {project}") else: st.write("No projects listed.") # Education tab with tabs[3]: st.subheader("Education") if 'education' in resume_data and resume_data['education']: for edu in resume_data['education']: with st.container(): st.markdown(f"""
{edu.get('degree', 'Degree')}
{edu.get('institution', 'Institution')}
{edu.get('date', '')}
""", unsafe_allow_html=True) else: st.write("No education information available.") st.markdown(""" """, unsafe_allow_html=True) # Create a centered container for the download button col1, col2, col3 = st.columns([1, 2, 1]) with col2: # Render the download button with icon st.markdown(f""" """, unsafe_allow_html=True) # Add a separator between resumes st.markdown("---") except Exception as e: # Clear the code animation in case of error code_container.empty() st.error(f"An error occurred: {str(e)}") if __name__ == "__main__": main()