|
|
import gradio as gr |
|
|
from agent import Agent |
|
|
from utils import extract_employee_data, get_survey_sentiment |
|
|
from strategy import StrategyFactory |
|
|
|
|
|
|
|
|
agent = Agent("L&D Recommendation Agent") |
|
|
agent.persona = "You are an AI-powered HR assistant specializing in learning and development recommendations." |
|
|
agent.instruction = "Provide clear, actionable, and personalized learning recommendations within 70 words." |
|
|
|
|
|
|
|
|
def recommend_learning(employee_name, strategy_name): |
|
|
try: |
|
|
agent.strategy = strategy_name |
|
|
|
|
|
|
|
|
employee_data = extract_employee_data(employee_name) |
|
|
if isinstance(employee_data, str): |
|
|
return employee_data |
|
|
|
|
|
|
|
|
sentiment = get_survey_sentiment(employee_name) |
|
|
rating = employee_data.get('rating', 0) |
|
|
experience = employee_data.get('experience', 0) |
|
|
role = employee_data.get('role', "Unknown") |
|
|
|
|
|
|
|
|
task = f""" |
|
|
Employee {employee_name} ({role}, {experience} years). |
|
|
Performance Rating: {rating}, Sentiment: {sentiment}. |
|
|
Identify skill gaps and recommend personalized learning programs to enhance employee performance. |
|
|
""" |
|
|
|
|
|
|
|
|
return agent.execute(task) |
|
|
|
|
|
except Exception as e: |
|
|
return str(e) |
|
|
|
|
|
|
|
|
iface = gr.Interface( |
|
|
fn=recommend_learning, |
|
|
inputs=[ |
|
|
gr.Textbox(label="Employee Name"), |
|
|
gr.Dropdown(choices=StrategyFactory.available_strategies(), label="Select Strategy") |
|
|
], |
|
|
outputs="text", |
|
|
title="AI-Based Learning & Development Recommendation System", |
|
|
description="Enter an employee's name and select a strategy to generate personalized learning recommendations." |
|
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
iface.launch() |
|
|
|