From 80b24b7e3f363a106ed533c7d7631629ca8b92f9 Mon Sep 17 00:00:00 2001 From: "David L. Qiu" Date: Mon, 9 Dec 2024 10:08:54 -0800 Subject: [PATCH] exclude empty str fields from config manager --- packages/jupyter-ai/jupyter_ai/config_manager.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/jupyter-ai/jupyter_ai/config_manager.py b/packages/jupyter-ai/jupyter_ai/config_manager.py index 7b309faae..b01cc122e 100644 --- a/packages/jupyter-ai/jupyter_ai/config_manager.py +++ b/packages/jupyter-ai/jupyter_ai/config_manager.py @@ -461,6 +461,13 @@ def _provider_params(self, key, listing, completions: bool = False): fields = config.completions_fields.get(model_uid, {}) else: fields = config.fields.get(model_uid, {}) + + # exclude empty fields + # TODO: modify the config manager to never save empty fields in the + # first place. + for field_key in fields: + if isinstance(fields[field_key], str) and not len(fields[field_key]): + fields[field_key] = None # get authn fields _, Provider = get_em_provider(model_uid, listing)