mgbam's picture
Update app.py
5fdef64 verified
raw
history blame
3.05 kB
import gradio as gr
import google.generativeai as genai
import os
from dotenv import load_dotenv
# Load environment variable
load_dotenv()
API_KEY = os.getenv("GEMINI_API_KEY")
genai.configure(api_key=API_KEY)
model = genai.GenerativeModel("gemini-pro")
# --- AI Functions ---
def generate_resume(name, email, phone, summary, experience, education, skills):
prompt = f"""
Create a professional resume using the following details:
Name: {name}
Email: {email}
Phone: {phone}
Summary:
{summary}
Experience:
{experience}
Education:
{education}
Skills:
{skills}
Format it clearly and professionally.
"""
response = model.generate_content(prompt)
return response.text
def score_resume(resume, job_desc):
prompt = f"""
Evaluate how well the following resume matches the job description below.
Return a match score out of 100 and specific, actionable suggestions to improve the resume.
Resume:
{resume}
Job Description:
{job_desc}
"""
response = model.generate_content(prompt)
return response.text
def refine_section(section_text, instruction):
prompt = f"Refine this section according to the instruction.\nInstruction: {instruction}\nText: {section_text}"
response = model.generate_content(prompt)
return response.text
# --- Gradio UI ---
with gr.Blocks() as demo:
gr.Markdown("## 🤖 AI Resume Builder using Gemini")
with gr.Tab("1️⃣ Generate Resume"):
name = gr.Textbox(label="Name")
email = gr.Textbox(label="Email")
phone = gr.Textbox(label="Phone")
summary = gr.Textbox(label="Professional Summary")
experience = gr.Textbox(label="Experience")
education = gr.Textbox(label="Education")
skills = gr.Textbox(label="Skills")
resume_output = gr.Textbox(label="Generated Resume", lines=15)
generate_btn = gr.Button("Generate Resume")
generate_btn.click(
fn=generate_resume,
inputs=[name, email, phone, summary, experience, education, skills],
outputs=resume_output
)
with gr.Tab("2️⃣ Score Resume Against Job"):
resume_input = gr.Textbox(label="Your Resume", lines=10)
job_desc = gr.Textbox(label="Job Description", lines=5)
score_output = gr.Textbox(label="Match Score & Suggestions", lines=10)
score_btn = gr.Button("Evaluate")
score_btn.click(
fn=score_resume,
inputs=[resume_input, job_desc],
outputs=score_output
)
with gr.Tab("3️⃣ Refine Resume Section"):
section_input = gr.Textbox(label="Resume Section", lines=5)
instruction_input = gr.Textbox(label="Refinement Instruction")
refined_output = gr.Textbox(label="Refined Text", lines=5)
refine_btn = gr.Button("Refine")
refine_btn.click(
fn=refine_section,
inputs=[section_input, instruction_input],
outputs=refined_output
)
demo.launch()