YoniFriedman commited on
Commit
52b83a1
·
verified ·
1 Parent(s): 5040561

updating user param parsing

Browse files
Files changed (1) hide show
  1. app.py +25 -1
app.py CHANGED
@@ -66,7 +66,8 @@ def contains_follow_up(question):
66
  return contains_exact_word_or_phrase(question, follow_up_keywords)
67
 
68
  def convert_to_date(date_str):
69
- return datetime.strptime(date_str, "%Y%m%d")
 
70
 
71
  def detect_language(question):
72
  # Check if the text has less than 5 words
@@ -105,6 +106,29 @@ def nishauri(user_params: str, conversation_history: list[str]):
105
  next_appt_date = convert_to_date(person_info.get("APPOINTMENT_DATETIME", ""))
106
  regimen = person_info.get("REGIMEN", "")
107
  question = user_params.get("QUESTION")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
  ## Process greeting
110
  # greet_response = process_greeting_response(question)
 
66
  return contains_exact_word_or_phrase(question, follow_up_keywords)
67
 
68
  def convert_to_date(date_str):
69
+ date_obj = datetime.strptime(date_str, "%Y%m%d")
70
+ return date_obj.strftime("%Y-%m-%d")
71
 
72
  def detect_language(question):
73
  # Check if the text has less than 5 words
 
106
  next_appt_date = convert_to_date(person_info.get("APPOINTMENT_DATETIME", ""))
107
  regimen = person_info.get("REGIMEN", "")
108
  question = user_params.get("QUESTION")
109
+
110
+ # Keep those user params that are present
111
+ info_pieces = []
112
+
113
+ if gender:
114
+ info_pieces.append(f"The person is {gender}.")
115
+
116
+ if age:
117
+ info_pieces.append(f"The person is age {age}.")
118
+
119
+ if next_appt_date:
120
+ info_pieces.append(f"The person's next clinical check-in is scheduled for {next_appt_date}.")
121
+
122
+ if regimen:
123
+ info_pieces.append(f"The person is on the following regimen for HIV: {regimen}.")
124
+
125
+ if vl_result:
126
+ info_pieces.append(f"The person's most recent viral load result was {vl_result}.")
127
+
128
+ if vl_date:
129
+ info_pieces.append(f"The person's most recent viral load was taken on {vl_date}.")
130
+
131
+ full_text = " ".join(info_pieces)
132
 
133
  ## Process greeting
134
  # greet_response = process_greeting_response(question)