Downloads · 30 days
0
vaguilar0124/HR.Agent.for.Prof
HR.Agent.for.Prof is a machine learning model from vaguilar0124. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
import gradio as gr import textwrap from datetime import datetime
Downloads · 30 days
0
Access
Public
Updated Aug 26, 2025
Repo size
—
Likes
0
Public
Click a slice to open those files.
.md3.5 KB · 69%
From the Hugging Face model README
import gradio as gr import textwrap from datetime import datetime
SCENARIO = ( "A manager's highest-performing employee is discovered to have a history of workplace misconduct at their " "previous job, a history that was not disclosed during the interview process. The employee is critical to a " "major, ongoing project. Should HR ignore the misconduct to protect the company's immediate project goals and " "reward employee loyalty, or terminate the employee to uphold the company's ethical standards and ensure a fair, " "transparent workplace?" )
DISCLAIMER = ( "⚠️ Disclaimer: This agent provides general HR guidance for educational purposes only and is not legal advice. " "For real decisions, consult your organization's counsel and follow applicable laws and company policy." )
def guidance_high_level():
return textwrap.dedent("""
High-level guidance:
• Do not ignore the information — that undermines standards and creates risk.
• Do not rush to terminate solely based on past allegations. Verify facts.
• Run a fair, documented review aligned with policy and law.
• Manage project continuity in parallel to reduce disruption.
""")
def guidance_answers(): return { "ignore": "❌ Ignoring credible misconduct is not recommended. It signals favoritism and risk.", "terminate": "⚖️ Do not auto-terminate. Verify facts, check policy, and apply standards consistently.", "investigate": "🔍 Yes, conduct a fair and timely investigation, with employee input.", "project": "📂 Protect the project: implement knowledge transfer, backups, and coverage plans.", "ethics": "🌐 Ethics vs results: uphold standards while balancing project continuity. Never sacrifice fairness." }
KEYWORDS = { "ignore": ["ignore", "look the other way"], "terminate": ["terminate", "fire", "dismiss"], "investigate": ["investigate", "review", "verify"], "project": ["project", "deadline", "handoff", "transition"], "ethics": ["ethics", "standards", "fair", "transparent"] }
def route_intent(user_text: str): t = user_text.lower() for intent, keys in KEYWORDS.items(): if any(k in t for k in keys): return intent return "general"
def generate_response(message, history): intent = route_intent(message) answers = guidance_answers()
if message.strip().lower() in ("scenario",):
return SCENARIO
if message.strip().lower() in ("policy", "overview"):
return guidance_high_level()
if intent in answers:
return answers[intent] + "\n\n" + DISCLAIMER
else:
return f"{DISCLAIMER}\n\nRecommended next step: Begin a fair, fact-based review. Use 'policy' for high-level guidance."
with gr.Blocks() as demo: gr.Markdown("## 🤖 HR Ethics AI Agent") gr.Markdown("Ask me questions about the HR scenario below.\n\n" + SCENARIO)
chatbot = gr.Chatbot()
msg = gr.Textbox(placeholder="Ask HR Agent a question...")
clear = gr.Button("Clear")
def respond(message, chat_history):
bot_message = generate_response(message, chat_history)
chat_history.append((message, bot_message))
return "", chat_history
msg.submit(respond, [msg, chatbot], [msg, chatbot])
clear.click(lambda: None, None, chatbot, queue=False)
demo.launch()