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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import plotly.express as px
|
| 4 |
+
from io import StringIO
|
| 5 |
+
from huggingface_hub import InferenceClient
|
| 6 |
+
|
| 7 |
+
# --------------------------
|
| 8 |
+
# Streamlit Setup
|
| 9 |
+
# --------------------------
|
| 10 |
+
st.set_page_config(
|
| 11 |
+
page_title="Team Career Progression Assistant",
|
| 12 |
+
layout="wide"
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
st.title("π§ Team Career Progression Assistant")
|
| 16 |
+
st.caption("Program Managers β’ Scrum Masters β’ People Leads")
|
| 17 |
+
|
| 18 |
+
# --------------------------
|
| 19 |
+
# Load LLM client (optional)
|
| 20 |
+
# --------------------------
|
| 21 |
+
@st.cache_resource
|
| 22 |
+
def load_llm():
|
| 23 |
+
return InferenceClient("google/flan-t5-small")
|
| 24 |
+
|
| 25 |
+
def generate_llm_plan(row):
|
| 26 |
+
client = load_llm()
|
| 27 |
+
|
| 28 |
+
prompt = f"""
|
| 29 |
+
You are an expert career coach. Summarize strengths and gaps.
|
| 30 |
+
Then give a 30-60-90 day plan.
|
| 31 |
+
|
| 32 |
+
Profile:
|
| 33 |
+
Name: {row['Name']}
|
| 34 |
+
Current Role: {row['CurrentRole']}
|
| 35 |
+
Years Exp: {row['YearsExperience']}
|
| 36 |
+
Tech Skills: {row['TechSkillRating']}
|
| 37 |
+
Soft Skills: {row['SoftSkillRating']}
|
| 38 |
+
Performance: {row['PerformanceRating']}
|
| 39 |
+
Leadership: {row['LeadershipInterest']}
|
| 40 |
+
Domain: {row['DomainInterest']}
|
| 41 |
+
Career Goal: {row['CareerGoal']}
|
| 42 |
+
"""
|
| 43 |
+
|
| 44 |
+
try:
|
| 45 |
+
response = client.text_generation(prompt, max_new_tokens=200)
|
| 46 |
+
return response.strip()
|
| 47 |
+
except Exception as e:
|
| 48 |
+
return f"LLM Error: {e}"
|
| 49 |
+
|
| 50 |
+
# --------------------------
|
| 51 |
+
# Compute readiness score
|
| 52 |
+
# --------------------------
|
| 53 |
+
def score(row):
|
| 54 |
+
years = min(row["YearsExperience"], 10) / 10 * 5
|
| 55 |
+
tech = row["TechSkillRating"]
|
| 56 |
+
soft = row["SoftSkillRating"]
|
| 57 |
+
perf = row["PerformanceRating"]
|
| 58 |
+
leadership = 5 if str(row["LeadershipInterest"]).lower() == "yes" else 2
|
| 59 |
+
|
| 60 |
+
score_5 = (0.3 * years + 0.2 * tech + 0.2 * soft +
|
| 61 |
+
0.2 * perf + 0.1 * leadership)
|
| 62 |
+
return round(score_5 / 5 * 100, 1)
|
| 63 |
+
|
| 64 |
+
# --------------------------
|
| 65 |
+
# Next role + actions
|
| 66 |
+
# --------------------------
|
| 67 |
+
def suggest_next_role(row):
|
| 68 |
+
s = row["ReadinessScore"]
|
| 69 |
+
|
| 70 |
+
if s >= 80:
|
| 71 |
+
return "Team Lead / Scrum Master"
|
| 72 |
+
elif s >= 60:
|
| 73 |
+
return f"Mid-level {row['CurrentRole']}"
|
| 74 |
+
else:
|
| 75 |
+
return "Upskill Current Role"
|
| 76 |
+
|
| 77 |
+
def suggest_actions(row):
|
| 78 |
+
actions = []
|
| 79 |
+
|
| 80 |
+
if row["ReadinessScore"] >= 80:
|
| 81 |
+
actions = [
|
| 82 |
+
"Lead small initiatives",
|
| 83 |
+
"Mentor junior teammates",
|
| 84 |
+
"Improve decision-making"
|
| 85 |
+
]
|
| 86 |
+
elif row["ReadinessScore"] >= 60:
|
| 87 |
+
actions = [
|
| 88 |
+
"Improve core technical skills",
|
| 89 |
+
"Own a module or feature",
|
| 90 |
+
"Drive small improvements"
|
| 91 |
+
]
|
| 92 |
+
else:
|
| 93 |
+
actions = [
|
| 94 |
+
"Focus on consistency",
|
| 95 |
+
"Work with mentor weekly",
|
| 96 |
+
"Upskill using certifications"
|
| 97 |
+
]
|
| 98 |
+
|
| 99 |
+
return "β’ " + "\nβ’ ".join(actions)
|
| 100 |
+
|
| 101 |
+
# --------------------------
|
| 102 |
+
# Sidebar Inputs
|
| 103 |
+
# --------------------------
|
| 104 |
+
with st.sidebar:
|
| 105 |
+
st.header("π Upload CSV or Use Sample")
|
| 106 |
+
file = st.file_uploader("Upload CSV", type=["csv"])
|
| 107 |
+
use_sample = st.checkbox("Use sample data", value=True)
|
| 108 |
+
|
| 109 |
+
st.header("π€ LLM Options")
|
| 110 |
+
use_llm = st.checkbox("Enable AI-generated 30-60-90 plans", value=False)
|
| 111 |
+
|
| 112 |
+
# --------------------------
|
| 113 |
+
# Load data
|
| 114 |
+
# --------------------------
|
| 115 |
+
if file:
|
| 116 |
+
df_raw = pd.read_csv(file)
|
| 117 |
+
elif use_sample:
|
| 118 |
+
df_raw = pd.read_csv("sample_data/team_members_sample.csv")
|
| 119 |
+
else:
|
| 120 |
+
st.stop()
|
| 121 |
+
|
| 122 |
+
st.subheader("π₯ Input Data")
|
| 123 |
+
st.dataframe(df_raw, use_container_width=True)
|
| 124 |
+
|
| 125 |
+
# --------------------------
|
| 126 |
+
# Calculate Results
|
| 127 |
+
# --------------------------
|
| 128 |
+
df = df_raw.copy()
|
| 129 |
+
df["ReadinessScore"] = df.apply(score, axis=1)
|
| 130 |
+
df["SuggestedNextRole"] = df.apply(suggest_next_role, axis=1)
|
| 131 |
+
df["RecommendedActions"] = df.apply(suggest_actions, axis=1)
|
| 132 |
+
|
| 133 |
+
if use_llm:
|
| 134 |
+
df["LLMPlan"] = df.apply(generate_llm_plan, axis=1)
|
| 135 |
+
else:
|
| 136 |
+
df["LLMPlan"] = "LLM disabled"
|
| 137 |
+
|
| 138 |
+
# --------------------------
|
| 139 |
+
# Summary Output
|
| 140 |
+
# --------------------------
|
| 141 |
+
st.subheader("π Team Summary")
|
| 142 |
+
st.dataframe(
|
| 143 |
+
df[["Name", "CurrentRole", "YearsExperience", "ReadinessScore",
|
| 144 |
+
"SuggestedNextRole"]],
|
| 145 |
+
use_container_width=True
|
| 146 |
+
)
|
| 147 |
+
|
| 148 |
+
# --------------------------
|
| 149 |
+
# Detailed Cards
|
| 150 |
+
# --------------------------
|
| 151 |
+
st.subheader("π§ Detailed Recommendations")
|
| 152 |
+
|
| 153 |
+
for _, row in df.iterrows():
|
| 154 |
+
with st.expander(f"{row['Name']} β {row['SuggestedNextRole']}"):
|
| 155 |
+
col1, col2 = st.columns(2)
|
| 156 |
+
|
| 157 |
+
with col1:
|
| 158 |
+
st.markdown("### Recommended Actions")
|
| 159 |
+
st.write(row["RecommendedActions"])
|
| 160 |
+
|
| 161 |
+
with col2:
|
| 162 |
+
st.markdown("### 30-60-90 AI Plan")
|
| 163 |
+
st.write(row["LLMPlan"])
|
| 164 |
+
|
| 165 |
+
# --------------------------
|
| 166 |
+
# Dashboard
|
| 167 |
+
# --------------------------
|
| 168 |
+
st.markdown("---")
|
| 169 |
+
st.header("π Team Dashboard")
|
| 170 |
+
|
| 171 |
+
col1, col2 = st.columns(2)
|
| 172 |
+
|
| 173 |
+
with col1:
|
| 174 |
+
fig = px.bar(df, x="Name", y="ReadinessScore", text="ReadinessScore")
|
| 175 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 176 |
+
|
| 177 |
+
with col2:
|
| 178 |
+
count = df["SuggestedNextRole"].value_counts().reset_index()
|
| 179 |
+
count.columns = ["Role", "Count"]
|
| 180 |
+
fig2 = px.pie(count, names="Role", values="Count")
|
| 181 |
+
st.plotly_chart(fig2, use_container_width=True)
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
# --------------------------
|
| 185 |
+
# Download results
|
| 186 |
+
# --------------------------
|
| 187 |
+
buffer = StringIO()
|
| 188 |
+
df.to_csv(buffer, index=False)
|
| 189 |
+
|
| 190 |
+
st.download_button(
|
| 191 |
+
"π₯ Download Full Results CSV",
|
| 192 |
+
buffer.getvalue(),
|
| 193 |
+
"career_progression_results.csv",
|
| 194 |
+
"text/csv"
|
| 195 |
+
)
|