Spaces:
Runtime error
Runtime error
File size: 4,051 Bytes
ec8f374 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
"""
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'
]
|