pratikshahp commited on
Commit
fb2bb9a
·
verified ·
1 Parent(s): 1897667

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -0
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from agent import Agent
3
+ from utils import extract_employee_data, get_survey_sentiment
4
+ from strategy import StrategyFactory
5
+
6
+ # Initialize Agent
7
+ agent = Agent("L&D Recommendation Agent")
8
+ agent.persona = "You are an AI-powered HR assistant specializing in learning and development recommendations."
9
+ agent.instruction = "Provide clear, actionable, and personalized learning recommendations within 70 words."
10
+
11
+ # Gradio Function
12
+ def recommend_learning(employee_name, strategy_name):
13
+ try:
14
+ agent.strategy = strategy_name
15
+
16
+ # Extract Employee Data
17
+ employee_data = extract_employee_data(employee_name)
18
+ if isinstance(employee_data, str):
19
+ return employee_data
20
+
21
+ # Get Survey Sentiment
22
+ sentiment = get_survey_sentiment(employee_name)
23
+ rating = employee_data.get('rating', 0)
24
+ experience = employee_data.get('experience', 0)
25
+ role = employee_data.get('role', "Unknown")
26
+
27
+ # Task for Recommendation
28
+ task = f"""
29
+ Employee {employee_name} ({role}, {experience} years).
30
+ Performance Rating: {rating}, Sentiment: {sentiment}.
31
+ Identify skill gaps and recommend personalized learning programs to enhance employee performance.
32
+ """
33
+
34
+ # Generate Recommendation
35
+ return agent.execute(task)
36
+
37
+ except Exception as e:
38
+ return str(e)
39
+
40
+ # Interface
41
+ iface = gr.Interface(
42
+ fn=recommend_learning,
43
+ inputs=[
44
+ gr.Textbox(label="Employee Name"),
45
+ gr.Dropdown(choices=StrategyFactory.available_strategies(), label="Select Strategy")
46
+ ],
47
+ outputs="text",
48
+ title="AI-Based Learning & Development Recommendation System",
49
+ description="Enter an employee's name and select a strategy to generate personalized learning recommendations."
50
+ )
51
+
52
+ if __name__ == "__main__":
53
+ iface.launch()