Recipe catalog / listing-compare
Compare two listings for a request
Which of firstListing and secondListing better satisfies request?
You need a head-to-head preference between two product listings for a shopper request, for tie-breaking, recommendation evaluation, or ranker calibration.
Explore this recipe interactively ยท Source and implementation guide
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);
Input contract
| Field | Type | Needed |
|---|---|---|
| request | string | Required |
| firstListing | string | Required |
| secondListing | string | Required |
| minConfidence | number | Optional |
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
}
}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 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
}
}
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
- Compares two listings only. Order is declared irrelevant, but run both orders when calibrating.
- Judges fit to the request from listing text alone, not price competitiveness, stock, or seller reputation unless the request asks about them.
Related recipes
- passage-compare: Use passage-compare for the same pairwise judgment over text passages and a question.
- rerank: Use rerank to score many listings independently against one request.