Recipe catalog / category-fit
Check an item against its category
category-fit is a Jev recipe from the jev-recipes TypeScript package. Does the product described by item belong under category as defined? Use it when you need to audit catalog placements or gate seller-submitted listings so items do not land in the wrong category.
Last updated .
Explore this recipe interactively · Source and implementation guide · Markdown version
How do I use category-fit 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 { categoryFit } from 'jev-recipes/category-fit';
const result = await categoryFit({
"item": "Replacement HEPA filter for the AirPure 300 series purifier. Two-pack, captures 99.97% of particles down to 0.3 microns. Compatible with models AP-300, AP-310, and AP-320.",
"category": "Air Purifiers: standalone air purifying appliances for home or office use. Excludes replacement filters, parts, and accessories, which belong under Air Purifier Accessories.",
"minConfidence": 0.8
});
console.log(result);
What input does category-fit take?
| Field | Type | Needed |
|---|---|---|
| item | string | Required |
| category | string | Required |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"item": {
"type": "string"
},
"category": {
"type": "string"
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"item",
"category"
]
},
"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": [
"fits",
"misfiled"
]
}
},
"required": [
"model",
"usage",
"status",
"probability",
"confidence",
"verdict"
],
"additionalProperties": false
}
}What does a category-fit 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 category-fit.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"probability": 0.04,
"confidence": 0.96,
"verdict": "misfiled"
}
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 fits when Jev's yes probability is at least 0.5 and misfiled otherwise. probability is that yes probability. confidence is the probability of the chosen side, so a 0.1 yes probability yields misfiled with 0.9 confidence.
A result is ready when confidence meets minConfidence. Otherwise it is review. Treat a review result as unknown and queue the item for a human check rather than moving it automatically.
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 recipe checks one item against one category definition. A misfiled verdict says the item does not belong there, not where it does belong; use route to choose among candidate categories. The judgment is only as sharp as the definition supplied in category, so include the inclusions and exclusions that matter, especially for accessories and parts. It reads the item description as given and cannot detect a description that misstates the product.
Example input
demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo category-fit shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe category-fit to inspect the input and result schemas.
How accurate is category-fit?
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 category-fit?
- Checks one item against one category definition. It does not say which category the item belongs in instead.
- The judgment depends on the supplied definition, so a vague category description yields vague results.
Which recipes are related to category-fit?
- document-role: Use document-role to classify what kind of document a text is rather than where a product belongs.
- route: Use route to pick the best category from several candidates instead of checking one.