elaineaishophouse commited on
Commit
9a91e2b
·
verified ·
1 Parent(s): b6c2a7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -10
app.py CHANGED
@@ -121,7 +121,8 @@ def ask_interview_question(respondent_agents_dict, question, processor_llm):
121
  respondent_agent = respondent_agents_dict[agent_name].get_agent()
122
  user_profile = respondent_agents_dict[agent_name].get_user_profile()
123
 
124
- communication_style = user_profile.get_field("Communication", "Style")
 
125
 
126
  question_task_description = f"""
127
  You are responding to a market research interview question. Your response must strictly follow the **style and tone** outlined below.
@@ -179,28 +180,41 @@ A culturally authentic and conversational response to the question: '{question}'
179
  agent=respondent_agent
180
  )
181
 
182
- logging.info(f"Executing task for {agent_name}")
183
-
 
 
 
184
  # Create a new crew for each agent-question pair
185
  crew = Crew(
186
  agents=[respondent_agent],
187
  tasks=[question_task],
188
  process=Process.sequential
189
  )
190
-
 
191
  try:
 
192
  crew_output = crew.kickoff()
 
 
193
  task_output = question_task.output
194
-
 
195
  # Collect and format the response
196
  if task_output.raw:
197
- responses.append(f"**{agent_name}**: {task_output.raw}")
 
 
198
  else:
199
- responses.append(f"**{agent_name}**: I wasn't able to answer right now - can you try again?")
200
-
 
 
201
  except Exception as e:
202
- logging.error(f"Error during execution for {agent_name}:", exc_info=True)
203
- responses.append(f"**PreData Moderator**: An error occurred while processing {agent_name}'s response. Please try again.")
 
204
 
205
  return responses
206
 
 
121
  respondent_agent = respondent_agents_dict[agent_name].get_agent()
122
  user_profile = respondent_agents_dict[agent_name].get_user_profile()
123
 
124
+ # communication_style = user_profile.get_field("Communication", "Style")
125
+ communication_style = ""
126
 
127
  question_task_description = f"""
128
  You are responding to a market research interview question. Your response must strictly follow the **style and tone** outlined below.
 
180
  agent=respondent_agent
181
  )
182
 
183
+ logging.debug(f"Created task for agent '{agent_name}' with description: {question_task_description}")
184
+
185
+ # Log before starting task execution
186
+ logging.info(f"Executing task for agent '{agent_name}'")
187
+
188
  # Create a new crew for each agent-question pair
189
  crew = Crew(
190
  agents=[respondent_agent],
191
  tasks=[question_task],
192
  process=Process.sequential
193
  )
194
+ logging.debug(f"Crew initialized for agent '{agent_name}' with 1 task and sequential process")
195
+
196
  try:
197
+ # Start the task
198
  crew_output = crew.kickoff()
199
+ logging.info(f"Task execution completed for agent '{agent_name}'")
200
+
201
  task_output = question_task.output
202
+ logging.debug(f"Raw output from agent '{agent_name}': {task_output.raw}")
203
+
204
  # Collect and format the response
205
  if task_output.raw:
206
+ formatted_response = f"**{agent_name}**: {task_output.raw}"
207
+ responses.append(formatted_response)
208
+ logging.info(f"Formatted response from agent '{agent_name}' added to responses")
209
  else:
210
+ fallback_response = f"**{agent_name}**: I wasn't able to answer right now - can you try again?"
211
+ responses.append(fallback_response)
212
+ logging.warning(f"No output from agent '{agent_name}'. Added fallback response.")
213
+
214
  except Exception as e:
215
+ logging.error(f"Error during task execution for agent '{agent_name}': {str(e)}", exc_info=True)
216
+ error_response = f"**PreData Moderator**: An error occurred while processing {agent_name}'s response. Please try again."
217
+ responses.append(error_response)
218
 
219
  return responses
220