Ram-1103 commited on
Commit
804e096
Β·
verified Β·
1 Parent(s): ed5a2b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -47
app.py CHANGED
@@ -1,10 +1,10 @@
1
  import gradio as gr
2
- from huggingface_hub import InferenceClient
3
  import os
 
4
 
5
  client = InferenceClient(
6
- model="mistralai/Mistral-7B-Instruct-v0.3",
7
- token=os.environ.get("Rejected_tk") # Uses the Space's built-in HF token automatically
8
  )
9
 
10
  SYSTEM_PROMPT = """You are a brutally honest but helpful senior hiring manager with 15 years of experience.
@@ -37,37 +37,36 @@ You must output your response in this exact structure:
37
  ## πŸ’‘ One Honest Verdict
38
  [One sentence: should they apply now, in 3 months, or pivot entirely?]
39
 
40
- Be specific. Name actual technologies. Do not be vague. Do not be encouraging unless there is a real reason to be."""
41
 
42
 
43
  def analyze(resume_text, job_description):
44
  if not resume_text.strip() or not job_description.strip():
45
  return "⚠️ Please paste both your resume and the job description."
46
 
47
- user_message = f"""Here is the candidate's resume:
48
  ---
49
  {resume_text}
50
  ---
51
-
52
- Here is the job description they want to apply to:
53
  ---
54
  {job_description}
55
  ---
56
-
57
- Tell them exactly why they will be rejected and what to do about it."""
58
 
59
  try:
60
- response = client.chat_completion(
61
- messages=[
62
- {"role": "system", "content": SYSTEM_PROMPT},
63
- {"role": "user", "content": user_message}
64
- ],
65
- max_tokens=1024,
66
  temperature=0.7,
67
- )
68
- return response.choices[0].message.content
 
 
69
  except Exception as e:
70
- return f"❌ Error: {str(e)}\n\nTry refreshing the page and clicking the button again."
 
71
 
72
  EXAMPLE_RESUME = """Name: Priya Sharma
73
  Education: M.S. Computer Science, 2024
@@ -95,54 +94,55 @@ Requirements:
95
  - Experience with data pipelines: Spark, Kafka, Airflow
96
  - Nice to have: ONNX optimization, TensorRT, model quantization"""
97
 
98
-
99
- with gr.Blocks(
100
- theme=gr.themes.Soft(),
101
- title="Rejected Before Applying",
102
- css="""
103
- .header { text-align: center; margin-bottom: 20px; }
104
- .warning-box { background: #fff3cd; border-left: 4px solid #ff6b35; padding: 12px; border-radius: 6px; }
105
- """
106
- ) as demo:
 
 
 
 
 
107
  gr.HTML("""
108
- <div class='header'>
109
  <h1>πŸ’” Rejected Before Applying</h1>
110
- <p style='font-size:1.1em; color:#666;'>
111
- Find out <b>exactly why</b> your resume won't make it β€” before you waste the application.
112
- </p>
113
- <p style='color:#888; font-size:0.9em;'>Powered by Qwen2.5-3B β€’ No data stored β€’ Brutal honesty guaranteed</p>
114
  </div>
115
  """)
116
 
117
- with gr.Row():
118
  with gr.Column():
119
  resume_input = gr.Textbox(
120
- label="πŸ“„ Your Resume (paste as plain text)",
121
  placeholder="Paste your resume here β€” skills, experience, education, projects...",
122
- lines=15,
123
  value=EXAMPLE_RESUME
124
  )
125
  with gr.Column():
126
  jd_input = gr.Textbox(
127
- label="πŸ’Ό Job Description (paste the full JD)",
128
- placeholder="Paste the job description here...",
129
- lines=15,
130
  value=EXAMPLE_JD
131
  )
132
 
133
- analyze_btn = gr.Button("πŸ” Analyse My Rejection", variant="primary", size="lg")
 
 
134
 
135
- output = gr.Markdown(label="Your Rejection Report")
136
 
137
- analyze_btn.click(
138
- fn=analyze,
139
- inputs=[resume_input, jd_input],
140
- outputs=output
141
- )
142
 
143
  gr.HTML("""
144
- <div style='text-align:center; margin-top:20px; color:#aaa; font-size:0.85em;'>
145
- Built for the πŸ€— Build Small Hackathon β€’ Small model, real talk
146
  </div>
147
  """)
148
 
 
1
  import gradio as gr
 
2
  import os
3
+ from huggingface_hub import InferenceClient
4
 
5
  client = InferenceClient(
6
+ model="HuggingFaceH4/zephyr-7b-beta",
7
+ token=os.environ.get("Rejected_tk")
8
  )
9
 
10
  SYSTEM_PROMPT = """You are a brutally honest but helpful senior hiring manager with 15 years of experience.
 
37
  ## πŸ’‘ One Honest Verdict
38
  [One sentence: should they apply now, in 3 months, or pivot entirely?]
39
 
40
+ Be specific. Name actual technologies. Do not be vague."""
41
 
