Pattern: customer-service pricing accuracy
Telecom — customer-service AI pricing-accuracy pattern. JSON-schema scorer, numeric exact-match, per-PR CI gating, continuous sampled trace eval.
Last updated
Was this helpful?
Was this helpful?
# Python (SDK) — CI-side gating evaluation
from layerlens import Stratix
client = Stratix()
schema_scorer = client.scorers.create(
name="pricing-citation",
type="json_schema_validate",
config={"schema": {
"type": "object",
"required": ["rate_card_row_id", "citation_ts"],
"properties": {
"rate_card_row_id": {"type": "string"},
"citation_ts": {"type": "string", "format": "date-time"},
},
}},
)
numeric_scorer = client.scorers.create_code(
name="price-exact-match",
code="result = abs(output['price'] - expected['rate_card_price']) < 0.01",
)
evaluation = client.evaluations.create(
name="cs-pricing-gate",
model_id=os.environ["MODEL_ID"],
dataset_id="pricing-regression-v1",
scorers=[schema_scorer.id, numeric_scorer.id],
)
result = client.evaluations.wait_for_completion(evaluation.id)
sys.exit(0 if result.pass_rate >= 0.995 else 1)// TypeScript (REST) — same gate from a Node CI runner
const r = await fetch("https://stratix.layerlens.ai/api/v1/evaluations", {
method: "POST",
headers: {
"X-API-Key": process.env.LAYERLENS_STRATIX_API_KEY!,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "cs-pricing-gate",
model_id: process.env.MODEL_ID,
dataset_id: "pricing-regression-v1",
scorers: [schemaScorerId, numericScorerId],
}),
});
const evaluation = await r.json();
// Poll evaluation.id until status === "completed"