Icon

Sentiment Analysis with Generative AI

<p>Demo related to sentiment analysis given at Harvard on 09/16/2025</p>

Demo related to sentiment analysis given at Harvard on 09/16/2025

Step 1. Read data and create prompt

  1. Read the reviews.xlsx file from the data folder.

  2. Use the Expression node to create a prompt which instructs an LLM to classify the sentiment of the reviews in the data table.

Step 2. Authenticate & Select

  1. Add the credentials provided by the instructor to the Get API Key component to access the OpenAI API key.*

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

  3. Use the OpenAI LLM Selector to connect to the default model.


*If you want to use your own credentials, replace the Get API Key with a Credential Configuration node and provide your OpenAI API key in the password field.

Step 3. Prompt LLM & clean response

  1. Use the LLM Prompter node to send the prompt created in step 1 to the model.

  2. Use the String Cleaner node to clean the response column from leading and trailing whitespace.


Hint: Use the String Format Manager node to better display the output table by wrapping long strings in multiple lines.

Sentiment Analysis with GenAI

Workflow description: The dataset contains reviews of a product. Your task is to send each review to an LLM with the instruction to send back only the sentiment of the review.


You'll find the instructions to the exercises in the yellow annotations.

💡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!

Help - Expression nodes
String Cleaner
Application password
Credentials Configuration
Create prompt
Expression
Predict sentiment
LLM Prompter
Read reviews
Excel Reader
gpt-4o-mini
OpenAI LLM Selector
String Format Manager
OpenAI Authenticator

Nodes

Extensions

Links