Skip to content

Commit

Permalink
Alias list in text display, updates messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonWeill committed May 9, 2023
1 parent 67c484d commit 66809b3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/jupyter-ai-magics/jupyter_ai_magics/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ def _safely_set_target(self, register_name, target):
else:
# Ensure that the destination is properly formatted
if (':' not in target):
raise ValueError('Target model was not specified in PROVIDER_ID:MODEL_NAME format')
raise ValueError(
'Target model must be an LLMChain object or a model name in PROVIDER_ID:MODEL_NAME format')

self.custom_model_registry[register_name] = target

Expand Down Expand Up @@ -310,7 +311,7 @@ def _ai_list_command_markdown(self, single_provider=None):
if isinstance(value, str):
output += f"`{value}`"
else:
output += "*(custom chain)*"
output += "*custom chain*"

output += " |\n"

Expand All @@ -329,6 +330,18 @@ def _ai_list_command_text(self, single_provider=None):
+ self._ai_env_status_for_provider_text(provider_id) # includes \n if nonblank
+ self._ai_bulleted_list_models_for_provider(provider_id, Provider))

# Also list aliases.
if (single_provider is None and len(self.custom_model_registry) > 0):
output += "\nAliases and custom commands:\n"
for key, value in self.custom_model_registry.items():
output += f"{key} - "
if isinstance(value, str):
output += value
else:
output += "custom chain"

output += "\n"

return output

# Run an AI command using the arguments provided as a space-delimited value
Expand Down

0 comments on commit 66809b3

Please sign in to comment.