Shageenderan Sapai commited on
Commit
06a04bf
·
1 Parent(s): f48f0e5

Aligned with staging

Browse files
Files changed (1) hide show
  1. app/user.py +35 -9
app/user.py CHANGED
@@ -107,8 +107,7 @@ class User:
107
  "day": 5,
108
  "coachingTheme": "FINAL_SUMMARY_STATE"
109
  }
110
- ]
111
- }
112
 
113
 
114
  self.growth_plan = CircularQueue(array=growth_plan['growthPlan'], user_id=self.user_id)
@@ -189,7 +188,7 @@ class User:
189
  def add_recent_wins(self, wins, context = None):
190
  prompt = f"""
191
  ## Role
192
- You are an expert in writing achievement message and progress notification. Your task is to use the user's achievement and context to formulate a short and creative achievement message/progress notification. The output must be a one sentence short message (less than 15 words) in this JSON output schema:
193
 
194
  ```json
195
  {{
@@ -206,7 +205,7 @@ class User:
206
  Output:
207
  ```
208
  {{
209
- achievement_message: You crushed it! Completing that 10k run is a huge milestone—way to go!
210
  }}
211
  ```
212
 
@@ -692,6 +691,8 @@ class User:
692
 
693
  8. You **MUST** call the process_reminder() function if the user wants to postpone their micro-action
694
 
 
 
695
  Today's Theme:
696
  {formatted_message}
697
  """
@@ -794,7 +795,7 @@ class User:
794
  logger.info(f"Summarizing zoom ai summary", extra={"user_id": self.user_id, "endpoint": "summarize_zoom"})
795
  # make an api call to gpt4o to summarize the zoom_ai_summary and produce a text with a focus on the most amount of user insight and info extracted
796
  system_prompt = f"""You are an expert at summarizing AI-generated Zoom transcripts concisely, focusing on extracting key user insights to enhance personalization in future interactions. Note that the zoom ai transcript may get the user's name wrong. Replace it with the actual user's name: {self.user_info}. Refer to the coach/guide as 'the Growth Guide'."""
797
- prompt = f"Please summarize the following AI-generated Zoom transcript **in one short paragraph only** !!, emphasizing the most significant user insights and information:\n\n{zoom_ai_summary}"
798
 
799
  response = self.client.chat.completions.create(
800
  model="gpt-4o",
@@ -802,10 +803,32 @@ class User:
802
  {"role": "system", "content": system_prompt},
803
  {"role": "user", "content": prompt}
804
  ],
805
- temperature=0.2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
806
  )
807
- logger.info(f"Summary: {response.choices[0].message.content}", extra={"user_id": self.user_id, "endpoint": "summarize_zoom"})
808
- return {'overview': response.choices[0].message.content}
 
 
809
 
810
  @catch_error
811
  def _update_user_data(self, data_type, text_input, extra_text=""):
@@ -996,12 +1019,15 @@ class User:
996
  if completed_micro_action:
997
  self.micro_actions[-1].status = "COMPLETE"
998
  self.micro_actions[-1].updated_at = pd.Timestamp.now(tz='UTC').strftime("%d-%m-%Y %a %H:%M:%S")
 
999
 
1000
  num_of_micro_actions_completed = sum(1 for item in self.micro_actions if item.status == 'COMPLETE')
1001
 
1002
  if (num_of_micro_actions_completed in (1,3,5)) or (num_of_micro_actions_completed % 10 == 0 and num_of_micro_actions_completed != 0):
1003
  self.add_life_score_point(variable = self.get_current_goal(full=True).area, points_added = 10, notes = f"Completing the {num_of_micro_actions_completed}-th micro-action")
1004
- self.add_recent_wins(wins = "You have completed a micro action!", context= self.micro_actions[-1]['content'])
 
 
1005
 
1006
  @catch_error
1007
  def trigger_deep_reflection_point(self, area_of_deep_reflection):
 
107
  "day": 5,
108
  "coachingTheme": "FINAL_SUMMARY_STATE"
109
  }
110
+ ]}
 
111
 
112
 
113
  self.growth_plan = CircularQueue(array=growth_plan['growthPlan'], user_id=self.user_id)
 
188
  def add_recent_wins(self, wins, context = None):
