CoolFace
Apppublic

Backup-bdg/OpenHands

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
0likes
server_config.py60 linesDownload Raw Back to config
1import os2 3from openhands.core.logger import openhands_logger as logger4from openhands.server.types import AppMode, ServerConfigInterface5from openhands.utils.import_utils import get_impl6 7 8class ServerConfig(ServerConfigInterface):9    config_cls = os.environ.get('OPENHANDS_CONFIG_CLS', None)10    app_mode = AppMode.OSS11    posthog_client_key = 'phc_3ESMmY9SgqEAGBB6sMGK5ayYHkeUuknH2vP6FmWH9RA'12    github_client_id = os.environ.get('GITHUB_APP_CLIENT_ID', '')13    enable_billing = os.environ.get('ENABLE_BILLING', 'false') == 'true'14    hide_llm_settings = os.environ.get('HIDE_LLM_SETTINGS', 'false') == 'true'15    settings_store_class: str = (16        'openhands.storage.settings.file_settings_store.FileSettingsStore'17    )18    secret_store_class: str = (19        'openhands.storage.secrets.file_secrets_store.FileSecretsStore'20    )21    conversation_store_class: str = (22        'openhands.storage.conversation.file_conversation_store.FileConversationStore'23    )24    conversation_manager_class: str = os.environ.get(25        'CONVERSATION_MANAGER_CLASS',26        'openhands.server.conversation_manager.standalone_conversation_manager.StandaloneConversationManager',27    )28    monitoring_listener_class: str = 'openhands.server.monitoring.MonitoringListener'29    user_auth_class: str = (30        'openhands.server.user_auth.default_user_auth.DefaultUserAuth'31    )32 33    def verify_config(self):34        if self.config_cls:35            raise ValueError('Unexpected config path provided')36 37    def get_config(self):38        config = {39            'APP_MODE': self.app_mode,40            'GITHUB_CLIENT_ID': self.github_client_id,41            'POSTHOG_CLIENT_KEY': self.posthog_client_key,42            'FEATURE_FLAGS': {43                'ENABLE_BILLING': self.enable_billing,44                'HIDE_LLM_SETTINGS': self.hide_llm_settings,45            },46        }47 48        return config49 50 51def load_server_config() -> ServerConfig:52    config_cls = os.environ.get('OPENHANDS_CONFIG_CLS', None)53    logger.info(f'Using config class {config_cls}')54 55    server_config_cls = get_impl(ServerConfig, config_cls)56    server_config : ServerConfig = server_config_cls()57    server_config.verify_config()58 59    return server_config60