jjz5463 commited on
Commit
ecf6658
·
1 Parent(s): dbdae97

fix the issue task completed will not shown in chat history

Browse files
Files changed (1) hide show
  1. chatbot_simulator.py +1 -27
chatbot_simulator.py CHANGED
@@ -170,7 +170,7 @@ Example Output Format:
170
 
171
  try:
172
  if updated_state['task_completed'].lower() == 'true':
173
- print(f"Task completed! You took {self.prompt_count} steps.")
174
  except:
175
  updated_state['task_completed'] = 'False'
176
 
@@ -185,32 +185,6 @@ Example Output Format:
185
  self.conversation.append({"role": "assistant", "content": gpt_instruction})
186
  return gpt_instruction
187
 
188
- def _generate_agent_input(self):
189
- """
190
- Simulate the agent generating input based on the conversation state.
191
- """
192
- agent_prompt = f"""
193
- Imagine you are an agent navigate through the Uber environment.
194
- Your overarching task is: {self.task}. You may have done some part of the task, or none at all.
195
- You will have access to all of your previous actions in the environment, as well as the last message from the assistant giving the current state of the environment.
196
- The last message from the assistant was: {self.conversation[-1]['content']}
197
- Respond first with a brief "Plan" which suggests what steps you are going to take to accomplish the task, and what your immediate.
198
- Then generate an "Action" which is the immediate next step you can take.
199
- """
200
-
201
- messages = [{"role": "system", "content": agent_prompt}]
202
- for action in self.actions:
203
- messages.append({"role": "user", "content": action})
204
- messages.append({"role": "assistant", "content": self.conversation[-1]['content']})
205
-
206
- agent_response = self.client.chat.completions.create(
207
- model="gpt-4",
208
- messages=messages,
209
- temperature=0.7,
210
- )
211
- print(f"LLM-Agent: {agent_response.choices[0].message.content}")
212
- return agent_response.choices[0].message.content
213
-
214
  def start_conversation(self):
215
  greeting = f'\n Welcome to {self.app_name} simulator! Your task is: {self.task}. \n'
216
  system_prompt = self._generate_system_prompt()
 
170
 
171
  try:
172
  if updated_state['task_completed'].lower() == 'true':
173
+ return f"Task completed! You took {self.prompt_count} steps."
174
  except:
175
  updated_state['task_completed'] = 'False'
176
 
 
185
  self.conversation.append({"role": "assistant", "content": gpt_instruction})
186
  return gpt_instruction
187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  def start_conversation(self):
189
  greeting = f'\n Welcome to {self.app_name} simulator! Your task is: {self.task}. \n'
190
  system_prompt = self._generate_system_prompt()