Back to bricks list
Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
Version

AITableGeneratePlotly

Class to call AI to generate a plotly figure from a table. The data of the table is not transferered to OpenAI, only the provided text.

Attributes
chat: OpenAiChatmessage_dispatcher: MessageDispatchertable: Table
Functions
__INIT__

Initialize self. See help(type(self)) for accurate signature.

table : Table
chat : OpenAiChat
message_dispatcher : Any
BUILD_CODE_INPUTS

Method to build the variables that will be accessible in the generated code. It is recommended to use known object types for the inputs, like dict, list, Dataframe, int ... so the AI can understand the structure of the input.

Return type : dict
BUILD_CODE_RULES_CONTEXT

Method to define the context rules for the code generation, so the generated code is executable. This method can be overrided to change the way of describing the code context.

pip_package_names : List
list of available package that can be used in the generated code. The version of the package will be automatically retrieved
Return type : str
BUILD_CONTEXT

Method that is automatically called by the task to build the context. This method can be overided to change the way of describing the context.

code_inputs : Dict
Return type : str
BUILD_INPUTS_CONTEXT

Method that is automatically called by the task to describe the inputs that are accessible in the generated code. This method can be overrided to change the way of describing the inputs, or to add more information (like the number of rows for a dataframe, the structure of a json ...)

code_inputs : Dict
Return type : str
BUILD_MAIN_CONTEXT

Method to build the context of the openAI chat. This should define the main goal of the task. You can use context variable to build main context.

The recommended order is :

  • INTRO
  • Text to explain the goal of the task (Ex: "The code purpose is to generate a plotly express figure from a DataFrame.")
  • INPUTS
  • OUTPUTS
  • CODE_RULES

You can insert text after a variable to add more information, like :

  • inputs_description + 'The dataframe has ' + str(table.nb_rows) + ' rows and ' + str(table.nb_columns) + ' columns.'
  • outputs_description + 'Only build the figure object, do not display the figure using 'show' method.'
context : AIPromptCodeContext
the variables to build the context
Return type : str
BUILD_OUTPUT

Method to build the output based on the generated code outputs.

code_outputs : dict
the outputs of the generated code
Return type : PlotlyResource
BUILD_OUTPUTS_CONTEXT

Method that is automatically called by the task to describe the outputs that are accessible in the generated code. This method can be overrided to change the way of describing the outputs.

Return type : str
GENERATE_AGENT_CODE

Generate the agent code that will be used to run the code in the agent.

Return type : str
GET_AVAILABLE_PACKAGE_NAMES

Method to retrieve the package names that can be used by the AI in the generated the code. The package must be installed in the lab. This is used by build_code_context to retrieve the version of the package are write a text to describe the packages. Return empty list if no package is needed.

Return type : List
GET_CODE_EXPECTED_OUTPUT_TYPES

Method to describe the output names (keys) and types (values) expected by the generated code. The AI will receive instructions to generate code that returns variables with the specified names and types. This is used by build_task_outputs to retrieve the output of the generated code.

Return type : Dict
RUN
Return type : Any
GENERATE_AGENT_CODE_TASK_OUTPUT_CONFIG - @staticmethod

Get the task output config for the generate_agent_code task.

Return type : OutputSpec