diff --git a/addons/activeblue_ai/__init__.py b/addons/activeblue_ai/__init__.py index ac29b95..4da3869 100644 --- a/addons/activeblue_ai/__init__.py +++ b/addons/activeblue_ai/__init__.py @@ -3,6 +3,42 @@ import logging _logger = logging.getLogger(__name__) +DEFAULT_AGENTS = [ + ('master', 'Routing / orchestration'), + ('finance', 'Finance reporting and analysis'), + ('accounting', 'Accounting, journals, reconciliation'), + ('crm', 'CRM, leads, opportunities'), + ('sales', 'Sales orders, quotations, customers'), + ('project', 'Project management and tasks'), + ('elearning', 'eLearning courses and content'), + ('expenses', 'Expense reports and approvals'), + ('hr', 'Human Resources, employees, time off'), +] + + +def _ensure_default_bot_and_registry(env): + """Seed an active ab.ai.bot row and the default agent registry entries.""" + Bot = env['ab.ai.bot'] + if not Bot.search([], limit=1): + Bot.create({ + 'display_name': 'ActiveBlue AI', + 'agent_service_url': 'http://activeblue-agent:8001', + 'privacy_mode': 'local', + 'active': True, + }) + _logger.info('Seeded default ab.ai.bot row') + + Registry = env['ab.ai.agent.registry'] + for name, domain in DEFAULT_AGENTS: + if not Registry.search([('agent_name', '=', name)], limit=1): + Registry.create({ + 'agent_name': name, + 'domain': domain, + 'active': True, + 'backend': 'ollama', + }) + _logger.info('Ensured %d default agent registry entries', len(DEFAULT_AGENTS)) + def _ensure_ai_bot_user(env): """Create the ActiveBlue AI internal user so it appears in Discuss DM search. @@ -54,3 +90,5 @@ def _ensure_ai_bot_user(env): (user.id, user.id), ) _logger.info('Marked ActiveBlue AI bot user id=%d as confirmed', user.id) + + _ensure_default_bot_and_registry(env)