-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
service.py
29 lines (22 loc) · 916 Bytes
/
service.py
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
from langflow.services.base import Service
from langflow.services.settings.auth import AuthSettings
from langflow.services.settings.base import Settings
class SettingsService(Service):
name = "settings_service"
def __init__(self, settings: Settings, auth_settings: AuthSettings):
super().__init__()
self.settings: Settings = settings
self.auth_settings: AuthSettings = auth_settings
@classmethod
def initialize(cls) -> "SettingsService":
# Check if a string is a valid path or a file name
settings = Settings()
if not settings.config_dir:
raise ValueError("CONFIG_DIR must be set in settings")
auth_settings = AuthSettings(
CONFIG_DIR=settings.config_dir,
)
return cls(settings, auth_settings)
def set(self, key, value):
setattr(self.settings, key, value)
return self.settings