Spaces:
Build error
Build error
| import streamlit as st | |
| from pdf_to_image import pdf_to_image | |
| from image_to_text import image_to_text | |
| from mirascope_extractor import extractor | |
| import google.generativeai as genai | |
| import pandas as pd | |
| import glob | |
| import os | |
| # from dotenv import load_dotenv | |
| import streamlit as st | |
| from resume_recommender import recommend_resume | |
| # load_dotenv() | |
| global empty_df | |
| openai_api_key = os.environ['OPENAI_API_KEY'] | |
| print('This is API key: ', openai_api_key) | |
| genai.configure(api_key=openai_api_key) | |
| st.set_page_config(page_title="CV Recommendor Gen AI") | |
| st.title("Gen AI CV Recommender") | |
| st.write(""" | |
| **Find the Best Candidates for Your Job!** | |
| π **What It Does:** | |
| - Analyzes multiple resumes in PDF format. | |
| - Matches them with your job description. | |
| π **How It Works:** | |
| 1. Upload resumes π | |
| 2. Upload the job description π | |
| 3. Get a table of top recommended candidates π | |
| Ready to find the perfect fit? Let's get started! | |
| """) | |
| uploaded_files = st.sidebar.file_uploader("Choose PDF files", accept_multiple_files=True, type="pdf") | |
| job_description = st.sidebar.text_input('Enter Job Description') | |
| if uploaded_files and job_description: | |
| if st.sidebar.button('AI Recommendation'): | |
| image_bytes = pdf_to_image(uploaded_files) | |
| all_texts = [] | |
| for image_byte in image_bytes: | |
| print('This is image_byte: ', image_byte) | |
| combine_text = '' | |
| for image in image_byte: | |
| text = image_to_text(image) | |
| combine_text += text | |
| print('This is the text from single PDF: ', combine_text) | |
| all_texts.append(combine_text) | |
| empty_df = pd.DataFrame() | |
| for text in all_texts: | |
| extracted_text = extractor(text) | |
| task_details_dict = extracted_text.dict() | |
| df = pd.DataFrame([task_details_dict]) | |
| empty_df = pd.concat([empty_df, df]) | |
| recommend_df = recommend_resume(empty_df, job_description) | |
| if 'Unnamed: 0' in recommend_df.columns: | |
| recommend_df = recommend_df.drop('Unnamed: 0', axis=1) | |
| print('Recommendation process done successfully') | |
| st.write(recommend_df) | |
| # csv = empty_df.to_csv(index=False) | |
| # st.download_button( | |
| # label = 'Click to Download CSV', | |
| # data = csv, | |
| # file_name = 'Extracted_data.csv', | |
| # mime='text/csv', | |
| # ) | |