File size: 4,038 Bytes
86723f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c72bf01
86723f0
c72bf01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86723f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import gradio as gr
import yagmail
from datasets import load_dataset, Dataset, concatenate_datasets
import pandas as pd
import os
from dotenv import load_dotenv
load_dotenv()  # Load environment variables from.env file

# Email Sending Function
def send_email(hr_email, subject, body, resume_path, sender_email, sender_password):
    yag = yagmail.SMTP(user=sender_email, password=sender_password)
    yag.send(to=hr_email, subject=subject, contents=body, attachments=resume_path)

# Load Existing Dataset or Create a New One
def load_hf_dataset(repo_id):
    try:
        dataset = load_dataset(repo_id, split="train")
        return dataset
    except Exception:
        return None

# Save Data to Hugging Face Dataset
def save_to_hf_dataset(repo_id, new_data, existing_dataset=None):
    try:
        new_dataset = Dataset.from_dict(new_data)
        if existing_dataset:
            updated_dataset = concatenate_datasets([existing_dataset, new_dataset])
        else:
            updated_dataset = new_dataset
        hf_token = os.getenv('HF_TOKEN')
        if not hf_token:
            raise ValueError("Hugging Face token is missing or invalid")
        updated_dataset.push_to_hub(repo_id)
        return True
    except Exception as e:
        print(f"Error saving to dataset: {e}")
        return False

# Main Function for Gradio Interface
def process_form(hr_email, job_profile, company_name, city, access_id):
    resume_path = "SujalTamrakar.py.pdf"
    email_body = f"""  
Dear Hiring Manager,

I'm excited to apply for the {job_profile} role at {company_name}. With a strong IT background (B.Tech, CGPA: 7.97) and experience in AI, Machine Learning, and Web Development, I'm confident in my ability to contribute to your team.

Key Highlights:

- AI Intern at VKAPS IT Solutions: Built & deployed AI projects using LangChain Python OpenAI
- Data Science Trainee at Grow Tech: Utilized exploratory data analysis and SQL
- Projects: Online Code Review Tool, Automatic Ticket Classification Tool (details on attached resume)

Tech Skills:

- Programming: Python, SQL
- AI/ML: LangChain, LLMs, Pinecone, Cohere
- Web Dev: Streamlit
Attached: Resume (including full project details, education, and additional experience)

Contact:

- Email: sujal.tamrakar@outlook.com
- Phone: +91-7067599678
- LinkedIn: linkedin.com/in/sujaltamrakar
- GitHub: github.com/sujal03

Best Regards, Sujal Tamrakar
    """
    
    sender_email = os.getenv('SENDER_EMAIL')
    sender_password = os.getenv('SENDER_PASSWORD') if access_id=='2003' else None
        
    if sender_password:
        try:
            send_email(hr_email, f"Application for {job_profile} at {company_name}", email_body, resume_path, sender_email, sender_password)
            print("Email sent successfully!")
            
            new_data = {
                "hr_email": [hr_email],
                "job_profile": [job_profile],
                "company_name": [company_name],
                "company_city": [city]
            }
            
            existing_dataset = load_hf_dataset("suzall/mails")
            if save_to_hf_dataset("suzall/mails", new_data, existing_dataset):
                print("Data saved to Hugging Face dataset successfully!")
            return "Email Sent and Data Saved Successfully!"
        except Exception as e:
            return f"Error: {e}"
    else:
        return "Invalid Access ID for sending email."

# Gradio Interface
demo = gr.Interface(
    fn=process_form,
    inputs=[
        gr.Textbox(label="HR's Email", placeholder="hr@example.com"),
        gr.Textbox(label="Job Profile", placeholder="e.g., Python Developer"),
        gr.Textbox(label="Company Name", placeholder="e.g., Accenture"),
        gr.Textbox(label="City", placeholder="e.g., Pune"),
        gr.Textbox(label="Access ID", placeholder="Enter Access ID")
    ],
    outputs=gr.Textbox(label="Output"),
    title="Email Sender",
    description="Send an email to HR with your application details.",
)

if __name__ == "__main__":
    demo.launch()