Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and dlqqq committed Sep 16, 2024
1 parent 037e6be commit 49779f1
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 41 deletions.
2 changes: 1 addition & 1 deletion packages/jupyter-ai/jupyter_ai/chat_handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
from langchain.pydantic_v1 import BaseModel

if TYPE_CHECKING:
from jupyter_ai.context_providers import BaseContextProvider
from jupyter_ai.handlers import RootChatHandler
from jupyter_ai.history import BoundedChatHistory
from jupyter_ai.context_providers import BaseContextProvider
from langchain_core.chat_history import BaseChatMessageHistory


Expand Down
2 changes: 1 addition & 1 deletion packages/jupyter-ai/jupyter_ai/chat_handlers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from langchain_core.runnables import ConfigurableFieldSpec
from langchain_core.runnables.history import RunnableWithMessageHistory

from ..models import HumanChatMessage
from ..context_providers import ContextProviderException
from ..models import HumanChatMessage
from .base import BaseChatHandler, SlashCommandRoutingType


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .base import (
BaseContextProvider,
BaseCommandContextProvider,
BaseContextProvider,
ContextProviderException,
)
from .file import FileContextProvider
Expand Down
8 changes: 3 additions & 5 deletions packages/jupyter-ai/jupyter_ai/context_providers/_examples.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# This file is for illustrative purposes
# It is to be deleted before merging
from jupyter_ai.models import HumanChatMessage
from langchain_community.retrievers import WikipediaRetriever
from langchain_community.retrievers import ArxivRetriever
from langchain_core.prompts import ChatPromptTemplate
from langchain_community.retrievers import ArxivRetriever, WikipediaRetriever
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate

from .base import BaseContextProvider, BaseCommandContextProvider

from .base import BaseCommandContextProvider, BaseContextProvider

# Examples of the ease of implementing retriever based context providers
ARXIV_TEMPLATE = """
Expand Down
23 changes: 5 additions & 18 deletions packages/jupyter-ai/jupyter_ai/context_providers/base.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
import abc
import re
from typing import ClassVar, List

import os
from typing import (
TYPE_CHECKING,
Awaitable,
ClassVar,
Dict,
List,
Optional,
)
import re
from typing import TYPE_CHECKING, Awaitable, ClassVar, Dict, List, Optional

from dask.distributed import Client as DaskClient
from jupyter_ai.config_manager import ConfigManager, Logger
from jupyter_ai.models import (
ChatMessage,
HumanChatMessage,
)
from jupyter_ai.chat_handlers.base import get_preferred_dir
from jupyter_ai.models import ListOptionsEntry, HumanChatMessage
from jupyter_ai.config_manager import ConfigManager, Logger
from jupyter_ai.models import ChatMessage, HumanChatMessage, ListOptionsEntry

if TYPE_CHECKING:
from jupyter_ai.history import BoundedChatHistory
from jupyter_ai.chat_handlers import BaseChatHandler
from jupyter_ai.history import BoundedChatHistory


class BaseContextProvider(abc.ABC):
Expand Down
4 changes: 2 additions & 2 deletions packages/jupyter-ai/jupyter_ai/context_providers/file.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
import glob
import os
import re
from typing import List

import nbformat
from jupyter_ai.models import ListOptionsEntry, HumanChatMessage
from jupyter_ai.document_loaders.directory import SUPPORTED_EXTS
from jupyter_ai.models import HumanChatMessage, ListOptionsEntry

from .base import BaseCommandContextProvider, ContextProviderException

Expand Down
3 changes: 1 addition & 2 deletions packages/jupyter-ai/jupyter_ai/context_providers/learned.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from typing import List

from jupyter_ai.models import HumanChatMessage
from jupyter_ai.chat_handlers.learn import Retriever
from jupyter_ai.models import HumanChatMessage

from .base import BaseCommandContextProvider
from .file import FileContextProvider


FILE_CHUNK_TEMPLATE = """
Snippet from file: {filepath}
```
Expand Down
4 changes: 2 additions & 2 deletions packages/jupyter-ai/jupyter_ai/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
HelpChatHandler,
LearnChatHandler,
)
from .context_providers import FileContextProvider, LearnedContextProvider
from .completions.handlers import DefaultInlineCompletionHandler
from .config_manager import ConfigManager
from .context_providers import FileContextProvider, LearnedContextProvider
from .handlers import (
ApiKeysHandler,
AutocompleteOptionsHandler,
ChatHistoryHandler,
EmbeddingsModelProviderHandler,
GlobalConfigHandler,
ModelProviderHandler,
RootChatHandler,
SlashCommandsInfoHandler,
AutocompleteOptionsHandler,
)
from .history import BoundedChatHistory

Expand Down
6 changes: 3 additions & 3 deletions packages/jupyter-ai/jupyter_ai/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
ClosePendingMessage,
ConnectionMessage,
HumanChatMessage,
ListOptionsEntry,
ListOptionsResponse,
ListProvidersEntry,
ListProvidersResponse,
ListSlashCommandsEntry,
ListSlashCommandsResponse,
ListOptionsEntry,
ListOptionsResponse,
Message,
PendingMessage,
UpdateConfigRequest,
Expand All @@ -45,8 +45,8 @@
from jupyter_ai_magics.embedding_providers import BaseEmbeddingsProvider
from jupyter_ai_magics.providers import BaseProvider

from .history import BoundedChatHistory
from .context_providers import BaseContextProvider
from .history import BoundedChatHistory


class ChatHistoryHandler(BaseAPIHandler):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
from unittest import mock

import pytest
from jupyter_ai.context_providers import FileContextProvider
from jupyter_ai.config_manager import ConfigManager
from jupyter_ai.context_providers import FileContextProvider
from jupyter_ai.history import BoundedChatHistory
from jupyter_ai.models import (
ChatClient,
HumanChatMessage,
Persona,
)
from jupyter_ai.models import ChatClient, HumanChatMessage, Persona


@pytest.fixture
Expand Down

0 comments on commit 49779f1

Please sign in to comment.