Recipe catalog / phrase-complete
Check whether a phrase has closed
phrase-complete is a Jev recipe from the jev-recipes TypeScript package. Does recentNotes form a complete musical phrase that is ready to cadence or rest, or is it still open, given any meter supplied? Use it when 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.
Last updated .
Explore this recipe interactively · Source and implementation guide · Markdown version
How do I 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);
What input does phrase-complete take?
| 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
}
}What does a phrase-complete 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 phrase-complete.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"probability": 0.91,
"confidence": 0.91,
"verdict": "complete"
}
Input
See shared options and behavior for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas. meter is optional and is omitted from the request when absent.
Result
verdict is complete when Jev's yes probability is at least 0.5 and open otherwise. probability is that yes probability. confidence is the probability of the chosen side, so a 0.1 yes probability yields open with 0.9 confidence.
A result is ready when confidence meets minConfidence. Otherwise it is review. Treat a review result as unknown and fall back to your safe default.
Reuse and calls
Uses the shared gate helper, a single yes/no question. This folder owns the question wording, the outcome descriptions, and the review policy. A live invocation makes one logical Jev request.
Limits
The verdict is a judgment of closure from the written notes and annotations, not a theory check: which key the line is in, whether the last note is the tonic, and whether the final bar is full are exact questions for application code, which should state the answers in recentNotes when they matter. A complete phrase is ready to close, not obliged to; a generation loop can still choose to extend it, and an open phrase can still be cut off deliberately. Closure conventions differ by style, so a line that reads as open in a chorale can read as complete in a blues, and meter only helps when the text also shows where the bars fall.
Example input
demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo phrase-complete shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe phrase-complete to inspect the input and result schemas.
How accurate is phrase-complete?
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 phrase-complete?
- 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.
Which recipes are related to phrase-complete?
- 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.