jjz5463 commited on
Commit
3f815a2
·
1 Parent(s): 3e24e07

task completed failed update

Browse files
Files changed (1) hide show
  1. chatbot_simulator.py +6 -7
chatbot_simulator.py CHANGED
@@ -12,7 +12,7 @@ class ChatbotSimulation:
12
  self.user_state = user_state
13
  self.user_state['current_page'] = 'Home' # Initialize current page
14
  self.user_state['last_page'] = 'Home'
15
- self.user_state['task_completed'] = 0
16
  self.task = task
17
  self.app_name = app_name
18
  self.log_location = log_location
@@ -115,7 +115,7 @@ Sitemap: {self.sitemap}
115
 
116
  Instructions:
117
  1. If the 'current_page' has changed, update it to a page from the sitemap.
118
- 2. If the task is finished, update 'task_completed' to 1. Otherwise, leave it as 0.
119
  3. If no updates are needed, return the user state exactly as provided, without modification.
120
 
121
  Important:
@@ -126,9 +126,9 @@ Example Output Format:
126
  {{
127
  'current_page': 'Home',
128
  'last_page': 'Home',
129
- 'task_completed': 0,
130
  }}
131
- """
132
 
133
  self.conversation.append({"role": "assistant", "content": update_prompt})
134
  updated_state = self._get_openai_response(self.conversation)
@@ -137,11 +137,10 @@ Example Output Format:
137
  updated_state = json_repair.loads(updated_state)
138
 
139
  try:
140
- updated_state['task_completed'] = int(updated_state['task_completed'])
141
- if updated_state['task_completed']:
142
  return f"Task completed! You took {self.prompt_count} steps."
143
  except:
144
- updated_state['task_completed'] = 0
145
 
146
  self.user_state = updated_state
147
 
 
12
  self.user_state = user_state
13
  self.user_state['current_page'] = 'Home' # Initialize current page
14
  self.user_state['last_page'] = 'Home'
15
+ self.user_state['task_completed'] = 'False'
16
  self.task = task
17
  self.app_name = app_name
18
  self.log_location = log_location
 
115
 
116
  Instructions:
117
  1. If the 'current_page' has changed, update it to a page from the sitemap.
118
+ 2. If the task is finished, update 'task_completed' to True. Otherwise, leave it as False.
119
  3. If no updates are needed, return the user state exactly as provided, without modification.
120
 
121
  Important:
 
126
  {{
127
  'current_page': 'Home',
128
  'last_page': 'Home',
129
+ 'task_completed': 'False',
130
  }}
131
+ """
132
 
133
  self.conversation.append({"role": "assistant", "content": update_prompt})
134
  updated_state = self._get_openai_response(self.conversation)
 
137
  updated_state = json_repair.loads(updated_state)
138
 
139
  try:
140
+ if updated_state['task_completed'].lower() == 'true':
 
141
  return f"Task completed! You took {self.prompt_count} steps."
142
  except:
143
+ updated_state['task_completed'] = 'False'
144
 
145
  self.user_state = updated_state
146