sentiment-analysis
Published
Public
in @structured-extraction

Classify the overall sentiment of text (positive / negative / neutral / mixed) with a rationale and confidence score. Strict JSON output.

sentiment-analysis

Classify the overall sentiment of a piece of text — positive, negative, neutral, or mixed — and get back a strict JSON object with a one-line rationale and a confidence score.

Built for product reviews, support messages, social posts, survey free-text, and any place you need a fast, structured read on tone.

Entrypoints

EntrypointRendersInputs
systemThe classifier instructions + embedded output schema
userThe delimited text block to analyzetext (string)

Render system as the system message and user as the user message.

Variables

  • text (string, required) — the text to analyze. A sentence to a few paragraphs works best.

Output

parseOutput() returns:

{
  "rationale": "Praises the battery life and screen with no complaints.",
  "sentiment": "positive",
  "confidence": 0.94
}
  • rationale comes before sentiment by design. Models that emit the label first tend to rationalize it after the fact; reasoning-first measurably improves accuracy. The system prompt pins this key order.
  • sentiment is one of positive / negative / neutral / mixed. mixed is reserved for genuinely contrasting sentiment of similar weight — not mostly-positive text with a minor caveat.
  • confidence is the model's self-reported certainty. ⚠️ LLM confidence is not calibrated — treat it as a rough signal for routing/triage, not a probability.

House conventions

  • Triple-mustache input ({{{text}}}) so &, <, " in user text are never HTML-escaped.
  • Grounded only in the input — the prompt forbids inferring sentiment from outside knowledge of the entities mentioned.
  • Empty / garbage input → classified neutral with low confidence (specified, not left to chance).
  • Strict schemaadditionalProperties: false, closed enum, confidence bounded 0–1.

Notes

Verified by local render against realistic input. Suggested default model claude-sonnet-4-6 at temperature: 0 (carried in version metadata — override per call as you like).

@sufleur/