Download main.py from Ahmad140/Agent: direct link, hf CLI and curl.
- Browser
- Download file 5.53 kB
-
https://huggingface.co/spaces/Ahmad140/Agent/resolve/main/main.py
- Command line
-
hf download hf://spaces/Ahmad140/Agent/main.py
-
curl -L -o main.py https://huggingface.co/spaces/Ahmad140/Agent/resolve/main/main.py
5.53 kB
| # β οΈ Sab se pehle set_page_config call karo | |
| import streamlit as st | |
| st.set_page_config(page_title="AI Job Hunter", layout="wide") | |
| # Ab baaki imports karo | |
| from utils import extract_text_from_pdf, init_db, save_application | |
| from agents import ( | |
| ProfileParserAgent, JobSearchAgent, EmbeddingGenerator, | |
| MatchingRankingAgent, CompanyResearchAgent, ResumeTailoringAgent, | |
| CoverLetterAgent, ApplicationAgent, InterviewPrepAgent, | |
| NotificationAgent, AnalyticsAgent | |
| ) | |
| st.title("π€ AI Job Hunting Multi-Agent System") | |
| st.markdown("Powered by **Groq**, Pinecone, and Hugging Face Spaces") | |
| init_db() | |
| # Sidebar | |
| with st.sidebar: | |
| st.header("Your Inputs") | |
| uploaded_file = st.file_uploader("Upload Resume (PDF)", type=["pdf"]) | |
| job_titles = st.text_input("Job Titles (comma separated)", "AI Engineer, Machine Learning Engineer") | |
| locations = st.text_input("Locations (comma separated)", "Remote, Pakistan") | |
| start_btn = st.button("π Start Job Hunt", type="primary") | |
| if not start_btn: | |
| st.info("Fill the sidebar and click **Start Job Hunt**.") | |
| st.stop() | |
| if not uploaded_file: | |
| st.error("Please upload your resume PDF.") | |
| st.stop() | |
| # Workflow execution | |
| progress_bar = st.progress(0) | |
| status_text = st.empty() | |
| def update_step(step_num, total_steps, description, details=""): | |
| # β Fix: progress value ko 0 se 1 ke beech mein rakho | |
| progress = min(step_num / total_steps, 1.0) | |
| progress_bar.progress(progress) | |
| status_text.markdown(f"**Step {step_num}/{total_steps}:** {description}\n\n{details}") | |
| total_steps = 11 | |
| step = 0 | |
| # Step 1 | |
| step += 1 | |
| update_step(step, total_steps, "Parsing Resume", "Extracting text and profile...") | |
| resume_text = extract_text_from_pdf(uploaded_file) | |
| parser = ProfileParserAgent() | |
| candidate_profile = parser.run(resume_text) | |
| st.success(f"β Parsed: {candidate_profile.get('full_name', 'Candidate')}") | |
| # Step 2 | |
| step += 1 | |
| update_step(step, total_steps, "Generating Candidate Embedding", "") | |
| embed_gen = EmbeddingGenerator() | |
| candidate_vec = embed_gen.generate(resume_text) | |
| # Step 3 | |
| step += 1 | |
| update_step(step, total_steps, "Searching Job Portals", f"Looking for {job_titles} in {locations}") | |
| job_titles_list = [t.strip() for t in job_titles.split(",")] | |
| locations_list = [l.strip() for l in locations.split(",")] | |
| search_agent = JobSearchAgent() | |
| raw_jobs = search_agent.run(job_titles_list, locations_list) | |
| st.success(f"β Found {len(raw_jobs)} jobs") | |
| # Step 4 | |
| step += 1 | |
| update_step(step, total_steps, "Ranking Jobs via Semantic Search", "Using Pinecone + embeddings") | |
| matcher = MatchingRankingAgent() | |
| ranked_jobs = matcher.run(candidate_profile, raw_jobs) | |
| st.write("**Top matches:**") | |
| for idx, rj in enumerate(ranked_jobs[:3]): | |
| st.write(f"{idx+1}. **{rj['job']['title']}** at {rj['job']['company']} β Match: {rj['match_percent']}%") | |
| selected_jobs = ranked_jobs[:3] | |
| # Process each job | |
| for idx, job_data in enumerate(selected_jobs): | |
| job = job_data['job'] | |
| match_percent = job_data['match_percent'] | |
| st.divider() | |
| st.subheader(f"Processing: {job['title']} @ {job['company']} (Match {match_percent}%)") | |
| # Step 5 | |
| step += 1 | |
| update_step(step, total_steps, "Company Research", f"Researching {job['company']}") | |
| company_research = CompanyResearchAgent().run(job['company']) | |
| st.write("π Company Summary:", company_research[:200] + "...") | |
| # Step 6 | |
| step += 1 | |
| update_step(step, total_steps, "Tailoring Resume", f"Customizing for {job['title']}") | |
| tailor_agent = ResumeTailoringAgent() | |
| tailored_resume = tailor_agent.run(resume_text, job['description'], job['title']) | |
| st.text_area("βοΈ Tailored Resume (excerpt)", tailored_resume[:500] + "...", height=150) | |
| # Step 7 | |
| step += 1 | |
| update_step(step, total_steps, "Generating Cover Letter", f"Writing for {job['company']}") | |
| cover_agent = CoverLetterAgent() | |
| cover_letter = cover_agent.run(candidate_profile.get('full_name','Candidate'), job['title'], job['company'], job['description'], candidate_profile.get('skills',[])) | |
| st.text_area("π Cover Letter", cover_letter, height=150) | |
| # Step 8 | |
| step += 1 | |
| update_step(step, total_steps, "Submitting Application", f"Auto-filling for {job['company']}") | |
| app_agent = ApplicationAgent() | |
| submission = app_agent.run(job['url'], tailored_resume, cover_letter) | |
| st.success(f"β Application submitted: {submission['status']}") | |
| save_application(job['title'], job['company'], match_percent, submission['status'], "tailored.txt", "cover.txt") | |
| # Step 9 | |
| step += 1 | |
| update_step(step, total_steps, "Interview Preparation", f"Generating Q&A for {job['title']}") | |
| interview_agent = InterviewPrepAgent() | |
| prep_notes = interview_agent.run(job['title'], job['description'], job['company']) | |
| with st.expander("π Interview Prep Q&A"): | |
| st.write(prep_notes) | |
| # Step 10 | |
| step += 1 | |
| update_step(step, total_steps, "Notification", "Sending update") | |
| NotificationAgent().run(f"Applied to {job['title']} at {job['company']} (match {match_percent}%)", channel="ui") | |
| # Step 11 | |
| step += 1 | |
| update_step(step, total_steps, "Analytics Dashboard", "Computing metrics") | |
| analytics = AnalyticsAgent().run() | |
| st.subheader("π Dashboard") | |
| col1, col2, col3 = st.columns(3) | |
| col1.metric("Total Applications", analytics['total_applications']) | |
| col2.metric("Avg Match Score", f"{analytics['avg_match_score']:.1f}%") | |
| col3.metric("Submitted Count", analytics['submitted_count']) | |
| st.success("π Workflow completed!") | |
| st.balloons() |