Skip to main content

9. python — Run Python

Mode: Both · Category: Other · Copilot types: Internal, Chat

Executes Python code in a sandboxed environment. Operates in two modes:

  • Dynamic mode (no code, or code without input_schema/columns): The LLM writes and executes code freely.

  • Static mode (code + input_schema and/or columns): Code is pre-defined by the creator. The LLM only fills the input variables declared in input_schema. Data from columns is loaded as a df DataFrame before execution.

- id: python
  code: |
    import pandas as pd
    result = df[df['status'] == status_filter].shape[0]
    print(f"Count: {result}")
  columns:
    - INVOICE.INVOICE_STATUS
    - INVOICE.INVOICE_NUMBER
  input_schema:
    properties:
      status_filter:
        description: The status value to filter invoices by.
        type: string
- id: python
  code: |
    import pandas as pd
    summary = df.describe()
    print(summary.to_string())
  columns:
    - INVOICE.INVOICE_AMOUNT
    - INVOICE.INVOICE_STATUS
pc_at_add_python.png

Field

Type

Description

code

string

Pre-defined Python code. Setting this with input_schema or columns activates static mode.

input_schema

object

Input variable definitions — each property becomes an LLM argument.

columns

list[string]

Column IDs loaded as a df DataFrame before code execution.

adhoc_filtering

bool

Allow the LLM to add ad-hoc filters to the data loading (default: false).

Related topics