Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,14 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from docx import Document
|
| 3 |
import io
|
| 4 |
-
import
|
| 5 |
-
import pandas as pd
|
| 6 |
|
| 7 |
-
# Load
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
|
| 12 |
# Function to create a Word document with the job description
|
| 13 |
def create_word_document(designation, job_description):
|
|
@@ -24,7 +25,7 @@ def create_word_document(designation, job_description):
|
|
| 24 |
|
| 25 |
# Streamlit app layout
|
| 26 |
st.set_page_config(
|
| 27 |
-
page_title="Job Description Generator",
|
| 28 |
page_icon="👷♂️",
|
| 29 |
layout="wide"
|
| 30 |
)
|
|
@@ -46,10 +47,6 @@ st.markdown("""
|
|
| 46 |
background-color: #ffffff;
|
| 47 |
border-radius: 5px;
|
| 48 |
}
|
| 49 |
-
.stTextInput>div>div>input {
|
| 50 |
-
background-color: #ffffff;
|
| 51 |
-
border-radius: 5px;
|
| 52 |
-
}
|
| 53 |
.header {
|
| 54 |
font-size: 36px;
|
| 55 |
color: #333333;
|
|
@@ -65,55 +62,48 @@ st.markdown("""
|
|
| 65 |
""", unsafe_allow_html=True)
|
| 66 |
|
| 67 |
# Header
|
| 68 |
-
st.markdown('<div class="header">Construction
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
-
#
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
# Step 1: Select Department
|
| 74 |
st.markdown('<div class="subheader">Step 1: Select Department</div>', unsafe_allow_html=True)
|
| 75 |
-
department = st.selectbox("Select the department:", list(
|
| 76 |
|
| 77 |
-
# Step 2: Select
|
| 78 |
if department:
|
| 79 |
-
st.markdown('<div class="subheader">Step 2: Select
|
| 80 |
-
|
| 81 |
|
| 82 |
-
if
|
| 83 |
-
#
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
# Display job description
|
| 87 |
st.markdown('<div class="subheader">Generated Job Description</div>', unsafe_allow_html=True)
|
| 88 |
-
st.write(
|
| 89 |
|
| 90 |
# Create Word document
|
| 91 |
-
doc_io = create_word_document(
|
| 92 |
|
| 93 |
# Download button for Word document
|
| 94 |
st.download_button(
|
| 95 |
label="Download Job Description as Word",
|
| 96 |
data=doc_io,
|
| 97 |
-
file_name=f"{
|
| 98 |
mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
| 99 |
)
|
| 100 |
else:
|
| 101 |
-
st.warning("Please select a department and
|
| 102 |
-
|
| 103 |
-
# Optional: Search functionality
|
| 104 |
-
st.markdown('<div class="subheader">Or Search for a Role Across All Departments</div>', unsafe_allow_html=True)
|
| 105 |
-
search_query = st.text_input("Search for a role:")
|
| 106 |
-
|
| 107 |
-
if search_query:
|
| 108 |
-
# Flatten the data to search across all departments
|
| 109 |
-
flat_data = {f"{dept} - {role}": desc for dept, roles in data.items() for role, desc in roles.items()}
|
| 110 |
-
results = {key: value for key, value in flat_data.items() if search_query.lower() in key.lower()}
|
| 111 |
-
|
| 112 |
-
if results:
|
| 113 |
-
st.markdown('<div class="subheader">Search Results</div>', unsafe_allow_html=True)
|
| 114 |
-
for result, desc in results.items():
|
| 115 |
-
st.write(f"**{result}**")
|
| 116 |
-
st.write(desc)
|
| 117 |
-
st.markdown("---")
|
| 118 |
-
else:
|
| 119 |
-
st.warning("No matching roles found.")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from docx import Document
|
| 3 |
import io
|
| 4 |
+
from transformers import pipeline
|
|
|
|
| 5 |
|
| 6 |
+
# Load a pre-trained model for text generation
|
| 7 |
+
@st.cache_resource
|
| 8 |
+
def load_model():
|
| 9 |
+
# Using a smaller model like Flan-T5 for demonstration purposes
|
| 10 |
+
generator = pipeline("text-generation", model="google/flan-t5-large")
|
| 11 |
+
return generator
|
| 12 |
|
| 13 |
# Function to create a Word document with the job description
|
| 14 |
def create_word_document(designation, job_description):
|
|
|
|
| 25 |
|
| 26 |
# Streamlit app layout
|
| 27 |
st.set_page_config(
|
| 28 |
+
page_title="Construction Job Description Generator",
|
| 29 |
page_icon="👷♂️",
|
| 30 |
layout="wide"
|
| 31 |
)
|
|
|
|
| 47 |
background-color: #ffffff;
|
| 48 |
border-radius: 5px;
|
| 49 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
.header {
|
| 51 |
font-size: 36px;
|
| 52 |
color: #333333;
|
|
|
|
| 62 |
""", unsafe_allow_html=True)
|
| 63 |
|
| 64 |
# Header
|
| 65 |
+
st.markdown('<div class="header">Construction Job Description Generator</div>', unsafe_allow_html=True)
|
| 66 |
+
|
| 67 |
+
# Load the pre-trained model
|
| 68 |
+
generator = load_model()
|
| 69 |
|
| 70 |
+
# Departments and Designations
|
| 71 |
+
departments = {
|
| 72 |
+
"Construction": ["Construction Manager", "Civil Engineer", "Project Manager", "Site Supervisor"],
|
| 73 |
+
"Engineering": ["Structural Engineer", "Electrical Engineer", "Mechanical Engineer"],
|
| 74 |
+
"Safety": ["Safety Officer", "Environmental Specialist"]
|
| 75 |
+
}
|
| 76 |
|
| 77 |
# Step 1: Select Department
|
| 78 |
st.markdown('<div class="subheader">Step 1: Select Department</div>', unsafe_allow_html=True)
|
| 79 |
+
department = st.selectbox("Select the department:", list(departments.keys()))
|
| 80 |
|
| 81 |
+
# Step 2: Select Designation
|
| 82 |
if department:
|
| 83 |
+
st.markdown('<div class="subheader">Step 2: Select Designation</div>', unsafe_allow_html=True)
|
| 84 |
+
designation = st.selectbox("Select the designation:", departments[department])
|
| 85 |
|
| 86 |
+
if designation:
|
| 87 |
+
# Generate a prompt for the model
|
| 88 |
+
prompt = f"Generate a detailed and professional job description for a {designation} in the {department} department."
|
| 89 |
+
|
| 90 |
+
# Generate job description using the pre-trained model
|
| 91 |
+
with st.spinner("Generating job description..."):
|
| 92 |
+
generated_text = generator(prompt, max_length=300, num_return_sequences=1)[0]['generated_text']
|
| 93 |
|
| 94 |
# Display job description
|
| 95 |
st.markdown('<div class="subheader">Generated Job Description</div>', unsafe_allow_html=True)
|
| 96 |
+
st.write(generated_text)
|
| 97 |
|
| 98 |
# Create Word document
|
| 99 |
+
doc_io = create_word_document(designation, generated_text)
|
| 100 |
|
| 101 |
# Download button for Word document
|
| 102 |
st.download_button(
|
| 103 |
label="Download Job Description as Word",
|
| 104 |
data=doc_io,
|
| 105 |
+
file_name=f"{designation.replace(' ', '_')}_job_description.docx",
|
| 106 |
mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
| 107 |
)
|
| 108 |
else:
|
| 109 |
+
st.warning("Please select a department and designation to generate the job description.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|