jjz5463 commited on
Commit
a1c328e
1 Parent(s): 15af633

prompt update

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. chatbot_simulator.py +13 -3
app.py CHANGED
@@ -67,7 +67,7 @@ def chat(user_input, history):
67
  valid_response = simulator_app.chat_interaction(user_input, history)
68
  return valid_response
69
  else:
70
- invalid_response = "Invalid input. Please use the format: '<Number>. <Description>: query'"
71
  return invalid_response
72
 
73
  css = """
 
67
  valid_response = simulator_app.chat_interaction(user_input, history)
68
  return valid_response
69
  else:
70
+ invalid_response = "Invalid input. Please use the format: <Number>. <Description>: query"
71
  return invalid_response
72
 
73
  css = """
chatbot_simulator.py CHANGED
@@ -10,7 +10,9 @@ class ChatbotSimulation:
10
  self.page_details = page_details
11
  self.user_state = user_state
12
  self.user_state['current_page'] = 'Home' # Initialize current page
 
13
  self.user_state['task_completed'] = 0
 
14
  self.task = task
15
  self.app_name = app_name
16
  self.log_location = log_location
@@ -37,11 +39,15 @@ class ChatbotSimulation:
37
  def _generate_system_prompt(self):
38
  """Create a dynamic system prompt based on the current state."""
39
  current_page = self.user_state['current_page']
 
40
  page_info = self._get_page_details(current_page)
41
 
42
  return f"""
43
- You are interacting with the {self.app_name} app. Your task is: {self.task}.
44
- You are currently on the {current_page} page. Current user state: {self.user_state}.
 
 
 
45
 
46
  Page Information:
47
  {page_info}
@@ -64,6 +70,7 @@ Please enter your choice as 'Number. Description'. If you have a query, enter as
64
  Rules:
65
  - Be sure to display all options that is available in features.
66
  - Be robotic and emotionless. Avoid offering any advice to the user.
 
67
  """
68
 
69
  def _get_openai_response(self, prompt):
@@ -89,12 +96,13 @@ Rules:
89
  def one_conversation_round(self, user_input):
90
  """Conduct one round of conversation between the user and the assistant."""
91
  # User provides input
 
92
  self.conversation.append({"role": "user", "content": user_input})
93
  self.actions.append(user_input)
94
 
95
  # Update user state using GPT's response
96
  update_prompt = f"""
97
- If user takes action '{user_input}' on {self.user_state['current_page']} page, which page will they move it?
98
  Recall user's task: {self.task}
99
  Update the user_state dictionary based on user's last action:
100
  Current user_state: {self.user_state}
@@ -112,6 +120,7 @@ Important:
112
  Example Output Format:
113
  {{
114
  'current_page': 'Home',
 
115
  'task_completed': 0,
116
  }}
117
  """
@@ -136,6 +145,7 @@ Example Output Format:
136
  # updated_state = json_repair.loads(reformat_state)
137
 
138
  try:
 
139
  if updated_state['task_completed']:
140
  return f"Task completed! You took {self.prompt_count} steps."
141
  except:
 
10
  self.page_details = page_details
11
  self.user_state = user_state
12
  self.user_state['current_page'] = 'Home' # Initialize current page
13
+ self.user_state['last_page'] = 'Home'
14
  self.user_state['task_completed'] = 0
15
+ self.user_last_action = ''
16
  self.task = task
17
  self.app_name = app_name
18
  self.log_location = log_location
 
39
  def _generate_system_prompt(self):
40
  """Create a dynamic system prompt based on the current state."""
41
  current_page = self.user_state['current_page']
42
+ last_page = self.user_state['last_page']
43
  page_info = self._get_page_details(current_page)
44
 
45
  return f"""
46
+ You are a text-based simulator of {self.app_name} app.
47
+ You are interacting with a user. User's task is: {self.task}.
48
+ User's last page was {last_page} and the user take action: {self.user_last_action}.
49
+ After action, user is currently on the {current_page} page.
50
+ Current user state: {self.user_state}.
51
 
52
  Page Information:
53
  {page_info}
 
70
  Rules:
71
  - Be sure to display all options that is available in features.
72
  - Be robotic and emotionless. Avoid offering any advice to the user.
73
+ - If user ask to access information that you do not possess. For example, list of restaurants, you can synthesize them.
74
  """
75
 
76
  def _get_openai_response(self, prompt):
 
96
  def one_conversation_round(self, user_input):
97
  """Conduct one round of conversation between the user and the assistant."""
98
  # User provides input
99
+ self.user_last_action = user_input
100
  self.conversation.append({"role": "user", "content": user_input})
101
  self.actions.append(user_input)
102
 
103
  # Update user state using GPT's response
104
  update_prompt = f"""
105
+ If user takes action '{user_input}' on {self.user_state['current_page']} page, which page will they move to?
106
  Recall user's task: {self.task}
107
  Update the user_state dictionary based on user's last action:
108
  Current user_state: {self.user_state}
 
120
  Example Output Format:
121
  {{
122
  'current_page': 'Home',
123
+ 'last_page': 'Home',
124
  'task_completed': 0,
125
  }}
126
  """
 
145
  # updated_state = json_repair.loads(reformat_state)
146
 
147
  try:
148
+ updated_state['task_completed'] = int(updated_state['task_completed'])
149
  if updated_state['task_completed']:
150
  return f"Task completed! You took {self.prompt_count} steps."
151
  except: