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

langchain[patch]: Migrate chat loaders to optional community imports #21089

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions libs/langchain/langchain/chat_loaders/gmail.py
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",
]
24 changes: 22 additions & 2 deletions libs/langchain/langchain/chat_loaders/imessage.py
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",
]
34 changes: 29 additions & 5 deletions libs/langchain/langchain/chat_loaders/langsmith.py
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",
]
24 changes: 22 additions & 2 deletions libs/langchain/langchain/chat_loaders/slack.py
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",
]
24 changes: 22 additions & 2 deletions libs/langchain/langchain/chat_loaders/telegram.py
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",
]
35 changes: 29 additions & 6 deletions libs/langchain/langchain/chat_loaders/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
from langchain_community.chat_loaders.utils import (
map_ai_messages,
map_ai_messages_in_session,
merge_chat_runs,
merge_chat_runs_in_session,
)
from typing import TYPE_CHECKING, Any

from langchain._api import create_importer

if TYPE_CHECKING:
from langchain_community.chat_loaders.utils import (
map_ai_messages,
map_ai_messages_in_session,
merge_chat_runs,
merge_chat_runs_in_session,
)

# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
"merge_chat_runs_in_session": "langchain_community.chat_loaders.utils",
"merge_chat_runs": "langchain_community.chat_loaders.utils",
"map_ai_messages_in_session": "langchain_community.chat_loaders.utils",
"map_ai_messages": "langchain_community.chat_loaders.utils",
}

_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)


def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)


__all__ = [
"merge_chat_runs_in_session",
Expand Down
24 changes: 22 additions & 2 deletions libs/langchain/langchain/chat_loaders/whatsapp.py
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",
]
Loading