Recipe catalog / repetition-level
Grade how repetitive recent material is
repetition-level is a Jev recipe from the jev-recipes TypeScript package. How repetitive is recentMaterial, from varied to stuck on one idea? Use it when a generation loop such as an infinite piano player should notice when it has fallen into a loop or frozen on one figure, so it can inject variation or change direction.
Last updated .
Explore this recipe interactively · Source and implementation guide · Markdown version
How do I use repetition-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 { repetitionLevel } from 'jev-recipes/repetition-level';
const result = await repetitionLevel({
"recentMaterial": "C4 E4 G4 E4 | C4 E4 G4 E4 | C4 E4 G4 E4 | C4 E4 G4 E4 | C4 E4 G4 E4 | C4 E4 G4 E4 (all quarter notes, same dynamic, no rests)",
"minConfidence": 0.8
});
console.log(result);
What input does repetition-level take?
| Field | Type | Needed |
|---|---|---|
| recentMaterial | string | Required |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"recentMaterial": {
"type": "string"
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"recentMaterial"
]
},
"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
}
},
"repetition": {
"type": "string",
"enum": [
"varied",
"some",
"repetitive",
"looping",
"stuck"
]
}
},
"required": [
"model",
"usage",
"status",
"score",
"level",
"confidence",
"probabilities",
"repetition"
],
"additionalProperties": false
}
}What does a repetition-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 repetition-level.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"score": 2.94,
"level": 3,
"confidence": 0.85,
"probabilities": {
"0": 0.01,
"1": 0.01,
"2": 0.07,
"3": 0.85,
"4": 0.06
},
"repetition": "looping"
}
Input
See shared options and behavior for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas.
Result
repetition is one of varied, some, repetitive, looping, stuck, 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 for ranking or thresholds where a single label loses information.
A result is ready when confidence meets minConfidence. Otherwise it is review and still carries the graded values for inspection. probabilities is keyed by level index.
Reuse and calls
Uses the shared score helper. This folder owns the question, the rubric wording, and the review policy. A live invocation makes one logical Jev request.
Limits
The grade is a judgment of repetition as written, not an exact pattern match: detecting a transposed, inverted, or augmented repeat, counting how many bars a figure has recurred, and checking whether a variation stays in the key are exact questions for application code, which should annotate recentMaterial when they matter. Repetition is a description, not a fault; an ostinato or a minimalist texture can be looping by design, so the threshold at which a generation loop should intervene belongs in application code. Only the material supplied is graded, so a caller that passes a short window will see less repetition than the full performance contains.
Example input
demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo repetition-level shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe repetition-level to inspect the input and result schemas.
How accurate is repetition-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 repetition-level?
- Grades repetition as written in the note names, rhythms, and annotations. It does not detect transpositions, inversions, or rhythmic augmentations exactly; describe them in the text when they matter.
- Repetition is not a fault in itself. Ostinatos, riffs, and minimalism repeat by design, so the threshold for intervening belongs in application code.
- Only the supplied material is graded; earlier material the caller left out does not count.
Which recipes are related to repetition-level?
- repeated-attempt: Use repeated-attempt to check whether one proposed attempt repeats a previous approach to a task, rather than grading the repetition across a stretch of music.
- progress-stall: Use progress-stall to detect an agent circling on a task objective, not a melody circling on one figure.