Bmccloud22's picture
Deploy LaunchLLM - Production AI Training Platform
ec8f374 verified
"""
Domain Templates for AURA AI Training System
This module provides pre-configured domain templates for different AI assistant specializations:
- Financial Advisor: Wealth management, investing, retirement planning
- Medical Assistant: Health information, symptom understanding, wellness
- Legal Advisor: Legal information, document understanding, rights explanation
- Education Tutor: Academic subjects, test prep, homework help
- Custom Domain: User-defined domain specifications
Each domain provides:
- Topics for training data generation
- System prompts for model behavior
- Example questions for testing
- Specialized tools for function calling
"""
from .base_domain import BaseDomain
from .financial_advisor import FinancialAdvisorDomain
from .medical_assistant import MedicalAssistantDomain
from .legal_advisor import LegalAdvisorDomain
from .education_tutor import EducationTutorDomain
from .custom_domain import CustomDomain
# Domain registry
_DOMAIN_REGISTRY = {
'financial_advisor': FinancialAdvisorDomain,
'medical_assistant': MedicalAssistantDomain,
'legal_advisor': LegalAdvisorDomain,
'education_tutor': EducationTutorDomain,
'custom': CustomDomain
}
def get_domain(domain_key: str, **kwargs) -> BaseDomain:
"""
Get a domain instance by key.
Args:
domain_key: Domain identifier (financial_advisor, medical_assistant, etc.)
**kwargs: Additional arguments for domain initialization (used for custom domains)
Returns:
Domain instance
Raises:
ValueError: If domain_key is not recognized
Examples:
>>> domain = get_domain('financial_advisor')
>>> domain.name
'Financial Advisor'
>>> custom = get_domain('custom', name='Cooking Assistant', icon='πŸ‘¨β€πŸ³')
>>> custom.name
'Cooking Assistant'
"""
if domain_key not in _DOMAIN_REGISTRY:
raise ValueError(
f"Unknown domain: {domain_key}. "
f"Available domains: {', '.join(_DOMAIN_REGISTRY.keys())}"
)
domain_class = _DOMAIN_REGISTRY[domain_key]
# CustomDomain accepts kwargs, others don't
if domain_key == 'custom':
return domain_class(**kwargs)
else:
return domain_class()
def list_domains() -> dict:
"""
List all available domains with their basic information.
Returns:
Dictionary mapping domain keys to domain info dicts
Each info dict contains: name, description, icon
Example:
>>> domains = list_domains()
>>> domains['financial_advisor']['name']
'Financial Advisor'
"""
domains = {}
for key, domain_class in _DOMAIN_REGISTRY.items():
if key == 'custom':
# Custom domain needs special handling
domain = domain_class()
else:
domain = domain_class()
domains[key] = {
'key': key,
'name': domain.name,
'description': domain.description,
'icon': domain.icon
}
return domains
def register_domain(key: str, domain_class: type) -> None:
"""
Register a custom domain class.
Args:
key: Domain identifier
domain_class: Domain class (must inherit from BaseDomain)
Raises:
TypeError: If domain_class doesn't inherit from BaseDomain
ValueError: If key already exists
Example:
>>> class MyDomain(BaseDomain):
... pass
>>> register_domain('my_domain', MyDomain)
"""
if not issubclass(domain_class, BaseDomain):
raise TypeError(f"{domain_class} must inherit from BaseDomain")
if key in _DOMAIN_REGISTRY:
raise ValueError(f"Domain key '{key}' already registered")
_DOMAIN_REGISTRY[key] = domain_class
# Export all public classes and functions
__all__ = [
'BaseDomain',
'FinancialAdvisorDomain',
'MedicalAssistantDomain',
'LegalAdvisorDomain',
'EducationTutorDomain',
'CustomDomain',
'get_domain',
'list_domains',
'register_domain'
]