Pattern: product description generation
Retail / e-commerce — product-description generation pattern. Specification accuracy, brand voice, return-rate impact.
Last updated
Was this helpful?
Was this helpful?
# Python (SDK)
from layerlens import Stratix
client = Stratix()
spec_scorer = client.scorers.create_code(
name="spec-accuracy",
code="""
claimed = extract_specs(output)
truth = catalog.get(input['sku']).specs
result = {'passed': all(claimed.get(k) == v for k, v in truth.items()), 'mismatches': diff(claimed, truth)}
""",
)
brand_voice = client.judges.create(
name="brand-voice",
evaluation_goal="Score brand-voice consistency on a 1-5 scale. Voice should match the brand guidelines for category {category}.",
)
trace_eval = client.trace_evaluations.create(
trace_set={"tags": {"feature": "product-description"}, "sample_rate": 0.01},
scorers=[spec_scorer.id],
judges=[brand_voice.id],
schedule="daily",
)// TypeScript (REST)
const r = await fetch("https://stratix.layerlens.ai/api/v1/trace-evaluations", {
method: "POST",
headers: {
"X-API-Key": process.env.LAYERLENS_STRATIX_API_KEY!,
"Content-Type": "application/json",
},
body: JSON.stringify({
trace_set: { tags: { feature: "product-description" }, sample_rate: 0.01 },
scorers: [specScorerId],
judges: [brandVoiceId],
schedule: "daily",
}),
});