[docs]classWaitingFreeTextState(BaseState):"""State where the user is expected to provide a free text response to the assesment question."""RESPONSE_VARIATIONS=["Got it, thanks for telling me. Based on what you described, which of these options best fits how often you've felt that way over the last 2 weeks?","Okay, I hear you. Thinking about what you've mentioned, could you select the option that best describes the frequency over the last 2 weeks?","Right, thanks for explaining that. To help map that feeling, which option here matches your experience most closely over the last 2 weeks?","Okay, I really appreciate you sharing that. Looking at these choices, which one best reflects how often this occurred for you over the last 2 weeks?","Right, that gives me a better picture. Now, considering the frequency over the last 2 weeks, please choose the option below that applies best.",]
[docs]defgenerate_response(self,user_input,conversation_id,assessment_id):# Get the current question that was askedquestion_json=self.context._get_question_json(assessment_id)#Building responseprompt=f"{random.choice(self.RESPONSE_VARIATIONS)}\n"fori,optioninenumerate(question_json['options']):prompt+=f"\n{i+1}. {option}"prompt+="\n\n(Just pop the number in)"# Changing state of AssesmentAgent to WaitingCategorizationStateself.context._transition_to_next_state(WaitingCategorizationState())# Updating Assesment in DBself.context.assess_repo.update_assessment(assessment_id,current_state=self.context.STATE_WAITING_CATEGORIZATION,last_free_text=user_input)returnprompt