Agents (tm.agents)
The tablemage.agents module contains ChatDA, TableMage’s conversational chatbot for no-code data analysis.
tm.use_agents
tm.agents.ChatDA
- class tablemage.agents.ChatDA(df: DataFrame, df_test: DataFrame | None = None, test_size: float = 0.2, split_seed: int = 42, system_prompt: str = "You are a helpful data scientist. You are equipped with tools for analyzing the dataset. Your tools are already connected to the dataset.\n\nYour tools span the following categories:\n- Exploratory Data Analysis (plotting, summary statistics, t-tests, anova, etc.)\n- Machine Learning (regression, classification, clustering, feature selection)\n- Linear Regression (OLS, Logit)\n- Data Transformation (scaling, imputation, encoding, feature engineering, etc.)\n\nAt each step, only the most relevant tools based on the user's request will be made available to you. Use as few tools as possible to answer the user's question. The user can see your tools' output. Never refer to your tools in your response.\n\nWith your tools, provide the user with expert results, insights, and synthesis. Be concise and clear in your answers. Be conversational. When appropriate, suggest next steps for the user.\nIf no relevant tools are available, let the user know you are unable to assist. \nMOST IMPORTANTLY: If a request is too general, ask clarifying questions and guide the user to a more specific request. DO NOT GO OVERBOARD WITH TOOL USAGE RIGHT AWAY.\n", react: bool = False, memory_type: Literal['buffer', 'vector'] = 'vector', memory_size: int = 3000, tool_rag: bool = True, tool_rag_top_k: int = 5, python_only: bool = False, tools_only: bool = False, multimodal: bool = False, verbose: bool = True)[source]
Chat Data Analyst. Class for interacting with the LLMs for data analysis on tabular data.
- __init__(df: DataFrame, df_test: DataFrame | None = None, test_size: float = 0.2, split_seed: int = 42, system_prompt: str = "You are a helpful data scientist. You are equipped with tools for analyzing the dataset. Your tools are already connected to the dataset.\n\nYour tools span the following categories:\n- Exploratory Data Analysis (plotting, summary statistics, t-tests, anova, etc.)\n- Machine Learning (regression, classification, clustering, feature selection)\n- Linear Regression (OLS, Logit)\n- Data Transformation (scaling, imputation, encoding, feature engineering, etc.)\n\nAt each step, only the most relevant tools based on the user's request will be made available to you. Use as few tools as possible to answer the user's question. The user can see your tools' output. Never refer to your tools in your response.\n\nWith your tools, provide the user with expert results, insights, and synthesis. Be concise and clear in your answers. Be conversational. When appropriate, suggest next steps for the user.\nIf no relevant tools are available, let the user know you are unable to assist. \nMOST IMPORTANTLY: If a request is too general, ask clarifying questions and guide the user to a more specific request. DO NOT GO OVERBOARD WITH TOOL USAGE RIGHT AWAY.\n", react: bool = False, memory_type: Literal['buffer', 'vector'] = 'vector', memory_size: int = 3000, tool_rag: bool = True, tool_rag_top_k: int = 5, python_only: bool = False, tools_only: bool = False, multimodal: bool = False, verbose: bool = True)[source]
Initializes the ChatDA object.
- Parameters:
df (pd.DataFrame) – The DataFrame to build the Analyzer for.
df_test (pd.DataFrame | None) – The test DataFrame to use for the Analyzer. Defaults to None.
test_size (float) – The size of the test set. Defaults to 0.2.
split_seed (int) – The seed to use for the train-test split. Default is 42.
system_prompt (str) – The system prompt to use for the LLM. Default is provided.
react (bool) – If True, the agent will employ the ReAct framework. Default is False.
memory_type (Literal["buffer", "vector"]) – The type of memory to use. Default is “vector”.
memory_size (int) – The size of the memory to use. Token limit synonym. Default is 3000.
tool_rag (bool) – If True, the RAG-based tooling is used. Default is True.
tool_rag_top_k (int) – The top-k value to use for the RAG-based tooling. Default is 5.
python_only (bool) – If True, only the Python environment is provided. Default is False.
tools_only (bool) – If True, only the non-coding tools are provided. Otherwise, the Python environment is also provided. python_only and tools_only cannot be True at the same time.
multimodal (bool) – If True, multimodal LLM is used only for interpreting figures. Default is False.
verbose (bool) – If True, prints agent thoughts and tool outputs. Default is True.
tm.agents.ChatDA_UserInterface
- class tablemage.agents.ChatDA_UserInterface(split_seed: int | None = None, system_prompt: str | None = None, react: bool | None = None, memory_type: Literal['buffer', 'vector'] | None = None, memory_size: int | None = None, tool_rag: bool | None = None, tool_rag_top_k: int | None = None, python_only: bool | None = None, tools_only: bool | None = None, multimodal: bool | None = None)[source]
- __init__(split_seed: int | None = None, system_prompt: str | None = None, react: bool | None = None, memory_type: Literal['buffer', 'vector'] | None = None, memory_size: int | None = None, tool_rag: bool | None = None, tool_rag_top_k: int | None = None, python_only: bool | None = None, tools_only: bool | None = None, multimodal: bool | None = None)[source]
Makes a user interface for the ChatDA agent.
- Parameters:
split_seed (int | None) – If None, default seed is used.
system_prompt (str | None) – If None, default system prompt is used.
react (bool | None) – If None, default ReAct flag is used. If True, ReAct is used. If False, ReAct is not used.
memory_type (Literal["buffer", "vector"] | None) – If None, default memory type is used. If “buffer”, buffer memory is used. If “vector”, vector plus buffer memory is used.
memory_size (int | None) – If None, default memory size is used. The size of the buffer.
tool_rag (bool | None) – If None, default tool RAG flag is used. If True, tool RAG is used. If False, tool RAG is not used, and all tools are provided to the agent for each query.
tool_rag_top_k (int | None) – If None, default tool RAG top k is used. The number of tools to provide to the agent for each query.
python_only (bool | None) – If None, default Python-only flag is used. If True, only Python environment is provided. If False, all tools are used.
tools_only (bool | None) – If None, default tools-only flag is used. If True, only tools are used. If False, all tools are used.
multimodal (bool | None) – If None, default multimodal flag is used. If True, multimodal model is used for image interpretation.
tm.agents.options
- tablemage.agents.options.set_llm(llm_type: Literal['openai', 'groq', 'ollama'], model_name: str | None = None, temperature: float = 0.1) None
Sets the LLM type.
- Parameters:
llm_type (Literal["openai", "groq", "ollama"]) – The type of LLM to use.
model_name (str, optional) – The name of the model to use, by default None. If None, the default model for llm_type will be used.
temperature (float, optional) – The temperature to use for the LLM, by default 0.0.
- tablemage.agents.options.set_multimodal_llm(llm_type: Literal['openai'], model_name: str | None = None, temperature: float = 0.1) None
Sets the multimodal LLM type.
- Parameters:
llm_type (Literal["openai"]) – The type of multimodal LLM to use.