Skip to content

Commit 42e8dfa

Browse files
authored
[litellm] Remove LangChain from source code (#1435)
* remove LangChain from jupyter_ai_magics * remove unused useServerInfo() hook in frontend * remove LangChain references from jupyter_ai * remove langchain from test & cookiecutter packages * move all completions code to jupyter_ai.completions * remove LangChain provider code from ConfigManager * minor fixes to allow JAI to start
1 parent c4ebbef commit 42e8dfa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+455
-3419
lines changed
Lines changed: 10 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,19 @@
1-
from typing import TYPE_CHECKING
2-
3-
from ._import_utils import import_attr as _import_attr
1+
from __future__ import annotations
42
from ._version import __version__
53

6-
if TYPE_CHECKING:
7-
# same as dynamic imports but understood by mypy
8-
from .embedding_providers import (
9-
BaseEmbeddingsProvider,
10-
GPT4AllEmbeddingsProvider,
11-
HfHubEmbeddingsProvider,
12-
QianfanEmbeddingsEndpointProvider,
13-
)
14-
from .exception import store_exception
15-
from .magics import AiMagics
16-
from .providers import (
17-
AI21Provider,
18-
BaseProvider,
19-
GPT4AllProvider,
20-
HfHubProvider,
21-
QianfanProvider,
22-
TogetherAIProvider,
23-
)
24-
else:
25-
_exports_by_module = {
26-
"embedding_providers": [
27-
"BaseEmbeddingsProvider",
28-
"GPT4AllEmbeddingsProvider",
29-
"HfHubEmbeddingsProvider",
30-
"QianfanEmbeddingsEndpointProvider",
31-
],
32-
"exception": ["store_exception"],
33-
"magics": ["AiMagics"],
34-
# expose model providers on the package root
35-
"providers": [
36-
"AI21Provider",
37-
"BaseProvider",
38-
"GPT4AllProvider",
39-
"HfHubProvider",
40-
"QianfanProvider",
41-
"TogetherAIProvider",
42-
],
43-
}
4+
from typing import TYPE_CHECKING
445

45-
_modules_by_export = {
46-
import_name: module
47-
for module, imports in _exports_by_module.items()
48-
for import_name in imports
49-
}
6+
if TYPE_CHECKING:
7+
from IPython.core.interactiveshell import InteractiveShell
508

51-
def __getattr__(export_name: str) -> object:
52-
module_name = _modules_by_export.get(export_name)
53-
result = _import_attr(export_name, module_name, __spec__.parent)
54-
globals()[export_name] = result
55-
return result
569

10+
def load_ipython_extension(ipython: InteractiveShell):
11+
from .exception import store_exception
12+
from .magics import AiMagics
5713

58-
def load_ipython_extension(ipython):
59-
ipython.register_magics(__getattr__("AiMagics"))
60-
ipython.set_custom_exc((BaseException,), __getattr__("store_exception"))
14+
ipython.register_magics(AiMagics)
15+
ipython.set_custom_exc((BaseException,), store_exception)
6116

6217

63-
def unload_ipython_extension(ipython):
18+
def unload_ipython_extension(ipython: InteractiveShell):
6419
ipython.set_custom_exc((BaseException,), ipython.CustomTB)
65-
66-
67-
# required to preserve backward compatibility with `from jupyter_ai_magics import *`
68-
__all__ = [
69-
"__version__",
70-
"load_ipython_extension",
71-
"unload_ipython_extension",
72-
"BaseEmbeddingsProvider",
73-
"GPT4AllEmbeddingsProvider",
74-
"HfHubEmbeddingsProvider",
75-
"QianfanEmbeddingsEndpointProvider",
76-
"store_exception",
77-
"AiMagics",
78-
"AI21Provider",
79-
"BaseProvider",
80-
"GPT4AllProvider",
81-
"HfHubProvider",
82-
"QianfanProvider",
83-
"TogetherAIProvider",
84-
]
85-
86-
87-
def __dir__():
88-
# Allows more editors (e.g. IPython) to complete on `jupyter_ai_magics.<tab>`
89-
return list(__all__)

packages/jupyter-ai-magics/jupyter_ai_magics/_import_utils.py

Lines changed: 0 additions & 58 deletions
This file was deleted.

packages/jupyter-ai-magics/jupyter_ai_magics/aliases.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)