-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
langchain[patch]: Migrate chat loaders to optional community imports (#…
…21089) Migrate chat loaders to optional community imports
- Loading branch information
Showing
7 changed files
with
168 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
from langchain_community.chat_loaders.gmail import ( | ||
GMailLoader, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["GMailLoader"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.chat_loaders.gmail import GMailLoader | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = {"GMailLoader": "langchain_community.chat_loaders.gmail"} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"GMailLoader", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
from langchain_community.chat_loaders.imessage import IMessageChatLoader | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["IMessageChatLoader"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.chat_loaders.imessage import IMessageChatLoader | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = {"IMessageChatLoader": "langchain_community.chat_loaders.imessage"} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"IMessageChatLoader", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,30 @@ | ||
from langchain_community.chat_loaders.langsmith import ( | ||
LangSmithDatasetChatLoader, | ||
LangSmithRunChatLoader, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["LangSmithRunChatLoader", "LangSmithDatasetChatLoader"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.chat_loaders.langsmith import ( | ||
LangSmithDatasetChatLoader, | ||
LangSmithRunChatLoader, | ||
) | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"LangSmithRunChatLoader": "langchain_community.chat_loaders.langsmith", | ||
"LangSmithDatasetChatLoader": "langchain_community.chat_loaders.langsmith", | ||
} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"LangSmithRunChatLoader", | ||
"LangSmithDatasetChatLoader", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
from langchain_community.chat_loaders.slack import SlackChatLoader | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["SlackChatLoader"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.chat_loaders.slack import SlackChatLoader | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = {"SlackChatLoader": "langchain_community.chat_loaders.slack"} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"SlackChatLoader", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
from langchain_community.chat_loaders.telegram import TelegramChatLoader | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["TelegramChatLoader"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.chat_loaders.telegram import TelegramChatLoader | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = {"TelegramChatLoader": "langchain_community.chat_loaders.telegram"} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"TelegramChatLoader", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
from langchain_community.chat_loaders.whatsapp import WhatsAppChatLoader | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["WhatsAppChatLoader"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.chat_loaders.whatsapp import WhatsAppChatLoader | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = {"WhatsAppChatLoader": "langchain_community.chat_loaders.whatsapp"} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"WhatsAppChatLoader", | ||
] |