jevrecipes

Recipe catalog / listing-compare

Compare two listings for a request

listing-compare is a Jev recipe from the jev-recipes TypeScript package. Which of firstListing and secondListing better satisfies request? Use it when you need a head-to-head preference between two product listings for a shopper request, for tie-breaking, recommendation evaluation, or ranker calibration.

Last updated .

Explore this recipe interactively · Source and implementation guide · Markdown version

How do I use listing-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 { listingCompare } from 'jev-recipes/listing-compare';

const result = await listingCompare({
  "request": "Wireless over-ear headphones with active noise cancelling and at least 30 hours of battery. Must fold flat for travel.",
  "firstListing": "AeroSound X3 over-ear wireless headphones. Hybrid active noise cancelling, 40-hour battery, foldable design with travel case. Bluetooth 5.3.",
  "secondListing": "PulseBeat Studio wired over-ear headphones. Passive noise isolation, detachable 3 m cable, rigid headband. Studio-grade 50 mm drivers.",
  "minConfidence": 0.8
});
console.log(result);

What input does listing-compare take?

FieldTypeNeeded
requeststringRequired
firstListingstringRequired
secondListingstringRequired
minConfidencenumberOptional
Full input and result schemas
{
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "request": {
        "type": "string"
      },
      "firstListing": {
        "type": "string"
      },
      "secondListing": {
        "type": "string"
      },
      "minConfidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      }
    },
    "required": [
      "request",
      "firstListing",
      "secondListing"
    ]
  },
  "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
  }
}

What does a listing-compare 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 listing-compare.

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

Input

See shared options and behavior for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas.

Result

verdict is first, second, tie, neither, or unclear. first and second name the listing that better satisfies the request. tie means both fit about equally. neither means no listing describes a product that satisfies the request, which is a confident answer rather than a failure.

A result is ready when confidence meets minConfidence and the verdict is not unclear. probabilities covers all five outcomes.

Reuse and calls

Uses the shared comparison helper, which fixes the five outcomes and tells Jev that presentation order is irrelevant. This folder owns the question wording and the four outcome descriptions. A live invocation makes one logical Jev request.

Limits

The recipe compares exactly two listings. For many candidates, use rerank or run pairwise comparisons in application code. It judges how well each described product fits the request, weighing must-have attributes before preferences, and does not consider price, stock, or seller reputation unless the request mentions them. It cannot verify that a listing's claims are true. When building evaluation data, run each pair in both orders and keep only agreeing results.

Example input

demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo listing-compare shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe listing-compare to inspect the input and result schemas.

How accurate is listing-compare?

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.

What are the limits of listing-compare?