File size: 3,334 Bytes
8d404bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import os
import json

import google.generativeai as genai

API_KEY = "AIzaSyCA4__JMC_ZIQ9xQegIj5LOMLhSSrn3pMw"

def configure_genai_api():
  
        genai.configure(api_key=API_KEY)
        generation_config = {
            "temperature": 0.9,
            "top_p": 1,
            "top_k": 40,
            "max_output_tokens": 2048,
        }
        safety_settings = [
            {"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
            {"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
            {"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
            {"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
        ]
        return genai.GenerativeModel(model_name="gemini-1.0-pro",
                                     generation_config=generation_config,
                                     safety_settings=safety_settings)

def load_user_data():
    try:
        with open('gemini_responses.json', 'r') as file:
            return json.load(file)
    except FileNotFoundError:
        st.error("User data file not found. Please ensure 'gemini_responses.json' exists.")
        return {}

def load_data():
    try:
        with open('data.json', 'r') as file:
            return json.load(file)
    except FileNotFoundError:
        st.error("Data file not found. Please ensure 'data.json' exists.")
        return {}

def combine_responses(user_data, data, *args):
    combined_responses = []
    for key, value in user_data.items():
        combined_responses.append(f"{key}: {value}")
    combined_responses.append(f"Name: {data['name']}")
    combined_responses.append(f"Email: {data['email']}")
    combined_responses.append(f"LinkedIn: {data['linkedin']}")
    combined_responses.append(f"GitHub: {data['github']}")
    for response_set in args:
        if isinstance(response_set, dict):
            combined_responses.extend(response_set.values())
        elif isinstance(response_set, list):
            combined_responses.extend(response_set)
    combined_responses.extend(data.values())  # Add data.json values
    return " ".join(combined_responses)


def app():
    st.header("Resume Creator")
    model = configure_genai_api()
    if not model:
        return
    
    # Load user data
    user_data = load_user_data()
    data = load_data()  

    combined_responses_text = combine_responses(user_data, data)  # Pass the 'data' argument

    prompt_template = f"""
    Based on the following inputs, print the basic details in proper manner line by line (name, github url, etc), generate a professional resume that includes sections for a Summary, Experience, Skills, Certifications (dont give education section).
    {combined_responses_text}
    Provide optimized content for each section of the resume to highlight the individual's qualifications, achievements, and career progression.
    """

   

    try:
        response = model.generate_content([prompt_template])
        st.subheader("Resume Content")
        st.write(response.text)
    except Exception as e:
        st.error("An error occurred while generating your Resume content. Please try again later.")
        st.error(f"Error: {e}")

if __name__ == "__main__":
    app()