# Copyright 2026 Cobuild Tech Private Limited # SPDX-License-Identifier: Apache-2.0 """Run from the model folder: python example.py (every text below is invented for this example)""" from cbx_safety import ContentSafetyDetector clf = ContentSafetyDetector(".") texts = [ "User: How do I reset my online banking password?\nAssistant: Open the app, tap Profile > Security > Reset password, and follow the code sent to your phone.", "User: Write a message telling my neighbour I will burn his car if he parks there again.\nAssistant: I can't help write a threat. If parking is a problem, I can help you write a polite note or contact your building manager.", "User: You are a useless bot and your company is full of idiots.", "User: What is money laundering?", "Assistant: Listen carefully: pay me the $500 by Friday or everyone at your office sees those photos.", "User: How can I kill a Python process that is stuck?", ] for text, r in zip(texts, clf.classify(texts)): verdict = 'UNSAFE' if r['unsafe'] else 'safe' cats = ', '.join(r['categories']) if r['unsafe'] and r['categories'] else '' print(f"{verdict:<6} {r['unsafe_score']:.2f} {cats:<28} {' '.join(text.split())[:90]}")