# Upsonic Docs: Add a Safety Engine
# https://docs.upsonic.ai/guides/3-add-a-safety-engine
# Imports
from upsonic import Agent, Task
from upsonic.safety_engine import CryptoBlockPolicy, AnonymizePhoneNumbersPolicy, SensitiveSocialBlockPolicy
# Banking Assistant with Multiple Safety Policies
banking_assistant = Agent(
model="openai/gpt-5-mini",
name="Banking Assistant V1",
role="Certified banking assistant providing financial guidance",
goal="Help customers with banking services while maintaining regulatory compliance and data protection",
instructions="""
You are a banking assistant. Provide information about traditional banking products
like savings accounts, checking accounts, loans, and investment products.
Always comply with banking regulations and protect customer privacy.
""",
user_policy=CryptoBlockPolicy, # Block cryptocurrency content per banking regulations
)
# Test Task with Crypto Content (Should be Blocked)
crypto_task = Task(
description="I want to invest in Bitcoin and Ethereum through my bank account. Can you help me set up crypto trading?",
)
# Test Task with Safe Banking Content (Should Pass)
safe_task = Task(
description="I'm 25 years old and want to open a high-yield savings account. What are the best options available?",
)
# Run the tasks
print("=== Testing Crypto Content (Should be Blocked) ===")
banking_assistant.print_do(crypto_task)
print("\n=== Testing Safe Banking Content (Should Pass) ===")
banking_assistant.print_do(safe_task)
print("Crypto Task Result:", crypto_task.response)
print("Safe Task Result:", safe_task.response[:100] + "...")