189
  prompt = f"""
190
  ## Role
191
+ You are an expert in writing achievement message and progress notification. Your task is to use the user's achievement and context to formulate a short achievement message/progress notification. The output must be a one sentence short message (less than 15 words) in this JSON output schema:
192
 
193
  ```json
194
  {{
 
205
  Output:
206
  ```
207
  {{
208
+ achievement_message: You have completed a 10k run!
209
  }}
210
  ```
211
 
 
691
 
692
  8. You **MUST** call the process_reminder() function if the user wants to postpone their micro-action
693
 
694
+ 9. When talking about Growth Guide, you must try to upsell the growth guide. Meaning that you are always encouraging the user to book a Growth Guide session and explain it benefits. Be like the Growth Guide's salesman!
695
+
696
  Today's Theme:
697
  {formatted_message}
698
  """
 
795
  logger.info(f"Summarizing zoom ai summary", extra={"user_id": self.user_id, "endpoint": "summarize_zoom"})
796
  # make an api call to gpt4o to summarize the zoom_ai_summary and produce a text with a focus on the most amount of user insight and info extracted
797
  system_prompt = f"""You are an expert at summarizing AI-generated Zoom transcripts concisely, focusing on extracting key user insights to enhance personalization in future interactions. Note that the zoom ai transcript may get the user's name wrong. Replace it with the actual user's name: {self.user_info}. Refer to the coach/guide as 'the Growth Guide'."""
798
+ prompt = f"Please summarize the following AI-generated Zoom transcript **in one short paragraph only, around 50 completion tokens maximum** !!, emphasizing the most significant user insights and information:\n\n{zoom_ai_summary}"
799
 
800
  response = self.client.chat.completions.create(
801
  model="gpt-4o",
 
803
  {"role": "system", "content": system_prompt},
804
  {"role": "user", "content": prompt}
805
  ],
806
+ response_format = {
807
+ "type": "json_schema",
808
+ "json_schema": {
809
+ "name": "summarized_overview",
810
+ "strict": True,
811
+ "schema": {
812
+ "type": "object",
813
+ "properties": {
814
+ "summary": {
815
+ "type": "string",
816
+ "description": "The summary of the zoom transcript"
817
+ }
818
+ },
819
+ "required": [
820
+ "achievement_message"
821
+ ],
822
+ "additionalProperties": False
823
+ }
824
+ }
825
+ },
826
+ temperature=0.5
827
  )
828
+
829
+ overview_summary = json.loads(response.choices[0].message.content)['summary']
830
+ logger.info(f"Summary: {overview_summary}", extra={"user_id": self.user_id, "endpoint": "summarize_zoom"})
831
+ return {'overview': overview_summary}
832
 
833
  @catch_error
834
  def _update_user_data(self, data_type, text_input, extra_text=""):
 
1019
  if completed_micro_action:
1020
  self.micro_actions[-1].status = "COMPLETE"
1021
  self.micro_actions[-1].updated_at = pd.Timestamp.now(tz='UTC').strftime("%d-%m-%Y %a %H:%M:%S")
1022
+ logger.info("Micro action status updated, checking number of actions completed...", extra={"user_id": self.user_id, "endpoint": "update_micro_action_status"})
1023
 
1024
  num_of_micro_actions_completed = sum(1 for item in self.micro_actions if item.status == 'COMPLETE')
1025
 
1026
  if (num_of_micro_actions_completed in (1,3,5)) or (num_of_micro_actions_completed % 10 == 0 and num_of_micro_actions_completed != 0):
1027
  self.add_life_score_point(variable = self.get_current_goal(full=True).area, points_added = 10, notes = f"Completing the {num_of_micro_actions_completed}-th micro-action")
1028
+ self.add_recent_wins(wins = "You have completed a micro action!", context= self.micro_actions[-1].content)
1029
+ logger.info("Added life score points based on number of actions completed.", extra={"user_id": self.user_id, "endpoint": "update_micro_action_status"})
1030
+ logger.info("Process done.", extra={"user_id": self.user_id, "endpoint": "update_micro_action_status"})
1031
 
1032
  @catch_error
1033
  def trigger_deep_reflection_point(self, area_of_deep_reflection):