42
 
43
  def analyze(resume_text, job_description):
44
  if not resume_text.strip() or not job_description.strip():
45
  return "⚠️ Please paste both your resume and the job description."
46
 
47
+ user_message = f"""Resume:
48
  ---
49
  {resume_text}
50
  ---
51
+ Job Description:
 
52
  ---
53
  {job_description}
54
  ---
55
+ Tell them exactly why they will be rejected and give the full structured report."""
 
56
 
57
  try:
58
+ result = ""
59
+ for token in client.text_generation(
60
+ prompt=f"<|system|>\n{SYSTEM_PROMPT}</s>\n<|user|>\n{user_message}</s>\n<|assistant|>\n",
61
+ max_new_tokens=1024,
 
 
62
  temperature=0.7,
63
+ stream=True,
64
+ ):
65
+ result += token
66
+ return result
67
  except Exception as e:
68
+ return f"❌ Error: {str(e)}"
69
+
70
 
71
  EXAMPLE_RESUME = """Name: Priya Sharma
72
  Education: M.S. Computer Science, 2024
 
94
  - Experience with data pipelines: Spark, Kafka, Airflow
95
  - Nice to have: ONNX optimization, TensorRT, model quantization"""
96
 
97
+ css = """
98
+ body { background: #0f0f1a !important; }
99
+ .gradio-container { max-width: 1100px !important; margin: auto; }
100
+ #title-block { text-align: center; padding: 30px 0 10px 0; }
101
+ #title-block h1 { font-size: 2.8em; font-weight: 900; background: linear-gradient(90deg, #ff6b6b, #ff8e53, #ff6bff); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
102
+ #title-block p { color: #aaa; font-size: 1.05em; }
103
+ .gr-button-primary { background: linear-gradient(90deg, #ff416c, #ff4b2b) !important; border: none !important; font-size: 1.1em !important; padding: 14px !important; border-radius: 10px !important; font-weight: 700 !important; letter-spacing: 0.5px; }
104
+ .gr-button-primary:hover { transform: scale(1.02); box-shadow: 0 0 20px #ff416c88 !important; }
105
+ .gr-textbox textarea { background: #1a1a2e !important; color: #e0e0e0 !important; border: 1px solid #333 !important; border-radius: 10px !important; font-size: 0.92em !important; }
106
+ .gr-markdown { background: #1a1a2e !important; border-radius: 12px !important; padding: 20px !important; border: 1px solid #2a2a4a !important; color: #e0e0e0 !important; }
107
+ label { color: #ccc !important; font-weight: 600 !important; }
108
+ """
109
+
110
+ with gr.Blocks(title="Rejected Before Applying", css=css) as demo:
111
  gr.HTML("""
112
+ <div id='title-block'>
113
  <h1>πŸ’” Rejected Before Applying</h1>
114
+ <p>Find out <b>exactly why</b> your resume won't make it β€” before you waste the application.</p>
115
+ <p style='color:#666; font-size:0.85em;'>⚑ Powered by Zephyr-7B &nbsp;β€’&nbsp; πŸ”’ No data stored &nbsp;β€’&nbsp; 🎯 Brutal honesty guaranteed</p>
 
 
116
  </div>
117
  """)
118
 
119
+ with gr.Row(equal_height=True):
120
  with gr.Column():
121
  resume_input = gr.Textbox(
122
+ label="πŸ“„ Your Resume",
123
  placeholder="Paste your resume here β€” skills, experience, education, projects...",
124
+ lines=16,
125
  value=EXAMPLE_RESUME
126
  )
127
  with gr.Column():
128
  jd_input = gr.Textbox(
129
+ label="πŸ’Ό Job Description",
130
+ placeholder="Paste the full job description here...",
131
+ lines=16,
132
  value=EXAMPLE_JD
133
  )
134
 
135
+ analyze_btn = gr.Button("πŸ” Analyse My Rejection", variant="primary", size="lg")
136
+
137
+ gr.HTML("<div style='margin:10px 0 6px 0; color:#888; font-size:0.85em; text-align:center;'>⏳ Analysis takes ~15 seconds β€” hang tight</div>")
138
 
139
+ output = gr.Markdown(label="πŸ“‹ Your Rejection Report", value="*Your rejection report will appear here...*")
140
 
141
+ analyze_btn.click(fn=analyze, inputs=[resume_input, jd_input], outputs=output)
 
 
 
 
142
 
143
  gr.HTML("""
144
+ <div style='text-align:center; margin-top:24px; color:#555; font-size:0.82em;'>
145
+ Built for the πŸ€— <b>Build Small Hackathon</b> &nbsp;β€’&nbsp; Small model, real talk
146
  </div>
147
  """)
148