Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates docs with reset, model lists #254

Merged
merged 14 commits into from
Jul 10, 2023
Merged
Prev Previous commit
Next Next commit
Adds provision for provider to have help when no model list exists
  • Loading branch information
JasonWeill authored and dlqqq committed Jul 10, 2023
commit 0eae4c81b8ab9cec991bdfb3efe7a4b2e981c04f
10 changes: 8 additions & 2 deletions packages/jupyter-ai-magics/jupyter_ai_magics/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ def __init__(self, shell):
def _ai_bulleted_list_models_for_provider(self, provider_id, Provider):
output = ""
if len(Provider.models) == 1 and Provider.models[0] == "*":
output += f"* {PROVIDER_NO_MODELS}\n"
if Provider.model_help is None:
output += f"* {PROVIDER_NO_MODELS}\n"
else:
output += f"* {Provider.model_help}\n"
else:
for model_id in Provider.models:
output += f"* {provider_id}:{model_id}\n"
Expand All @@ -158,7 +161,10 @@ def _ai_inline_list_models_for_provider(self, provider_id, Provider):
output = ""

if len(Provider.models) == 1 and Provider.models[0] == "*":
return PROVIDER_NO_MODELS
if Provider.model_help is None:
return PROVIDER_NO_MODELS
else:
return Provider.model_help

for model_id in Provider.models:
output += f", `{provider_id}:{model_id}`"
Expand Down
12 changes: 12 additions & 0 deletions packages/jupyter-ai-magics/jupyter_ai_magics/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ class Config:
"""List of supported models by their IDs. For registry providers, this will
be just ["*"]."""

model_help: ClassVar[str] = None
"""Text to display in lieu of a model list for a registry provider that does
not provide a list of models."""

model_id_key: ClassVar[str] = ...
"""Kwarg expected by the upstream LangChain provider."""

Expand Down Expand Up @@ -177,6 +181,7 @@ class HfHubProvider(BaseProvider, HuggingFaceHub):
name = "Hugging Face Hub"
models = ["*"]
model_id_key = "repo_id"
model_help = "See https://huggingface.co/models for a list of models."
JasonWeill marked this conversation as resolved.
Show resolved Hide resolved
# ipywidgets needed to suppress tqdm warning
# https://stackoverflow.com/questions/67998191
# tqdm is a dependency of huggingface_hub
Expand Down Expand Up @@ -365,6 +370,13 @@ class SmEndpointProvider(BaseProvider, SagemakerEndpoint):
name = "Sagemaker Endpoint"
models = ["*"]
model_id_key = "endpoint_name"
# This all needs to be on one line of markdown, for use in a table
model_help = ("SageMaker endpoint names are created when you deploy a model. "
"For more information, see "
'["Create your endpoint and deploy your model"]'
'(https://docs.aws.amazon.com/sagemaker/latest/dg/realtime-endpoints-deployment.html)'
"in the SageMaker documentation.")

pypi_package_deps = ["boto3"]
auth_strategy = AwsAuthStrategy()
registry = True
Expand Down