contractor-management-chatbot / src /streamlit_app.py
002AnandPR's picture
Update src/streamlit_app.py
f4459a9 verified
Raw
History Blame Contribute Delete
2.42 kB
import streamlit as st
import pandas as pd
from transformers import pipeline
# Hugging Face model (stub for decision making)
decision_model = pipeline("text-classification", model="distilbert-base-uncased")
# Simulated SharePoint fetch (replace with API calls later)
def fetch_supplier_master():
return pd.read_excel("supplier_master.xlsx")
def fetch_contractor_master():
return pd.read_excel("contractor_master.xlsx")
def check_msa_validity(msa_df):
expired = msa_df[msa_df['EndDate'] < pd.Timestamp.today()]
return expired
def check_po_validity(po_df):
expired = po_df[po_df['EndDate'] < pd.Timestamp.today()]
return expired
def generate_performance_report(contractor_df):
top_performers = contractor_df[contractor_df['Performance'] == 'Top']
below_par = contractor_df[contractor_df['Performance'] == 'Below']
role_distribution = contractor_df.groupby('Role').size()
budget_utilization = contractor_df['Cost'].sum()
return top_performers, below_par, role_distribution, budget_utilization
def main():
st.title("Contractor Workflow AI Agent")
supplier_data = fetch_supplier_master()
contractor_data = fetch_contractor_master()
st.subheader("MSA & PO Validation")
expired_msa = check_msa_validity(supplier_data)
expired_po = check_po_validity(supplier_data)
if not expired_msa.empty:
st.warning("Expired MSAs found! Notify procurement team.")
st.write(expired_msa)
if not expired_po.empty:
st.warning("Expired POs found! Notify procurement team.")
st.write(expired_po)
st.subheader("Contractor Performance Report")
top, below, roles, budget = generate_performance_report(contractor_data)
st.write("βœ… Top Performers", top)
st.write("⚠️ Below Par Performers", below)
st.write("πŸ“Š Role Distribution", roles)
st.write(f"πŸ’° Overall Budget Utilization: {budget}")
st.subheader("Onboarding / Offboarding Actions")
for _, row in contractor_data.iterrows():
if row['EndDate'] < pd.Timestamp.today():
st.error(f"Contractor {row['Name']} expired. Offboard immediately.")
elif row.get('ExtendFlag', False):
st.info(f"Contractor {row['Name']} requires extension. Notify user.")
elif row.get('ManagerChanged', False):
st.info(f"Update hiring manager for {row['Name']}.")
if __name__ == "__main__":
main()