jjz5463 commited on
Commit
e3ac915
1 Parent(s): 29ff717

force json format in updated user state

Browse files
Files changed (1) hide show
  1. chatbot_simulator.py +12 -5
chatbot_simulator.py CHANGED
@@ -136,11 +136,18 @@ Example Output Format:
136
  # Parse and update the user state
137
  updated_state = json_repair.loads(updated_state)
138
 
139
- if isinstance(updated_state, dict):
140
- pass
141
- else:
142
- print(updated_state)
143
- print(type(updated_state))
 
 
 
 
 
 
 
144
 
145
  try:
146
  if updated_state['task_completed'].lower() == 'true':
 
136
  # Parse and update the user state
137
  updated_state = json_repair.loads(updated_state)
138
 
139
+ while not isinstance(updated_state, dict):
140
+ transform_prompt = f""""
141
+ Transform {updated_state} to a properly formate JSON file.
142
+ Example Output Format:
143
+ {{
144
+ 'current_page': 'Home',
145
+ 'last_page': 'Home',
146
+ 'task_completed': 'False',
147
+ }}
148
+ """
149
+ updated_state = self._get_openai_response({'role': 'system', 'content': transform_prompt})
150
+ updated_state = json_repair.loads(updated_state)
151
 
152
  try:
153
  if updated_state['task_completed'].lower() == 'true':