community[patch]: cross_encoders flatten namespaces (#20183)

Issue `langchain_community.cross_encoders` didn't have flattening
namespace code in the __init__.py file.
Changes:
- added code to flattening namespaces (used #20050 as a template)
- added ut for a change
- added missed `test_imports` for `chat_loaders` and
`chat_message_histories` modules
This commit is contained in:
Leonid Ganeline
2024-04-08 17:50:23 -07:00
committed by GitHub
parent 1af7133828
commit 2f8dd1a161
5 changed files with 91 additions and 12 deletions

View File

@@ -0,0 +1,18 @@
from langchain_community.chat_loaders import _module_lookup
EXPECTED_ALL = [
"BaseChatLoader",
"FolderFacebookMessengerChatLoader",
"GMailLoader",
"IMessageChatLoader",
"LangSmithDatasetChatLoader",
"LangSmithRunChatLoader",
"SingleFileFacebookMessengerChatLoader",
"SlackChatLoader",
"TelegramChatLoader",
"WhatsAppChatLoader",
]
def test_all_imports() -> None:
assert set(_module_lookup.keys()) == set(EXPECTED_ALL)

View File

@@ -0,0 +1,29 @@
from langchain_community.chat_message_histories import _module_lookup
EXPECTED_ALL = [
"AstraDBChatMessageHistory",
"CassandraChatMessageHistory",
"ChatMessageHistory",
"CosmosDBChatMessageHistory",
"DynamoDBChatMessageHistory",
"ElasticsearchChatMessageHistory",
"FileChatMessageHistory",
"FirestoreChatMessageHistory",
"MomentoChatMessageHistory",
"MongoDBChatMessageHistory",
"Neo4jChatMessageHistory",
"PostgresChatMessageHistory",
"RedisChatMessageHistory",
"RocksetChatMessageHistory",
"SQLChatMessageHistory",
"SingleStoreDBChatMessageHistory",
"StreamlitChatMessageHistory",
"TiDBChatMessageHistory",
"UpstashRedisChatMessageHistory",
"XataChatMessageHistory",
"ZepChatMessageHistory",
]
def test_all_imports() -> None:
assert set(_module_lookup.keys()) == set(EXPECTED_ALL)

View File

@@ -0,0 +1,14 @@
from langchain_community.cross_encoders import __all__, _module_lookup
EXPECTED_ALL = [
"BaseCrossEncoder",
"FakeCrossEncoder",
"HuggingFaceCrossEncoder",
"SagemakerEndpointCrossEncoder",
]
def test_all_imports() -> None:
"""Test that __all__ is correctly set."""
assert set(__all__) == set(EXPECTED_ALL)
assert set(__all__) == set(_module_lookup.keys())