Muhammad Salman Akbar commited on
Commit
318f9b1
1 Parent(s): 014511c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -44
app.py CHANGED
@@ -4,7 +4,7 @@ import re
4
  import torch
5
  from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModelForSeq2SeqLM
6
  from groq import Groq
7
- import gradio as gr
8
  from docxtpl import DocxTemplate
9
  from datetime import datetime
10
 
@@ -170,46 +170,29 @@ def generate_offer_letter(template_file, candidate_name, role, start_date, hours
170
  # Return the file object
171
  return open(docx_file_path, 'rb')
172
 
173
- # --- Gradio Interface ---
174
- demo = gr.Interface(
175
- fn=analyze_resume,
176
- inputs=[
177
- gr.File(label="Upload Resume (PDF or TXT)"),
178
- gr.File(label="Upload Job Description (TXT)"),
179
- ],
180
- outputs=[
181
- gr.Textbox(label="Similarity Score"),
182
- gr.Textbox(label="Communication Response"),
183
- gr.Textbox(label="Sentiment Analysis"),
184
- gr.Textbox(label="Resume Skills"),
185
- gr.Textbox(label="Job Description Skills"),
186
- gr.Textbox(label="Enhanced Resume", lines=20),
187
- gr.Textbox(label="Enhanced Job Description", lines=10),
188
- ],
189
- title="Resume and Job Description Analyzer",
190
- description="Upload your resume (PDF or TXT) and job description (TXT) to analyze their similarity, extract skills, and generate a communication response.",
191
- )
192
-
193
- offer_demo = gr.Interface(
194
- fn=generate_offer_letter,
195
- inputs=[
196
- gr.File(label="Upload Offer Letter Template (DOCX)"),
197
- gr.Textbox(label="Candidate Name"),
198
- gr.Textbox(label="Role"),
199
- gr.Textbox(label="Start Date (YYYY-MM-DD)"), # Use Textbox for date
200
- gr.Number(label="Hours per Week"),
201
- ],
202
- outputs=gr.File(label="Offer Letter"), # Change to gr.File
203
- title="Offer Letter Generator",
204
- description="Upload an offer letter template and enter candidate information to generate an offer letter.",
205
- )
206
-
207
- # Combine the interfaces using a Tabbed interface
208
- demo = gr.TabbedInterface(
209
- [demo, offer_demo],
210
- ["Resume Analyzer", "Offer Letter Generator"],
211
- title="HR Assistant",
212
- )
213
-
214
- if __name__ == '__main__':
215
- demo.launch(share=True)
 
4
  import torch
5
  from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModelForSeq2SeqLM
6
  from groq import Groq
7
+ import streamlit as st
8
  from docxtpl import DocxTemplate
9
  from datetime import datetime
10
 
 
170
  # Return the file object
171
  return open(docx_file_path, 'rb')
172
 
173
+ # --- Streamlit Interface ---
174
+ st.title("HR Assistant")
175
+
176
+ tab1, tab2 = st.tabs(["Resume Analyzer", "Offer Letter Generator"])
177
+
178
+ with tab1:
179
+ st.header("Resume and Job Description Analyzer")
180
+ resume_file = st.file_uploader("Upload Resume (PDF or TXT)", type=['pdf', 'txt'])
181
+ job_description_file = st.file_uploader("Upload Job Description (TXT)", type=['txt'])
182
+
183
+ if resume_file is not None and job_description_file is not None:
184
+ analysis_results = analyze_resume(resume_file, job_description_file)
185
+ for result in analysis_results:
186
+ st.markdown(result)
187
+
188
+ with tab2:
189
+ st.header("Offer Letter Generator")
190
+ template_file = st.file_uploader("Upload Offer Letter Template (DOCX)", type=['docx'])
191
+ candidate_name = st.text_input("Candidate Name")
192
+ role = st.text_input("Role")
193
+ start_date = st.text_input("Start Date (YYYY-MM-DD)")
194
+ hours = st.number_input("Hours per Week")
195
+
196
+ if template_file is not None and candidate_name and role and start_date and hours:
197
+ offer_letter = generate_offer_letter(template_file, candidate_name, role, start_date, hours)
198
+ st.download_button("Download Offer Letter", offer_letter, file_name=f"{candidate_name}_offer_letter.docx")