Pattern: multilingual booking assistant
Travel / hospitality — multilingual booking-assistant pattern. Per-language booking-detail accuracy, cultural appropriateness, locale-aware date handling.
Last updated
Was this helpful?
Was this helpful?
# Python (SDK)
from layerlens import Stratix
client = Stratix()
booking_accuracy = client.scorers.create_code(
name="booking-detail-accuracy",
code="""
extracted = output['booking']
truth = expected['booking']
fields = ['check_in', 'check_out', 'guest_name', 'guests', 'room_type']
result = {'passed': all(extracted[f] == truth[f] for f in fields), 'date_format_ok': extracted['check_in'] == truth['check_in']}
""",
)
cross_language = client.scorers.create_code(
name="locale-parity",
code="""
en_acc = mean(s for t, s in zip(traces, scores) if t.tags['lang'] == 'en')
gaps = {l: en_acc - mean(s for t, s in zip(traces, scores) if t.tags['lang'] == l) for l in supported_langs}
result = {'passed': max(abs(g) for g in gaps.values()) <= 0.05, 'gaps': gaps}
""",
)
cultural = client.judges.create(
name="cultural-fit",
evaluation_goal="Score 1-5: is the response culturally appropriate for the locale, including tone, formality, and idiom?",
)
trace_eval = client.trace_evaluations.create(
trace_set={"tags": {"feature": "booking-assistant"}, "sample_rate": 0.01},
scorers=[booking_accuracy.id, cross_language.id],
judges=[cultural.id],
schedule="hourly",
)// 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: "booking-assistant" }, sample_rate: 0.01 },
scorers: [bookingAccuracyId, crossLanguageId],
judges: [culturalId],
schedule: "hourly",
}),
});