def continue_response( self, base_response_result: ResponseGeneratorResult, new_entity: Optional[str] = None) -> ResponseGeneratorResult: state = base_response_result.state conditional_state = base_response_result.conditional_state new_state = state.update(conditional_state) if not (base_response_result.cur_entity or new_entity): raise CantContinueResponseError( "Neither base_response_result.cur_entity nor new_entity was given" ) entity = base_response_result.cur_entity try: text, new_conditional_state = self.prompt_sections( new_state, entity, repeat=conditional_state.discussed_section is not None, have_response=base_response_result.text != '') except CantPromptError as e: raise CantContinueResponseError(*e.args) from e text = base_response_result.text + ' ' + text conditional_state.suggested_sections = new_conditional_state.suggested_sections conditional_state.prompted_options = new_conditional_state.prompted_options conditional_state.cur_doc_title = new_conditional_state.cur_doc_title conditional_state.prompt_handler = new_conditional_state.prompt_handler base_response_result.conditional_state = conditional_state base_response_result.text = text base_response_result.needs_prompt = False return base_response_result
def continue_response( self, base_response_result: ResponseGeneratorResult, new_entity: Optional[str] = None) -> ResponseGeneratorResult: state = base_response_result.state conditional_state = base_response_result.conditional_state new_state = state.update(conditional_state) if not (base_response_result.cur_entity or new_entity): raise CantContinueResponseError( "Neither base_response_result.cur_entity nor new_entity was given" ) entity = new_entity or base_response_result.cur_entity if len(new_state.entity_state[entity.name].highlights_used) >= 2: raise CantContinueResponseError( "Already gave open response twice, not prompting anymore") try: text, new_conditional_state = self.get_prompt_question( new_state, entity) except CantPromptError as e: raise CantContinueResponseError(*e.args) from e text = base_response_result.text + ' ' + text conditional_state.prompt_handler = self.__repr__() conditional_state.cur_doc_title = new_conditional_state.cur_doc_title conditional_state.open_question = new_conditional_state.open_question base_response_result.conditional_state = conditional_state base_response_result.text = text base_response_result.needs_prompt = False base_response_result.cur_entity = entity return base_response_result
def continue_response( self, base_response_result: ResponseGeneratorResult ) -> ResponseGeneratorResult: state = base_response_result.state conditional_state = base_response_result.conditional_state new_state = state.update(conditional_state) entity = base_response_result.cur_entity if not entity: raise CantContinueResponseError( "base_response_result.cur_entity was not set") til_response = self.get_til(entity.name, new_state) if not til_response: raise CantContinueResponseError("Not prompting for more TILs.") text = base_response_result.text + ' ' + self.rg.state_manager.current_state.choose_least_repetitive( WANNA_KNOW_MORE) conditional_state.prompted_options = [entity.name] conditional_state.prompt_handler = self.__repr__() base_response_result.conditional_state = conditional_state base_response_result.text = text base_response_result.needs_prompt = False return base_response_result