Pattern: citizen-services chatbot
Government / public sector — citizen-services chatbot pattern. Policy accuracy against versioned source-of-truth, plain-language reading-level, multilingual parity.
Last updated
Was this helpful?
Was this helpful?
# Python (SDK)
from layerlens import Stratix
client = Stratix()
policy_hash = client.scorers.create_code(
name="policy-document-hash",
code="""
cited = output.get('policy_version_hash')
active = policy_registry.active_hash(output['program'])
result = {'passed': cited == active, 'cited': cited, 'active': active}
""",
)
reading_level = client.scorers.create_code(
name="reading-level",
code="result = {'passed': flesch_kincaid_grade(output['text']) <= 8}",
)
faithfulness = client.judges.create(
name="policy-faithfulness",
evaluation_goal="Eligibility and procedure claims must be grounded in the cited policy section.",
)
trace_eval = client.trace_evaluations.create(
trace_set={"tags": {"feature": "citizen-chatbot"}},
scorers=[policy_hash.id, reading_level.id],
judges=[faithfulness.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: "citizen-chatbot" } },
scorers: [policyHashId, readingLevelId],
judges: [faithfulnessId],
schedule: "hourly",
}),
});