AI Agent
import logging
from gunicorn.app.base import BaseApplication
from app_init import create_initialized_flask_app
# Flask app creation should be done by create_initialized_flask_app to avoid circular dependency problems.
app = create_initialized_flask_app()
# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
class StandaloneApplication(BaseApplication):
def __init__(self, app, options=None):
self.application = app
self.options = options or {}
super().__init__()
def load_config(self):
# Apply configuration to Gunicorn
for key, value in self.options.items():
if key in self.cfg.settings and value is not None:
self.cfg.set(key.lower(), value)
def load(self):
Frequently Asked Questions
Per-domain pricing for enterprise customers Q3: What makes the AI Agent template different from using raw API access to AI models?
The AI Agent template provides several advantages over direct API usage: - Built-in team collaboration features - Visual interface for non-technical users - Real-time testing environment - Domain-based access control - Response temperature adjustment - Centralized instruction management This makes it much more suitable for business environments where multiple stakeholders need to influence the AI's behavior.
Q4: How can I modify the AI Agent template to add custom response validation? A: You can add validation by modifying the chat route in routes.py. Here's an example:
```python @app.route("/api/chat", methods=["POST"]) def chat(): try: # Existing code...
# Add custom validation
def validate_response(response):
forbidden_words = ['inappropriate', 'offensive']
contains_forbidden = any(word in response.lower() for word in forbidden_words)
if contains_forbidden:
return False, "Response contains forbidden content"
return True, None
is_valid, error = validate_response(ai_response)
if not is_valid:
return jsonify({"error": error}), 400
# Continue with existing code...
```
Q5: How can I extend the AI Agent template to support multiple instruction sets for different use cases? A: You can modify the ChatbotSettings model and add instruction set management. Here's an example:
```python
In models.py
class InstructionSet(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), nullable=False) instructions = db.Column(db.Text, nullable=False)
class ChatbotSettings(db.Model): id = db.Column(db.Integer, primary_key=True) instruction_set_id = db.Column(db.Integer, db.ForeignKey('instruction_set.id')) model_selection = db.Column(db.String(50), default="gpt-4o") temperature = db.Column(db.Float, default=0.7)
@property
def active_instructions(self):
instruction_set = InstructionSet.query.get(self.instruction_set_id)
return instruction_set.instructions if instruction_set else ""
```
This allows you to maintain multiple instruction sets and switch between them as needed.
Created: | Last Updated:
Here's a step-by-step guide for using the AI Agent template:
Introduction
The AI Agent template provides a customizable AI chatbot with a team management dashboard. You can configure the AI's behavior through custom instructions, choose different AI models (GPT-4, Claude, Gemini), and adjust response creativity. The template includes user management features to control access through email domains or individual permissions.
Getting Started
- Click "Start with this Template" to begin using the AI Agent template
Test the Application
- Click the "Test" button to deploy your AI Agent
- Lazy will provide you with a server link to access your AI Agent dashboard
Using the Dashboard
Configure AI Settings
- Navigate to the Dashboard tab
- Customize the AI's behavior:
- Enter custom instructions in the "Chatbot Instructions" field
- Select an AI model from the dropdown (GPT-4, Claude, Gemini options)
- Adjust the temperature slider to control response creativity (0-2)
- Click "Save Changes" to update settings
Manage Team Access
- Go to the Team tab to control who can access the agent
- Add individual admin access:
- Click "Add New Admin"
- Enter the admin's email address
- Add domain-wide access:
- Click "Add New Email Ending"
- Enter the domain (e.g., "company.com")
- Manage existing access:
- Block/unblock individual admins
- Remove domain access
- Delete individual admin access
Test the AI Agent
- Navigate to the AI Chat tab
- Enter messages in the chat interface to test your configuration
- View the AI's responses based on your settings
- Clear chat history using the "Clear This Chat" button
The dashboard provides real-time testing of your AI agent's behavior based on the configured settings. You can iteratively adjust the instructions, model selection, and temperature to achieve the desired interaction style for your use case.
Template Benefits
-
Customizable AI Response Control
Organizations can fine-tune their AI agent's behavior through specific instructions, model selection, and temperature settings, ensuring responses align with their brand voice and communication standards. -
Enterprise-Grade Access Management
Built-in team management features allow organizations to control access at both domain and individual levels, making it ideal for companies that need to manage multiple departments or client accounts with different permission levels. -
Real-Time Testing Environment
The integrated simulator enables teams to test and validate AI responses before deployment, reducing the risk of inappropriate or incorrect responses in production environments. -
Multi-Model Flexibility
Support for multiple AI models (GPT-4, Claude, Gemini) allows organizations to optimize for different use cases, balancing factors like cost, speed, and capability based on specific needs. -
Scalable Foundation for AI Integration
Serves as a robust starting point for building custom AI solutions, whether for email automation, customer service, or internal tools, saving significant development time and resources.
Technologies





