mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com> Co-authored-by: openhands <openhands@all-hands.dev>
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
import os
|
|
|
|
from openhands.core.logger import openhands_logger as logger
|
|
from openhands.server.types import AppMode, ServerConfigInterface
|
|
from openhands.utils.import_utils import get_impl
|
|
|
|
|
|
class ServerConfig(ServerConfigInterface):
|
|
config_cls = os.environ.get('OPENHANDS_CONFIG_CLS', None)
|
|
app_mode = AppMode.OSS
|
|
posthog_client_key = 'phc_3ESMmY9SgqEAGBB6sMGK5ayYHkeUuknH2vP6FmWH9RA'
|
|
github_client_id = os.environ.get('GITHUB_APP_CLIENT_ID', '')
|
|
settings_store_class: str = (
|
|
'openhands.storage.settings.file_settings_store.FileSettingsStore'
|
|
)
|
|
conversation_store_class: str = (
|
|
'openhands.storage.conversation.file_conversation_store.FileConversationStore'
|
|
)
|
|
conversation_manager_class: str = 'openhands.server.conversation_manager.standalone_conversation_manager.StandaloneConversationManager'
|
|
|
|
github_service_class: str = 'openhands.services.github.github_service.GitHubService'
|
|
|
|
def verify_config(self):
|
|
if self.config_cls:
|
|
raise ValueError('Unexpected config path provided')
|
|
|
|
def get_config(self):
|
|
config = {
|
|
'APP_MODE': self.app_mode,
|
|
'GITHUB_CLIENT_ID': self.github_client_id,
|
|
'POSTHOG_CLIENT_KEY': self.posthog_client_key,
|
|
}
|
|
|
|
return config
|
|
|
|
|
|
def load_server_config():
|
|
config_cls = os.environ.get('OPENHANDS_CONFIG_CLS', None)
|
|
logger.info(f'Using config class {config_cls}')
|
|
|
|
server_config_cls = get_impl(ServerConfig, config_cls)
|
|
server_config = server_config_cls()
|
|
server_config.verify_config()
|
|
|
|
return server_config
|