From 3d5da61baa1eb3689de1ae3e3854c9ecf2375077 Mon Sep 17 00:00:00 2001 From: "David L. Qiu" Date: Mon, 12 Feb 2024 10:08:00 -0800 Subject: [PATCH] pre-commit --- .../{{cookiecutter.python_name}}/llm.py | 1 + .../{{cookiecutter.python_name}}/provider.py | 6 ++---- .../{{cookiecutter.python_name}}/slash_command.py | 4 +++- packages/jupyter-ai/jupyter_ai/__init__.py | 7 ++++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.root_dir_name}}/{{cookiecutter.python_name}}/llm.py b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.root_dir_name}}/{{cookiecutter.python_name}}/llm.py index ba8442902..7c33d5206 100644 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.root_dir_name}}/{{cookiecutter.python_name}}/llm.py +++ b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.root_dir_name}}/{{cookiecutter.python_name}}/llm.py @@ -3,6 +3,7 @@ from langchain_core.callbacks.manager import CallbackManagerForLLMRun from langchain_core.language_models.llms import LLM + class TestLLM(LLM): model_id: str diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.root_dir_name}}/{{cookiecutter.python_name}}/provider.py b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.root_dir_name}}/{{cookiecutter.python_name}}/provider.py index f2e71e7ca..c70ae388a 100644 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.root_dir_name}}/{{cookiecutter.python_name}}/provider.py +++ b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.root_dir_name}}/{{cookiecutter.python_name}}/provider.py @@ -1,4 +1,5 @@ from typing import ClassVar, List + from jupyter_ai import AuthStrategy, BaseProvider, Field from .llm import TestLLM @@ -40,9 +41,7 @@ class TestModelProvider(BaseProvider, ): name: ClassVar[str] = "Test Provider" """User-facing name of this provider.""" - models: ClassVar[List[str]] = [ - "test-model-1" - ] + models: ClassVar[List[str]] = ["test-model-1"] """List of supported models by their IDs. For registry providers, this will be just ["*"].""" @@ -69,4 +68,3 @@ class TestModelProvider(BaseProvider, ): fields: ClassVar[List[Field]] = [] """User inputs expected by this provider when initializing it. Each `Field` `f` should be passed in the constructor as a keyword argument, keyed by `f.key`.""" - diff --git a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.root_dir_name}}/{{cookiecutter.python_name}}/slash_command.py b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.root_dir_name}}/{{cookiecutter.python_name}}/slash_command.py index 876d21372..f82bd5531 100644 --- a/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.root_dir_name}}/{{cookiecutter.python_name}}/slash_command.py +++ b/packages/jupyter-ai-module-cookiecutter/{{cookiecutter.root_dir_name}}/{{cookiecutter.python_name}}/slash_command.py @@ -1,18 +1,20 @@ from jupyter_ai.chat_handlers.base import BaseChatHandler, SlashCommandRoutingType from jupyter_ai.models import HumanChatMessage + class TestSlashCommand(BaseChatHandler): """ A test slash command implementation that developers should build from. The string used to invoke this command is set by the `slash_id` keyword argument in the `routing_type` attribute. The command is mainly implemented in the `process_message()` method. See built-in implementations under - `jupyter_ai/handlers` for further reference. + `jupyter_ai/handlers` for further reference. The provider is made available to Jupyter AI by the entry point declared in `pyproject.toml`. If this class or parent module is renamed, make sure the update the entry point there as well. """ + id = "test" name = "Test" help = "A test slash command." diff --git a/packages/jupyter-ai/jupyter_ai/__init__.py b/packages/jupyter-ai/jupyter_ai/__init__.py index cfcdf8187..21df49b8f 100644 --- a/packages/jupyter-ai/jupyter_ai/__init__.py +++ b/packages/jupyter-ai/jupyter_ai/__init__.py @@ -1,6 +1,3 @@ -from ._version import __version__ -from .extension import AiExtension - # expose jupyter_ai_magics ipython extension # DO NOT REMOVE. from jupyter_ai_magics import load_ipython_extension, unload_ipython_extension @@ -9,6 +6,10 @@ # DO NOT REMOVE. from jupyter_ai_magics.providers import * +from ._version import __version__ +from .extension import AiExtension + + def _jupyter_labextension_paths(): return [{"src": "labextension", "dest": "@jupyter-ai/core"}]