| 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()) |
| return " ".join(combined_responses) |
|
|
|
|
| def app(): |
| st.header("Resume Creator") |
| model = configure_genai_api() |
| if not model: |
| return |
| |
| |
| user_data = load_user_data() |
| data = load_data() |
|
|
| combined_responses_text = combine_responses(user_data, data) |
|
|
| 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() |
|
|