matthew.farant commited on
Commit
67bd08c
·
1 Parent(s): 636011f

change response format for _update_goal to json schema

Browse files
Files changed (1) hide show
  1. app/user.py +37 -6
app/user.py CHANGED
@@ -25,11 +25,6 @@ class UserDataItem(BaseModel):
25
  class UserDataResponse(BaseModel):
26
  data: list[UserDataItem]
27
 
28
- class GoalItem(BaseModel):
29
- same_or_not: bool
30
- goal: str
31
- area: str
32
-
33
  logger = logging.getLogger(__name__)
34
 
35
  def get_current_datetime():
@@ -708,7 +703,43 @@ class User:
708
  response = self.client.chat.completions.create(
709
  model="gpt-4o",
710
  messages=[{"role": "user", "content": prompt}],
711
- response_format = GoalItem,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
712
  temperature=0.2
713
  )
714
 
 
25
  class UserDataResponse(BaseModel):
26
  data: list[UserDataItem]
27
 
 
 
 
 
 
28
  logger = logging.getLogger(__name__)
29
 
30
  def get_current_datetime():
 
703
  response = self.client.chat.completions.create(
704
  model="gpt-4o",
705
  messages=[{"role": "user", "content": prompt}],
706
+ response_format = {
707
+ "type": "json_schema",
708
+ "json_schema": {
709
+ "name": "goal_determination",
710
+ "strict": True,
711
+ "schema": {
712
+ "type": "object",
713
+ "properties": {
714
+ "same_or_not": {
715
+ "type": "boolean",
716
+ "description": "Indicates whether the new goal is the same as the current goal."
717
+ },
718
+ "goal": {
719
+ "type": "string",
720
+ "description": "The final goal determined based on input."
721
+ },
722
+ "area": {
723
+ "type": "string",
724
+ "description": "The area of the goal.",
725
+ "enum": [
726
+ "Personal Growth",
727
+ "Career Growth",
728
+ "Relationship",
729
+ "Mental Well-Being",
730
+ "Health and Wellness"
731
+ ]
732
+ }
733
+ },
734
+ "required": [
735
+ "same_or_not",
736
+ "goal",
737
+ "area"
738
+ ],
739
+ "additionalProperties": False
740
+ }
741
+ }
742
+ },
743
  temperature=0.2
744
  )
745