jevrecipes

Recipe catalog / continuation-compare

Compare two musical continuations

Which of firstContinuation and secondContinuation better follows the musical context in motif, contour, harmony, and any style supplied?

A generation loop has produced two candidate continuations for a passage and wants a head-to-head preference before committing to one.

Explore this recipe interactively ยท Source and implementation guide

Use continuation-compare 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 { continuationCompare } from 'jev-recipes/continuation-compare';

const result = await continuationCompare({
  "context": "G major, 4/4. Opening motif: G4 A4 B4 D5 | B4 A4 G4 (half). A rising line to the fifth answered by a stepwise descent home.",
  "firstContinuation": "D5 E5 F#5 A5 | F#5 E5 D5 (half). The motif transposed up a fifth, same rhythm, same rise-and-fall contour.",
  "secondContinuation": "C#4 (eighth) G#5 (eighth) Bb3 (quarter) rest | Eb5 (dotted half). Wide chromatic leaps in a new, jagged rhythm.",
  "style": "Celtic air, lyrical and unhurried",
  "minConfidence": 0.8
});
console.log(result);

Input contract

FieldTypeNeeded
contextstringRequired
firstContinuationstringRequired
secondContinuationstringRequired
stylestringOptional
minConfidencenumberOptional
Full input and result schemas
{
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "context": {
        "type": "string"
      },
      "firstContinuation": {
        "type": "string"
      },
      "secondContinuation": {
        "type": "string"
      },
      "style": {
        "type": "string"
      },
      "minConfidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      }
    },
    "required": [
      "context",
      "firstContinuation",
      "secondContinuation"
    ]
  },
  "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"
        ]
      },
      "verdict": {
        "type": "string",
        "enum": [
          "first",
          "second",
          "tie",
          "neither",
          "unclear"
        ]
      },
      "confidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      },
      "probabilities": {
        "type": "object",
        "propertyNames": {
          "type": "string",
          "enum": [
            "first",
            "second",
            "tie",
            "neither",
            "unclear"
          ]
        },
        "additionalProperties": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "required": [
          "first",
          "second",
          "tie",
          "neither",
          "unclear"
        ]
      }
    },
    "required": [
      "model",
      "usage",
      "status",
      "verdict",
      "confidence",
      "probabilities"
    ],
    "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 continuation-compare.

{
  "model": "demo-fixture",
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0
  },
  "status": "ready",
  "verdict": "first",
  "confidence": 0.91,
  "probabilities": {
    "first": 0.91,
    "second": 0.02,
    "tie": 0.02,
    "neither": 0.03,
    "unclear": 0.02
  }
}

Evaluation evidence

Fixture only

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

Related recipes