ConversationalData - agents API reference (0.0.10)

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# ConversationalData

class inmydata.ConversationalData.ConversationalDataDriver(tenant: str, server: str = 'inmydata.com', logging_level=20, log_file: str | None = None)

  Bases: `object`

  This class provides methods for querying data in the inmydata platform using a conversational interface. It allows users to ask questions about their data and receive answers in various formats, including text and structured data. It uses the inmydata API to fetch data and returns it as a pandas DataFrame or a string response.

  tenant

    The tenant identifier for the inmydata platform.

    Type:

      str

  server

    The server address for the inmydata platform, default is “inmydata.com”.

    Type:

      str

  logging_level

    The logging level for the logger, default is logging.INFO.

    Type:

      int

  log_file

    The file to log messages to, if None, logs to console.

    Type:

      Optional[str]

  ## Members

  __init__(tenant: str, server: str = 'inmydata.com', logging_level=20, log_file: str | None = None)

    Initializes the ConversationalDataDriver with the specified tenant, server, logging level, and optional log file.

    Parameters:

      - tenant (str) – The tenant identifier for the inmydata platform.

      - server (str) – The server address for the inmydata platform, default is “inmydata.com”.

      - logging_level (int) – The logging level for the logger, default is logging.INFO.

      - log_file (Optional[str]) – The file to log messages to, if None, logs to console.

  async get_answer(question: str, subject: str | None = None) → Answer

    Returns a text response for a given question.

    Parameters:

      - question (str) – The question you want to ask.

      - subject (str, optional) – The subject you want to ask the question about. If None provided, copilot with choose the subject.

    Raises:

      ai_question_update – This event is triggered when the AI question status is updated. The callback function will receive the instance of this class and a string containing the status message as parameters.

    Returns:

      A string response to the question.

    Return type:

      Answer

  async get_answer_and_data_frame(question: str, subject: str | None = None) → QuestionResponse | None

    Returns a stext and pandas DataFrame response for a given question.

    Parameters:

      - question (str) – The question you want to ask.

      - subject (str, optional) – The subject you want to ask the question about. If None provided, copilot with choose the subject.

    Raises:

      ai_question_update – This event is triggered when the AI question status is updated. The callback function will receive the instance of this class and a string containing the status message as parameters.

    Returns:

      A structured response containing both a string and a pandas DataFrame.

    Return type:

      QuestionResponse

  async get_data_frame(question: str, subject: str | None = None) → DataFrame | None

    Returns a pandas DataFrame response for a given question.

    Parameters:

      - question (str) – The question you want to ask.

      - subject (str, optional) – The subject you want to ask the question about. If None provided, copilot with choose the subject.

    Raises:

      ai_question_update – This event is triggered when the AI question status is updated. The callback function will receive the instance of this class and a string containing the status message as parameters.

    Returns:

      A pandas DataFrame containing the data in response to the question.

    Return type:

      pd.DataFrame

  on(event_name, callback)

    Registers a callback function for a specific event.

    Parameters:

      - event_name (str) – The name of the event to listen for.

      - callback (function) – The function to call when the event is triggered. The function should accept two parameters: the instance of this class and the event data.

    Raises:

      ai_question_update – This event is triggered when the AI question status is updated. The callback function will receive the instance of this class and a string containing the status message as parameters.