Skip to content
KNIME Documentation
Main Navigation Get startedBuildWork with KnimeAccount and adminRelease notesDeveloper tools
Community Hub
DevelopersKnime 2.0
Sidebar Navigation

Getting Started

Installation

User Guide

Release Notes

Install Extensions

Building Workflows

Components

Flow Control

Expressions

File Handling

Deployment

Integrated Deployment

Workflow Invocation

Best Practices

Advanced Features

AI Extension

Get Started

Build an Agent

Inject context with RAG

LLM Providers

Tutorials

Summarize product reviews

Product FAQ assistant

Restaurant agent

Your first local agent

Task extractor

Reporting

Kerberos

Extensions

Database

Overview

Tutorials

Read and filter data from a database

Write a transformed dataset to a database

Concepts

Ports and Sessions

Query Generation

Type Mapping

Deprecated Framework

Connecting

Connect: Dedicated Node

Connect: File-Based Database

Connect: Generic DB Connector

Register a JDBC Driver

Install Third-Party Driver Plug-in

Drivers on Hub and Server

Kerberos Constrained Delegation

Reading and Transforming

Read Data

Transform Data Visually

Run a Custom SQL Query

Parameterize a Query

Writing and Modifying

Insert, Update, or Merge

Delete Rows

Bulk Load Data

Create and Remove Tables

Use Transactions

Reference

Connector Node Settings

JDBC Driver Reference

Deprecated Node Mapping

Migrate Deprecated Workflows

Python

Overview

Tutorials

Python Scripting Quickstart

Data App Development Using Plotly

Data Processing

K-AI Scripting Assistant

Data Type Conversion

Batch Processing

Jupyter Integration

Environment Management

Pixi Configuration

Dependency Management

Environment Persistence

Channel Mirrors & Air-Gapped Setups

Conda Migration

Alternative Configurations

Conda and Miniforge Setup

Conda Environment Propagation

Manual Python Configuration

Legacy Node Migration

Concepts

Pixi Backend Architecture

Storage Logic

Python Environments on Executors

Reference

Python Scripting API

Bundled Packages

Executor and Hub Configuration

Troubleshooting Guide

API Reference

Inputs and outputs

Classes

Views

Utility functions

R

Deep Learning

Snowflake

Google Cloud

Azure

AWS

Big Data

Big Data Admin

Big Data Secured Cluster

Databricks

Microsoft Fabric

Power BI

Tableau

Report Designer

H2O

Changelogs

Version 5.12

Version 5.11

Version 5.10

Version 5.9

Version 5.8

Version 5.7

Version 5.6

Version 5.5

Version 5.3

Extensions

K-AI Assistant for Python Code ​

KNIME Analytics Platform includes a built-in AI assistant, K-AI, which can help you write, explain, and debug Python code directly within the Python Script nodes.

Writing Python Code with K-AI ​

The "Ask K-AI" feature within the configuration dialog of a Python Script node is an advanced AI-assisted code generation tool. When activated, you can input prompts specifying the intended functionality. K-AI has contextual awareness of the KNIME Python API, your input data's structure, and the current script content in the editor.

  1. Open the Python Script node: Double-click the node to open the configuration dialog.
  2. Access the K-AI panel: Click the Ask K-AI button to open the prompt interface.
  3. Write a prompt: Ask K-AI to perform a specific data manipulation task. For example:
    • "Filter the dataset to include only rows where 'Sales' is greater than 1000."
    • "Convert the 'Date' column to datetime format."
    • "Calculate the moving average of the 'Revenue' column."
  4. Review the Diff: Once the assistant generates the code, it is presented to you in a diff-editor format, which highlights the differences between your current code and the new suggestion.
  5. Accept or Discard: You have the option to review these suggestions and choose whether to accept them into your script or discard them, providing a high degree of control over the changes made to your code.

The Ask K-AI dialog inside a Python Script node showing the diff-editor view.

Debugging and Explaining Code ​

K-AI is also useful when you have existing code that is throwing an error or that you don't fully understand:

  • Explain Code: Select a block of Python code and ask K-AI to "Explain this code". It will break down what the script is doing conceptually.
  • Fix Errors: If your node execution fails with a Python exception, you can prompt K-AI with the error message. It will analyze your script and suggest a fix.

Privacy and Data ​

When using K-AI inside a Python node:

  • Schema Context: K-AI is automatically aware of your input table's column names and data types to write accurate code.
  • Data Privacy: K-AI does not read your actual data rows (cell values).

Data Transmission

When you use Ask K-AI, the current code from the editor, your input data's schema, and your prompt are sent over the internet to the configured KNIME Hub and OpenAI. This is necessary for the AI to tailor code suggestions to your script's context. Keep this in mind if you are working with sensitive column names or proprietary schema information.

Pager
Previous pageData App Development Using Plotly
Next pageData Type Conversion