class_docstr: Agent class to improve the conversational experience in PandasAI
class_docstr_tok: ["Agent","class","to","improve","the","conversational","experience","in","PandasAI"]
docstr: Simulate a chat interaction with the assistant on Dataframe.
docstr_tok: ["Simulate","a","chat","interaction","with","the","assistant","on","Dataframe","."]
code: def chat(self, query: str, output_type: Optional[str] = None):
      """
      Simulate a chat interaction with the assistant on Dataframe.
      """
      try:
          is_related = self.check_if_related_to_conversation(query)
          self._lake.is_related_query(is_related)
          return self._lake.chat(query, output_type=output_type)
      except Exception as exception:
          return (
              "Unfortunately, I was not able to get your answers, "
              "because of the following error:\n"
              f"\n{exception}\n"
          )
  
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 4 for calling the Agent obj's underlying member method code with example usage: obj.chat(query, output_type) and returns: self, str, exception, str