pratikshahp commited on
Commit
a796aa3
·
verified ·
1 Parent(s): fa756b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -34,7 +34,7 @@ def analyze_attrition_with_llm(df_dict, hr_query):
34
  employees_data = {row["Employee"].strip(): row["Sentiment"] for _, row in df.iterrows()}
35
 
36
  prompt = f"HR Query: {hr_query}\nEmployees Data: {json.dumps(employees_data, indent=2)}"
37
- response = client.chat.completions.create(
38
  model="gpt-4o-mini",
39
  messages=[{"role": "user", "content": prompt}],
40
  functions=[
@@ -54,6 +54,27 @@ def analyze_attrition_with_llm(df_dict, hr_query):
54
  ],
55
  function_call="auto"
56
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  print(response) # Debugging: Print response
58
 
59
  # Handle function call response properly
 
34
  employees_data = {row["Employee"].strip(): row["Sentiment"] for _, row in df.iterrows()}
35
 
36
  prompt = f"HR Query: {hr_query}\nEmployees Data: {json.dumps(employees_data, indent=2)}"
37
+ '''response = client.chat.completions.create(
38
  model="gpt-4o-mini",
39
  messages=[{"role": "user", "content": prompt}],
40
  functions=[
 
54
  ],
55
  function_call="auto"
56
  )
57
+ '''
58
+ response = client.chat.completions.create(
59
+ model="gpt-4o-mini",
60
+ messages=[{"role": "user", "content": prompt}],
61
+ functions=[
62
+ {
63
+ "name": "predict_attrition_risk",
64
+ "description": "Predicts attrition risk based on sentiment and provides explanation.",
65
+ "parameters": {
66
+ "type": "object",
67
+ "properties": {
68
+ "employee_name": {"type": "string", "description": "Employee's name"},
69
+ "sentiment": {"type": "string", "description": "Extracted sentiment"},
70
+ "explanation": {"type": "string", "description": "Brief explanation"}
71
+ },
72
+ "required": ["employee_name", "sentiment", "explanation"]
73
+ }
74
+ }
75
+ ],
76
+ function_call="auto"
77
+ )
78
  print(response) # Debugging: Print response
79
 
80
  # Handle function call response properly