from lyzr import Studio, PIIType, PIIAction, SecretsAction
from lyzr.image_models import DallE
studio = Studio(api_key="your-api-key")
# Create base agent
agent = studio.create_agent(
name="Full-Featured Bot",
provider="gpt-4o",
role="Enterprise assistant",
goal="Help with various tasks securely",
instructions="Be helpful while maintaining security"
)
# Add memory
agent = agent.add_memory(50)
# Add tools
def search_docs(query: str) -> str:
"""Search internal documentation"""
return f"Results for: {query}"
agent.add_tool(search_docs)
# Add context
company_ctx = studio.create_context(
name="company",
value="Acme Corp - Enterprise software"
)
agent = agent.add_context(company_ctx)
# Add RAI policy
policy = studio.create_rai_policy(
name="EnterprisePolicy",
description="Enterprise security",
toxicity_threshold=0.2,
secrets_detection=SecretsAction.BLOCK,
pii_detection={
PIIType.CREDIT_CARD: PIIAction.BLOCK,
PIIType.SSN: PIIAction.BLOCK
}
)
agent = agent.add_rai_policy(policy)
# Enable file and image output
agent = agent.enable_file_output()
agent = agent.set_image_model(DallE.DALL_E_3)
# Enable evaluation features
agent = agent.enable_reflection()
agent = agent.enable_bias_check()
# Add groundedness facts
agent = agent.add_groundedness_facts([
"Product launched in 2020",
"Over 1000 enterprise customers"
])
# Verify features
print(f"Memory: {agent.has_memory()}")
print(f"RAI: {agent.has_rai_policy()}")
print(f"File output: {agent.has_file_output()}")
print(f"Image output: {agent.has_image_output()}")
print(f"Reflection: {agent.has_reflection()}")
print(f"Bias check: {agent.has_bias_check()}")
print(f"Groundedness: {agent.has_groundedness()}")
# Use the fully-featured agent
response = agent.run("Create a product overview document")