File size: 1,875 Bytes
fb2bb9a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import gradio as gr
from agent import Agent
from utils import extract_employee_data, get_survey_sentiment
from strategy import StrategyFactory

# Initialize Agent
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."

# Gradio Function
def recommend_learning(employee_name, strategy_name):
    try:
        agent.strategy = strategy_name

        # Extract Employee Data
        employee_data = extract_employee_data(employee_name)
        if isinstance(employee_data, str):
            return employee_data
        
        # Get Survey Sentiment
        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 for Recommendation
        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.
        """
        
        # Generate Recommendation
        return agent.execute(task)
    
    except Exception as e:
        return str(e)

# Interface
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()