DATA STORIES | ARTIFICIAL INTELLIGENCE | KNIME ANALYTICS PLATFORM

Integrating Agent Frameworks into Low Code Tools: Making CrewAI work in KNIME

The How-To guide to get you started

Martin D Aus A
Low Code for Data Science

--

Crew AI: A Python-based AI Agent Framework

Crew AI is a framework that’s been gaining traction lately. It allows for the creation of LLM-based AI agents that direct workflows, moderate language, and act as cohesive units to tackle specific tasks. For those interested in delving deeper, I’ve provided a link to the Crew AI GitHub page here.

Implementing Crew AI in No-Code Tools

AI Agent frameworks have the potential to add lots of value by modelling and automating mundane, manual tasks. That said this for now still requires to be able to understand and modify Python Code. To try and make tools like this more accessible I’ve integrated Crew AI into a KNIME Workflow with dedicated user interfaces for:

  • Creating Agents
  • Creating Tasks
  • Configuring a local Language Model to be used (either locally hosted via LM Studio or alternatively by using OpenAI API)

What you need:

To get started, you’ll need:

  • Latest KNIME Analytics Platform (I’m using version 5.2) with the KNIME Python Integration installed.
  • Your own Python environment with necessary packages (step-by-step instructions covered at the end of this Article
  • An OpenAI API Key or alternatively a locally hosted LLM / any other hosted LLM with an OpenAI Chat completion-like user interface

Utilizing Crew AI: The Process

Information Requirements:

Define Agents

Open the Define Agent Component and provide:

  • Agent Name
  • Agent Goal
  • Agent Backstory
  • Agent Model (only relevant if OpenAI API is used)

Define Tasks:

Open the Define Task Component and:

  • Ensure Input Port is connected to merged Agent output port
  • Provide Task Name
  • Provide Task Description
  • Optional: include any parameters in {} — e.g. {Topic}. This will allow you to make Agent Swarms re-usable.
  • Optional: Provide Parameter Value & Parameter Name. This is required if a Parameter is included in the task description. Parameter Name does not need to have {} here, but make sure to reference it with {} e.g.- as {Topic} in the Task Description
  • Select Agent to perform the task

Building a Blog Post Writer Agent Swarm and Running the Workflow

First, execute and view the “Provide Model Details” component and either provide an OpenAI API Key or the base URL of a locally hosted LLM. If you have the hardware to support it, using a software called LM Studio to run a model available on Huggingface.co — e.g. in my example shown in a YouTube video I used Dolphin 2.6 Mistral 7B provided by TheBloke.

A very simple use case is to set up two agents for the task of creating a blog post:

We have the following agents:

  • Blog Post Outline Creator
  • Blog Post writer

We define the following tasks:

  • Brainstorm Blog Post performed by the Blog Post Outline Creator
  • Write Blog Post performed by the Blog Post writer

You can access the full example here: KNIME Community Hub

KNIME Workflow KNIME_CrewAI.

Once the agents have been set up all you need to do is to execute the Python Script node at the very end. I recommend to switch to the KNIME Classical User Interface before running the Python node so that you have access to the KNIME Console to monitor progress.

Depending on the model you are using and the size of the task, running the agent swarm may take a while. To accelerate I highly recommend, at least for the initial release, to include “YOU DO NOT NEED TO USE TOOLS” in all Agent Backstories and Task Descriptions. The current version does not support tool usage (area for future development), however the agents will still try to use tools the make up and without the additional prompt input I had certain instances where the agents did not realise tools had not been defined.

Setting Up Your Conda Environment

If you are not familiar with setting up Python environments, here’s a step-by-step guide to set up a conda environment “knime_crewai” using Miniconda:

Start Miniconda
  • Take note of base folder in the anaconda window (e.g. in this case “C:\Users\marti”. Navigate to this folder and copy the downloaded “environment.yml” file from step 2 into this folder
  • In the Anaconda Prompt window type: “conda env create -f environment.yml” and hit enter. This will trigger creation of an environment with all the required packages
  • Once the environment set up is complete, enter in the same window the command: “conda activate knime_crewai”. The text in brackets on the left should switch to (knime_crewai) if environment activation was successful

Activate the Environment:

Verify that environment has been created successfully:

  • Now open up KNIME and go to Preferences => KNIME => Python. From the three options select “conda”

Navigate here and wait for Environment dropdown to be available:

  • Wait KNIME to finish detecting conda environments on your system and then open the dropdown and select “knime_crewai”
  • Click “Apply and Close” and you are set to spin up your agents!

And now… enjoy exploring what AI Agents can do for you 😊.

--

--