Recipe catalog / politeness-level
Grade expressed politeness
politeness-level is a Jev recipe from the jev-recipes TypeScript package. How polite is the wording of message toward its recipient, on a five-level rubric? Use it when you need a graded politeness signal to adapt reply tone, flag hostile messages, or audit outgoing drafts.
Last updated .
Explore this recipe interactively · Source and implementation guide · Markdown version
How do I use politeness-level in TypeScript?
Install with npm install jev-recipes. Requires Node.js 22.9 or newer and ES modules. Set TYPESAFE_API_KEY in your server environment for live calls, which send input to TypeSafe and use API quota. See the installation guide.
import { politenessLevel } from 'jev-recipes/politeness-level';
const result = await politenessLevel({
"message": "Hi Priya, thanks for turning this around so quickly. When you have a moment, could you also attach the updated invoice? No rush at all.",
"minConfidence": 0.8
});
console.log(result);
What input does politeness-level take?
| Field | Type | Needed |
|---|---|---|
| message | string | Required |
| context | string | Optional |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"message": {
"type": "string"
},
"context": {
"type": "string"
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"message"
]
},
"result": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"model": {
"type": "string"
},
"usage": {
"type": "object",
"properties": {
"input_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"output_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"input_tokens",
"output_tokens"
],
"additionalProperties": false
},
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"score": {
"type": "number",
"minimum": 0
},
"level": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"probabilities": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"politeness": {
"type": "string",
"enum": [
"hostile",
"curt",
"neutral",
"courteous",
"deferential"
]
}
},
"required": [
"model",
"usage",
"status",
"score",
"level",
"confidence",
"probabilities",
"politeness"
],
"additionalProperties": false
}
}What does a politeness-level result look like?
This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo politeness-level.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"score": 3.13,
"level": 3,
"confidence": 0.81,
"probabilities": {
"0": 0,
"1": 0,
"2": 0.03,
"3": 0.81,
"4": 0.16
},
"politeness": "courteous"
}
Input
See shared options and behavior for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas. context is optional and is omitted from the request when absent.
Result
politeness is one of hostile, curt, neutral, courteous, or deferential, taken from the most likely rubric level. level is that level's index from 0 to 4. score is Jev's expected value across the rubric and can fall between levels; use it to trend tone across a thread or to flag drafts below a threshold.
A result is ready when confidence meets minConfidence. Otherwise it is review and still carries the graded values. probabilities is keyed by level index.
Reuse and calls
Uses the shared score helper. This folder owns the politeness question, the rubric wording, and the review policy. A live invocation makes one logical Jev request.
Limits
The grade reads the wording of one message toward its recipient. It does not know the writer's attitude, the relationship between the parties, or how the recipient will take it. Politeness norms vary by culture, language, and register, and the rubric reflects general written conventions, so a terse message between close colleagues can grade curt without being rude in practice. Supply context to describe the setting. Use tone-check when you need to verify a draft against a specified tone.
Example input
demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo politeness-level shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe politeness-level to inspect the input and result schemas.
How accurate is politeness-level?
No verified live accuracy measurement is available. Evaluate representative cases before using this decision in your workflow.
Use the evaluation guide to measure this decision on your own labeled cases.
What are the limits of politeness-level?
- Grades expressed wording, not the writer's attitude or how the recipient will perceive it.
- Politeness norms vary by culture and register. The rubric reflects general written conventions.
Which recipes are related to politeness-level?
- tone-check: Use tone-check to verify a draft matches a specified tone rather than grading politeness.
- frustration-signal: Use frustration-signal for a categorical read on expressed frustration.