Skip to content

Commit

Permalink
fix lm_provider_params prop to include fields
Browse files Browse the repository at this point in the history
  • Loading branch information
dlqqq committed Dec 2, 2024
1 parent d79c85c commit 41be9c3
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/jupyter-ai/jupyter_ai/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,16 +436,21 @@ def completions_lm_provider_params(self):
)

def _provider_params(self, key, listing):
# get generic fields
# read config
config = self._read_config()
gid = getattr(config, key)
if not gid:

# get model ID (without provider ID component) from model universal ID
# (with provider component).
model_uid = getattr(config, key)
if not model_uid:
return None
model_id = model_uid.split(":", 1)[1]

lid = gid.split(":", 1)[1]
# get config fields (e.g. base API URL, etc.)
fields = config.fields.get(model_uid, {})

# get authn fields
_, Provider = get_em_provider(gid, listing)
_, Provider = get_em_provider(model_uid, listing)
authn_fields = {}
if Provider.auth_strategy and Provider.auth_strategy.type == "env":
keyword_param = (
Expand All @@ -456,7 +461,8 @@ def _provider_params(self, key, listing):
authn_fields[keyword_param] = config.api_keys[key_name]

return {
"model_id": lid,
"model_id": model_id,
**fields,
**authn_fields,
}

Expand Down

0 comments on commit 41be9c3

Please sign in to comment.