Recipe catalog / repetition-level
Grade how repetitive recent material is
How repetitive is recentMaterial, from varied to stuck on one idea?
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.
Explore this recipe interactively ยท Source and implementation guide
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);
Input contract
| 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
}
}Saved example result
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"
}
Evaluation evidence
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.
Limitations
- 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.
Related recipes
- 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.