Recipe catalog / phrase-complete
Check whether a phrase has closed
Does recentNotes form a complete musical phrase that is ready to cadence or rest, or is it still open, given any meter supplied?
A generation loop needs to know whether the line it has produced can pause, cadence, or hand off to a new idea, or whether it should keep the phrase going.
Explore this recipe interactively ยท Source and implementation guide
Use phrase-complete 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 { phraseComplete } from 'jev-recipes/phrase-complete';
const result = await phraseComplete({
"recentNotes": "C major. E4 D4 C4 D4 | E4 E4 E4 (half) | D4 D4 E4 D4 | C4 (whole note, held)",
"meter": "4/4",
"minConfidence": 0.8
});
console.log(result);
Input contract
| Field | Type | Needed |
|---|---|---|
| recentNotes | string | Required |
| meter | string | Optional |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"recentNotes": {
"type": "string"
},
"meter": {
"type": "string"
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"recentNotes"
]
},
"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"
]
},
"probability": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"verdict": {
"type": "string",
"enum": [
"complete",
"open"
]
}
},
"required": [
"model",
"usage",
"status",
"probability",
"confidence",
"verdict"
],
"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 phrase-complete.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"probability": 0.91,
"confidence": 0.91,
"verdict": "complete"
}
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
- Judges closure from note names, rhythms, and any annotations in the text. It does not identify the key, compute scale degrees, or count beats; state the key and bar position in the text when they matter.
- A phrase can be heard as complete and still be musically better continued. The verdict reports readiness to close, not whether closing is the best choice.
- Phrase conventions vary by style; a blues line and a chorale close differently.
Related recipes
- step-complete: Use step-complete when supplied evidence must establish a stated completion condition, rather than judging musical closure from the notes themselves.
- resolution-check: Use resolution-check to detect whether a customer reports an issue as resolved, not whether a melody has come to rest.