class_docstr: Agent class to improve the conversational experience in PandasAI
class_docstr_tok: ["Agent","class","to","improve","the","conversational","experience","in","PandasAI"]
docstr: Check if the query is related to the previous conversation
docstr_tok: ["Check","if","the","query","is","related","to","the","previous","conversation"]
code: def check_if_related_to_conversation(self, query: str) -> bool:
      """
      Check if the query is related to the previous conversation
      """
      if self._lake._memory.count() == 0:
          return
  
      prompt = CheckIfRelevantToConversationPrompt(
          conversation=self._lake._memory.get_conversation(),
          query=query,
      )
  
      result = self._call_llm_with_prompt(prompt)
  
      related = "true" in result
      self._logger.log(
          f"""Check if the new message is related to the conversation: {related}"""
      )
  
      if not related:
          self._lake.clear_memory()
  
      return related
  
imports: import json
  from typing import Union, List, Optional
  from ..helpers.df_info import DataFrameType
  from ..helpers.logger import Logger
  from ..helpers.memory import Memory
  from ..prompts.base import AbstractPrompt
  from ..prompts.clarification_questions_prompt import ClarificationQuestionPrompt
  from ..prompts.explain_prompt import ExplainPrompt
  from ..prompts.rephase_query_prompt import RephraseQueryPrompt
  from ..prompts.check_if_relevant_to_conversation import CheckIfRelevantToConversationPrompt
  from ..schemas.df_config import Config
  from ..skills import Skill
  from ..smart_datalake import SmartDatalake
label_desc: Use image node_id 6 for calling the Agent obj's underlying member method code with example usage: obj.check_if_related_to_conversation(query) and returns: related