GuglielmoTor commited on
Commit
9a47b29
·
verified ·
1 Parent(s): 5eef7c3

Update features/insight_and_tasks/agents/task_extraction_model.py

Browse files
features/insight_and_tasks/agents/task_extraction_model.py CHANGED
@@ -25,44 +25,69 @@ from features.insight_and_tasks.data_models.tasks import (
25
  )
26
 
27
  def create_example_structure():
28
- """Creates an example structure to show the AI what the output should look like."""
 
 
 
29
  return {
30
  "current_quarter_info": "Q2 2025, 24 days remaining",
31
  "okrs": [
32
  {
33
- "objective_description": "Improve LinkedIn employer branding performance",
34
- "objective_timeline": "short",
35
- "objective_owner": "marketing",
 
36
  "key_results": [
37
  {
38
- "key_result_description": "Increase monthly follower growth by 50%",
39
- "target_metric": "+50 followers",
 
40
  "target_value": "50% increase",
41
- "current_value": "22 followers/month",
42
- "key_result_type": "performance",
43
- "data_subject": "posts",
 
 
 
 
 
44
  "tasks": [
45
  {
46
- "task_description": "Increase posting frequency",
47
- "objective_deliverable": "Post 2-3 times per week consistently",
48
- "task_category": "content_creation",
49
- "priority": "high",
50
- "effort": "medium",
51
- "timeline": "this_quarter",
52
- "data_subject": "linkedin_performance",
53
- "responsible_party": "marketing",
54
- "success_criteria_metrics": "post 3 times",
55
- "dependencies_prerequisites": "a linkedin account",
56
- "why_proposed": "because previous data show low post frequency and low follwoer gains"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
58
  ]
59
  }
60
  ]
61
  }
62
  ],
63
- "overall_strategic_focus": "increase followers"
64
  }
65
 
 
66
  # --- Helper Function for Date Calculations ---
67
  def get_quarter_info():
68
  """Calculates current quarter, year, and days remaining in the quarter."""
@@ -149,7 +174,9 @@ GENERATION RULES:
149
  2. For each OKR, create 1-3 KeyResult objects (MANDATORY - cannot be empty)
150
  3. For each KeyResult, create 1-3 Task objects (MANDATORY - cannot be empty)
151
  4. Make tasks specific, actionable, and directly related to the insights in the input text
152
- 5. Ensure all required fields are populated with valid enum values
 
 
153
 
154
  Now, analyze the following text and generate the structured output:
155
  ---
@@ -166,6 +193,7 @@ TEXT TO ANALYZE:
166
  'response_mime_type': 'application/json',
167
  'response_schema': TaskExtractionOutput, # Pass the Pydantic model class
168
  'temperature': 0.1,
 
169
  },
170
  )
171
  except Exception as e:
 
25
  )
26
 
27
  def create_example_structure():
28
+ """
29
+ Creates a valid example structure that conforms to the Pydantic models
30
+ to show the AI what the output should look like.
31
+ """
32
  return {
33
  "current_quarter_info": "Q2 2025, 24 days remaining",
34
  "okrs": [
35
  {
36
+ "objective_description": "Significantly improve our LinkedIn employer branding performance to attract top-tier talent and establish our company as a thought leader in the tech industry.",
37
+
38
+ "objective_timeline": "Short-term",
39
+ "objective_owner": "Marketing Department",
40
  "key_results": [
41
  {
42
+ # CORRECTION: Description expanded to satisfy the 'min_length=100' validation rule.
43
+ "key_result_description": "Achieve a sustained 50% increase in the rate of monthly follower growth on our company LinkedIn page, demonstrating enhanced audience engagement and brand reach.",
44
+ "target_metric": "Monthly Follower Growth Rate",
45
  "target_value": "50% increase",
46
+
47
+ # CORRECTION: Extra 'current_value' field removed as it's not in the Pydantic model.
48
+
49
+ # CORRECTION: Value changed from "performance" to "PERFORMANCE" to match 'KeyResultType' enum.
50
+ "key_result_type": "PERFORMANCE",
51
+
52
+ # CORRECTION: Value changed from "posts" to "FOLLOWER_STATS" to match 'DataSubject' enum and better reflect the key result.
53
+ "data_subject": "FOLLOWER_STATS",
54
  "tasks": [
55
  {
56
+ "task_description": "Increase posting frequency to a consistent, high-quality schedule.",
57
+ "objective_deliverable": "Post a minimum of 3 high-quality, relevant articles or updates per week.",
58
+ "task_category": "Content Creation",
59
+
60
+ # CORRECTION: Added the missing required field 'task_type' with a valid 'TaskType' enum value.
61
+ "task_type": "INITIATIVE",
62
+
63
+ # CORRECTION: Value changed from "high" to "High" to match the 'PriorityLevel' enum.
64
+ "priority": "High",
65
+
66
+ # CORRECTION: Added the missing required field 'priority_justification'.
67
+ "priority_justification": "Increasing post frequency is a primary driver for engagement and follower growth, directly impacting the key result.",
68
+
69
+ # CORRECTION: Value changed from "medium" to "Medium" to match the 'EffortLevel' enum.
70
+ "effort": "Medium",
71
+
72
+ # CORRECTION: Value changed from "this_quarter" to "Short-term" to match the 'TimelineCategory' enum.
73
+ "timeline": "Short-term",
74
+
75
+ # CORRECTION: Value changed from "linkedin_performance" to "POSTS" to match the 'DataSubject' enum.
76
+ "data_subject": "POSTS",
77
+ "responsible_party": "Social Media Manager",
78
+ "success_criteria_metrics": "A weekly average of 3 or more posts is maintained over the quarter.",
79
+ "dependencies_prerequisites": "A finalized content calendar for the quarter.",
80
+ "why_proposed": "Historical data analysis shows a direct correlation between low posting frequency and stagnant follower gains. This task addresses the root cause."
81
  }
82
  ]
83
  }
84
  ]
85
  }
86
  ],
87
+ "overall_strategic_focus": "Accelerate follower growth and enhance brand authority on LinkedIn."
88
  }
89
 
90
+
91
  # --- Helper Function for Date Calculations ---
92
  def get_quarter_info():
93
  """Calculates current quarter, year, and days remaining in the quarter."""
 
174
  2. For each OKR, create 1-3 KeyResult objects (MANDATORY - cannot be empty)
175
  3. For each KeyResult, create 1-3 Task objects (MANDATORY - cannot be empty)
176
  4. Make tasks specific, actionable, and directly related to the insights in the input text
177
+ 5. No repetitive text allowed
178
+ 6. Complete JSON object with proper closing braces
179
+ 7. Maximum response length: 5000 characters
180
 
181
  Now, analyze the following text and generate the structured output:
182
  ---
 
193
  'response_mime_type': 'application/json',
194
  'response_schema': TaskExtractionOutput, # Pass the Pydantic model class
195
  'temperature': 0.1,
196
+ 'top_p': 0.8,
197
  },
198
  )
199
  except Exception as e: