Icon

Group 2 - Define a tool (A touch of AI)

<p><strong>Agentic AI Learnathon - Group 2</strong></p><p>In this exercise you will develop an intelligent tool that has access to company information. It takes in input a query and the company name, matches the name with a company in the database and retrieves the requested information. You will also practice how to transform a workflow into a callable workflow and set the tool description.</p>












🕵️‍♂️ (Optional) Step 6. Anonymize data

The prompt might contain sensitive data. You can use the Presidio nodes to remove or mask this data, and then reinsert it after the model generates an output.

  1. Add the Presidio Anonymizer node before the LLM Prompter node. Mask all the sensitive data in the prompt.

  2. Add the Presidio Deanonymizer node after the LLM Prompter node to reinsert the masked data. Provide in input the model response and the entity mapping produced by the Presidio Anonymizer node.

💡 This step can be also done with a RAG system. Learn more about it here.

Group 2 - Define a tool (A touch of AI ✨)

🛠️Tool - Company Information


In this exercise you will develop an intelligent tool that has access to company information. It takes in input a query and the company name, matches the name with a company in the database and retrieves the requested information. You will also practice how to transform a workflow into a callable workflow and set the tool description.


Read company data file

The Excel Reader nodes read the files containing company data. The file includes, among the other, information about the industry, the domain and location of the company, the number of employees, the year of foundation and whether it is a KNIME customer or not.



📝 Example input

This table shows an example input to use during development. You will replace this example with the actual input from the caller.



Step 1. Find company by string similarity search

  1. Add a String Matcher node and connect

    • the Table Creator (Example company) to the top input.

    • the Excel Reader (Companies) to the bottom input.

  2. Configure the String Matcher node to use the column company as search string and the column Company Name as dictionary column. Retrieve only 1 related word.

  3. Add a Value Lookup node and connect

    • the String Matcher node to the top input.

    • the Excel Reader (Companies) to the bottom input.

  4. Configure the Value Lookup node the column Related1 as lookup column and the Company Name as key column.


Step 8-9. Tool definition

This is the last step of the exercise! Come back here once you have completed the other steps. Open the metanode and follow the instructions.



Step 2. Prepare the company information for the LLM prompt

  1. Convert the table containing the company info into a JSON Object using the Columns to JSON node.

    • set the new column name to company info

    • select all the columns except Origin

    • click Remove the source columns option.

  2. Use a String Manipulation node to convert the JSON column to a string using the string() function. You can use the expression string($company info$). Select the option to replace the column company info.


Note: This step will make it easier to add the company information to the LLM prompt.

Step 4. Authenticate and connect to an LLM

  1. Configure the Get Api Key component to provide a valid API key for OpenAI. Ask your instructor to get username and password.

  2. Pass the key as a flow variable to the OpenAI Authenticator node.

  3. Use the OpenAI Chat Model Connector to connect to the default model.


Step 5. Prompt the LLM

  1. Connect the prompt (Step 3) and the model (Step 4) to an LLM Prompter node. Select the column containing the prompt and activate the JSON output.


Step 7. Configure the tool output

Remember that a tool is a workflow that can be called by a caller, receive data from it, and send data back to the caller.

This tool retrieves the requested company's information and sends it as a JSON object to the caller workflow.

  1. Convert the response of the LLM into a JSON object using the String to JSON node. Make sure to select the correct column.

  2. Add a Container Output (JSON) node. In its configuration, click the button "Fill example JSON from input data".
    This is the output produced by the tool given the example input.

  3. Move back to the beginning of the workflow and complete Step 8 and 9, where you will set the tool description and configure the tool input.



💡Help

If you are having troubles creating the prompts with
the Expression node, have a look at the Help metanode.

✨ Alternatively, click Ask K-AI in the Expression node
and let the copilot build it for you!

🕵️‍♂️ Anonymization

🕵️‍♂️ Deanonymization

Step 3. Create LLM Prompt

The Table Row to Variable node converts the user input 'query' into a flow variable.

  1. Build the prompt for the LLM using the Expression node. The prompt should include:

    • The task: Something like "Retrieve information about a company and return it in a JSON object".

    • The user query: which information to retrieve. This is included in the flow variable created by the Table Row to Variable node.

    • The company information from Step 2.

    • Optionally, an example of the expected output.


In the 💡Help metanode below you can find a prompt example.

Get API Key
Presidio Deanonymizer
Convert columnsto JSON object
Columns to JSON
Retrieve companyinformation
Value Lookup
Connect to mode
OpenAI Chat Model Connector
Presidio Anonymizer
Tool definition
User queryto flow variable
Table Row to Variable
String to JSON
Help - Expression nodes
Companies
Excel Reader
Convert JSONto string
String Manipulation
Match companyby similarity
String Matcher
Container Output (JSON)
LLM Prompter
LLM prompt
Expression
Example company
Table Creator
Authenticate
OpenAI Authenticator

Nodes

Extensions

Links