File size: 3,863 Bytes
3eb5441
 
 
 
 
 
 
 
 
 
 
 
8160bb3
 
f881b91
8160bb3
 
 
 
 
 
 
 
 
 
 
 
24de1bf
1874769
838d2be
 
 
 
 
 
 
9d8232e
838d2be
 
 
 
9d8232e
 
1874769
64df11f
 
 
 
 
 
 
 
 
 
 
 
 
e7cb1d2
 
 
 
 
 
 
 
 
 
 
 
797951b
 
 
 
 
e7cb1d2
 
 
 
 
64df11f
e7cb1d2
 
 
 
 
 
 
 
 
 
 
 
b7e5f96
e7cb1d2
 
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
import streamlit as st
import google.generativeai as genai

# App header
st.header("Candidate Outreach Using Ai")

# Retrieve the API key from Streamlit secrets
GOOGLE_API_KEY = st.secrets["GEMINI_API_KEY"]

# Configure the Google Generative AI API with your API key
genai.configure(api_key=GOOGLE_API_KEY)

# Create a container for better grouping
with st.container():
    st.subheader("Enter Candidate Details:")
    
    # Create two columns for alignment
    col1, col2 = st.columns([2, 3])  # Adjust column proportions as needed

    # First column for candidate details
    with col1:
        candidate_name = st.text_input('Candidate Name:', '')
        candidate_designation = st.text_input('Candidate Designation:', '')
        candidate_details = st.text_input('Candidate Details - Skills, Experience (comma separated):', '')

    # Second column for job description
    with col2:
        job_description = st.text_area('Your Job Description:', '', height=250)

# Dropdown menu for tone selection
st.subheader("Select the Tone of the Message:")
tone_options = ["Formal", "Friendly", "Persuasive", "Neutral"]
selected_tone = st.selectbox("Tone", tone_options)

# Buttons for message type
st.subheader("Select Message Type:")
col1, col2, col3 = st.columns(3)
with col1:
    linkedin_invite = st.button("LinkedIn Invite")
with col2:
    email_invite = st.button("Email Invite")
with col3:
    whatsapp_invite = st.button("Whatsapp Invite")

# Generate message based on input
if linkedin_invite or email_invite or whatsapp_invite:
    if not candidate_name or not candidate_designation or not candidate_details or not job_description:
        st.error("Please fill in all the above details before proceeding.")
    else:
        if linkedin_invite:
            message_type = "LinkedIn Invite"
        elif email_invite:
            message_type = "Email Invite"
        else:
            message_type = "WhatsApp Invite"
        st.info(f"Generating {message_type}...")

        # Construct the prompt for analysis
        prompt = f"""
        
        Candidate Details:
        - Name: {candidate_name}
        - Designation: {candidate_designation}
        - Details: {candidate_details}
        
        Job Description:
        {job_description}
        
        ### Tasks:
        "Write a personalized {message_type.lower()} message for candidate outreach. The message should maintain a {selected_tone.lower()} tone and adhere 
        to professional communication standards.
        Use the provided candidate details (Name: {candidate_name}, Designation: {candidate_designation}, Skills and Experience: {candidate_details}) 
        and the job description ({job_description}) to craft the message.
        Highlight why the candidate is a strong fit for the role, referencing their skills and experience concerning the job requirements. Ensure the message is engaging, concise, and tailored to the platform ({message_type.lower()})."
        """
        
        try:
            # Initialize the generative model
            model = genai.GenerativeModel("gemini-pro")

            # Generate content using the Gemini API
            response = model.generate_content(
                        prompt,
                        generation_config=genai.types.GenerationConfig(
                            temperature=0.0,          # Ensures deterministic output
                            max_output_tokens=500,    # Limits the response length to 500 tokens
                            candidate_count=1         # Generates only one candidate
                        )
                    )
            
            # Display the generated message
            st.success(f"{message_type} Generated:")
            st.write(response.text)
        except Exception as e:
            st.error(f"An error occurred while generating the message: {e}")