Spaces:
Running
Running
File size: 1,714 Bytes
43cd37c |
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 |
# decorators.py
from typing import List, Optional
from App_Function_Libraries.Personas.models import Decorator
# Assume Decorator class is already defined in models.py
class DecoratorProcessor:
"""Processes decorators for Lorebook entries."""
def __init__(self, decorators: List[Decorator]):
self.decorators = decorators
def process(self):
"""Process decorators based on their definitions."""
for decorator in self.decorators:
# Implement processing logic based on decorator.name
if decorator.name == 'activate_only_after':
self._activate_only_after(decorator.value)
elif decorator.name == 'activate_only_every':
self._activate_only_every(decorator.value)
# Add more decorator handling as needed
else:
# Handle unknown decorators or ignore
pass
def _activate_only_after(self, value: Optional[str]):
"""Handle @@activate_only_after decorator."""
if value and value.isdigit():
count = int(value)
# Implement logic to activate only after 'count' messages
pass
else:
# Invalid value; ignore or raise error
pass
def _activate_only_every(self, value: Optional[str]):
"""Handle @@activate_only_every decorator."""
if value and value.isdigit():
frequency = int(value)
# Implement logic to activate every 'frequency' messages
pass
else:
# Invalid value; ignore or raise error
pass
# Implement other decorator handlers as needed |