From 0143c604540bd82d7c23c29b878b8700f81da1c0 Mon Sep 17 00:00:00 2001 From: amanape <83104063+amanape@users.noreply.github.com> Date: Tue, 31 Dec 2024 20:34:45 +0400 Subject: [PATCH] Bring back merge logic --- openhands/server/routes/settings.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/openhands/server/routes/settings.py b/openhands/server/routes/settings.py index b96aec1dc5c6..7879f6128b26 100644 --- a/openhands/server/routes/settings.py +++ b/openhands/server/routes/settings.py @@ -54,7 +54,17 @@ async def store_settings( github_token = request.state.github_token try: settings_store = await SettingsStoreImpl.get_instance(config, github_token) + existing_settings = await settings_store.load() + + if existing_settings: + # Only update settings that are not None with the new values + for key, value in settings.__dict__.items(): + if value is None: + setattr(settings, key, getattr(existing_settings, key)) + if settings.llm_api_key is None: + settings.llm_api_key = existing_settings.llm_api_key await settings_store.store(settings) + return JSONResponse( status_code=status.HTTP_200_OK, content={'message': 'Settings stored'},