Files
Auto-GPT/scripts/config.py
Andres Caicedo eac5c1f6e6 Add documentation
2023-04-02 19:03:37 +02:00

34 lines
938 B
Python

class Singleton(type):
"""
Singleton metaclass for ensuring only one instance of a class.
"""
_instances = {}
def __call__(cls, *args, **kwargs):
"""Call method for the singleton metaclass."""
if cls not in cls._instances:
cls._instances[cls] = super(
Singleton, cls).__call__(
*args, **kwargs)
return cls._instances[cls]
class Config(metaclass=Singleton):
"""
Configuration class to store the state of bools for different scripts access.
"""
def __init__(self):
"""Initialize the configuration class."""
self.continuous_mode = False
self.speak_mode = False
def set_continuous_mode(self, value: bool):
"""Set the continuous mode value."""
self.continuous_mode = value
def set_speak_mode(self, value: bool):
"""Set the speak mode value."""
self.speak_mode = value