[Sentiment] Analyzer
The Sentiment analyzer
operation is a simple prompt request operation to the configured LLM. It uses a plain text prompt as input and responds with a sentiment for the input text. The sentiment value can be NEUTRAL
, POSITIVE
, or NEGATIVE
.
Input Fields
Module Configuration
This refers to the MuleSoft AI Chain LLM Configuration set up in the Getting Started section.
General Operation Field
- Prompt: Contains the prompt as plain text for the operation. This is the text which will be analyzed for its sentiment.
XML Configuration
Below is the XML configuration for this operation:
<ms-aichain:sentiment-analyze
doc:name="Sentiment analyze"
doc:id="cad4ef27-5c85-47f7-a68c-f666809b0846"
config-ref="MAC_AI_Llm_configuration"
data="#[payload.inputText]"
/>
Output Field for v0.2.0
This operation responds with a string
payload which needs to be converted into a json, this can be achieved with a Transform Message component with the following dataweave expression:
%dw 2.0
output application/json
---
read(payload,"application/json").
Output Field
This operation responds with a json
payload.
Example Output
This output has been converted to JSON.
{
"sentiment": "POSITIVE",
"tokenUsage": {
"outputCount": 2,
"totalCount": 111,
"inputCount": 109
},
"isPositive": true
}
- sentiment: The sentiment result for the query.
- isPositive: Boolean if the query or text was positive.
- tokenUsage
- outputCount: Token used to generate the output.
- totalCount: Total token used for input and output.
- inputCount: Token used to process the input.
Example Use Cases
This operation is particularly useful in scenarios where you need to analyze the sentiment of text, such as:
- Customer Feedback Analysis: Determining whether customer feedback is positive, negative, or neutral.
- Social Media Monitoring: Analyzing the sentiment of social media posts or comments to gauge public opinion.
- Market Research: Assessing the sentiment of survey responses or market research data.