mgbam commited on
Commit
d068091
·
verified ·
1 Parent(s): 95118a5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +92 -0
app.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ import requests
4
+ from dotenv import load_dotenv
5
+
6
+ load_dotenv()
7
+
8
+ BACKEND_URL = "http://127.0.0.1:5000/api" # Adjust if hosted elsewhere
9
+
10
+ def generate_resume(name, email, phone, summary, experience, education, skills):
11
+ payload = {
12
+ "name": name,
13
+ "email": email,
14
+ "phone": phone,
15
+ "summary": summary,
16
+ "experience": experience,
17
+ "education": education,
18
+ "skills": skills
19
+ }
20
+ response = requests.post(f"{BACKEND_URL}/generate", json=payload)
21
+ if response.status_code == 200:
22
+ return response.json().get("resume", "")
23
+ return f"Error: {response.text}"
24
+
25
+ def score_resume(resume_text, job_description):
26
+ payload = {
27
+ "resume": resume_text,
28
+ "job_description": job_description
29
+ }
30
+ response = requests.post(f"{BACKEND_URL}/score", json=payload)
31
+ if response.status_code == 200:
32
+ data = response.json()
33
+ return f"Score: {data['score']}/100\nSuggestions:\n" + "\n".join(data['suggestions'])
34
+ return f"Error: {response.text}"
35
+
36
+ def refine_section(section_text, instruction):
37
+ payload = {
38
+ "text": section_text,
39
+ "instruction": instruction
40
+ }
41
+ response = requests.post(f"{BACKEND_URL}/refine_section", json=payload)
42
+ if response.status_code == 200:
43
+ return response.json().get("refined_text", "")
44
+ return f"Error: {response.text}"
45
+
46
+ with gr.Blocks() as demo:
47
+ gr.Markdown("## 🤖 AI Resume Builder")
48
+
49
+ with gr.Tab("1️⃣ Generate Resume"):
50
+ with gr.Row():
51
+ name = gr.Textbox(label="Name")
52
+ email = gr.Textbox(label="Email")
53
+ phone = gr.Textbox(label="Phone")
54
+ summary = gr.Textbox(label="Professional Summary")
55
+ experience = gr.Textbox(label="Experience")
56
+ education = gr.Textbox(label="Education")
57
+ skills = gr.Textbox(label="Skills")
58
+ resume_output = gr.Textbox(label="Generated Resume", lines=15)
59
+ generate_btn = gr.Button("Generate Full Resume")
60
+
61
+ generate_btn.click(
62
+ generate_resume,
63
+ inputs=[name, email, phone, summary, experience, education, skills],
64
+ outputs=resume_output
65
+ )
66
+
67
+ with gr.Tab("2️⃣ Score Resume Against Job"):
68
+ resume_input = gr.Textbox(label="Your Resume", lines=10)
69
+ job_desc = gr.Textbox(label="Job Description", lines=5)
70
+ score_output = gr.Textbox(label="Job Match Score + Suggestions", lines=10)
71
+ score_btn = gr.Button("Evaluate")
72
+
73
+ score_btn.click(
74
+ score_resume,
75
+ inputs=[resume_input, job_desc],
76
+ outputs=score_output
77
+ )
78
+
79
+ with gr.Tab("3️⃣ Refine Resume Section"):
80
+ section_input = gr.Textbox(label="Resume Section", lines=5)
81
+ instruction_input = gr.Textbox(label="Refinement Instruction (e.g., make it more concise)")
82
+ refined_output = gr.Textbox(label="Refined Text", lines=5)
83
+ refine_btn = gr.Button("Refine")
84
+
85
+ refine_btn.click(
86
+ refine_section,
87
+ inputs=[section_input, instruction_input],
88
+ outputs=refined_output
89
+ )
90
+
91
+ if __name__ == "__main__":
92
+ demo.launch()