def should_answer(
        self,
        should_answer_prompt_template: str = SHOULD_ANSWER_PROMPT_TEMPLATE,
        **kwargs,
    ) -> Optional[AgentFinish]:
        """Determine if agent should continue to answer user questions based on the latest user
        query"""
        if "history" not in kwargs or not kwargs["history"]:
            return None

        history = kwargs.pop("history")
        inputs = {
            "history": history.format_message(),
            **kwargs,
        }

        def _parse_response(res: str):
            if "yes" in res.lower():
                return AgentFinish(
                    message="Thank your for contacting",
                    log="Thank your for contacting",
                )
            else:
                return None

        prompt = Template(should_answer_prompt_template).substitute(**inputs)
        response = (
            self.llm.generate([UserMessage(content=prompt)])
            .generations[0]
            .message.content
        )
        return _parse_response(response)
Determine if agent should continue to answer user questions based on the latest user
        query
autochain/agent/conversational_agent/conversational_agent.py