-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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 document transformers (#21098)
Migrate document transformers
- Loading branch information
Showing
11 changed files
with
301 additions
and
61 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
28 changes: 24 additions & 4 deletions
28
libs/langchain/langchain/document_transformers/beautiful_soup_transformer.py
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,25 @@ | ||
from langchain_community.document_transformers.beautiful_soup_transformer import ( | ||
BeautifulSoupTransformer, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["BeautifulSoupTransformer"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.document_transformers import BeautifulSoupTransformer | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"BeautifulSoupTransformer": "langchain_community.document_transformers" | ||
} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"BeautifulSoupTransformer", | ||
] |
28 changes: 24 additions & 4 deletions
28
libs/langchain/langchain/document_transformers/doctran_text_extract.py
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,25 @@ | ||
from langchain_community.document_transformers.doctran_text_extract import ( | ||
DoctranPropertyExtractor, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["DoctranPropertyExtractor"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.document_transformers import DoctranPropertyExtractor | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"DoctranPropertyExtractor": "langchain_community.document_transformers" | ||
} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"DoctranPropertyExtractor", | ||
] |
28 changes: 24 additions & 4 deletions
28
libs/langchain/langchain/document_transformers/doctran_text_qa.py
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,25 @@ | ||
from langchain_community.document_transformers.doctran_text_qa import ( | ||
DoctranQATransformer, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["DoctranQATransformer"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.document_transformers import DoctranQATransformer | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"DoctranQATransformer": "langchain_community.document_transformers" | ||
} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"DoctranQATransformer", | ||
] |
28 changes: 24 additions & 4 deletions
28
libs/langchain/langchain/document_transformers/doctran_text_translate.py
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,25 @@ | ||
from langchain_community.document_transformers.doctran_text_translate import ( | ||
DoctranTextTranslator, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["DoctranTextTranslator"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.document_transformers import DoctranTextTranslator | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"DoctranTextTranslator": "langchain_community.document_transformers" | ||
} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"DoctranTextTranslator", | ||
] |
49 changes: 41 additions & 8 deletions
49
libs/langchain/langchain/document_transformers/embeddings_redundant_filter.py
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
28 changes: 24 additions & 4 deletions
28
libs/langchain/langchain/document_transformers/google_translate.py
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,25 @@ | ||
from langchain_community.document_transformers.google_translate import ( | ||
GoogleTranslateTransformer, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["GoogleTranslateTransformer"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.document_transformers import GoogleTranslateTransformer | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"GoogleTranslateTransformer": "langchain_community.document_transformers" | ||
} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"GoogleTranslateTransformer", | ||
] |
26 changes: 24 additions & 2 deletions
26
libs/langchain/langchain/document_transformers/html2text.py
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,25 @@ | ||
from langchain_community.document_transformers.html2text import Html2TextTransformer | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["Html2TextTransformer"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.document_transformers import Html2TextTransformer | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"Html2TextTransformer": "langchain_community.document_transformers" | ||
} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"Html2TextTransformer", | ||
] |
26 changes: 22 additions & 4 deletions
26
libs/langchain/langchain/document_transformers/long_context_reorder.py
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.document_transformers.long_context_reorder import ( | ||
LongContextReorder, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["LongContextReorder"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.document_transformers import LongContextReorder | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = {"LongContextReorder": "langchain_community.document_transformers"} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"LongContextReorder", | ||
] |
28 changes: 24 additions & 4 deletions
28
libs/langchain/langchain/document_transformers/nuclia_text_transform.py
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,25 @@ | ||
from langchain_community.document_transformers.nuclia_text_transform import ( | ||
NucliaTextTransformer, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["NucliaTextTransformer"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.document_transformers import NucliaTextTransformer | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"NucliaTextTransformer": "langchain_community.document_transformers" | ||
} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"NucliaTextTransformer", | ||
] |
36 changes: 31 additions & 5 deletions
36
libs/langchain/langchain/document_transformers/openai_functions.py
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,32 @@ | ||
from langchain_community.document_transformers.openai_functions import ( | ||
OpenAIMetadataTagger, | ||
create_metadata_tagger, | ||
) | ||
from typing import TYPE_CHECKING, Any | ||
|
||
__all__ = ["OpenAIMetadataTagger", "create_metadata_tagger"] | ||
from langchain._api import create_importer | ||
|
||
if TYPE_CHECKING: | ||
from langchain_community.document_transformers import OpenAIMetadataTagger | ||
from langchain_community.document_transformers.openai_functions import ( | ||
create_metadata_tagger, | ||
) | ||
|
||
# Create a way to dynamically look up deprecated imports. | ||
# Used to consolidate logic for raising deprecation warnings and | ||
# handling optional imports. | ||
DEPRECATED_LOOKUP = { | ||
"OpenAIMetadataTagger": "langchain_community.document_transformers", | ||
"create_metadata_tagger": ( | ||
"langchain_community.document_transformers.openai_functions" | ||
), | ||
} | ||
|
||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP) | ||
|
||
|
||
def __getattr__(name: str) -> Any: | ||
"""Look up attributes dynamically.""" | ||
return _import_attribute(name) | ||
|
||
|
||
__all__ = [ | ||
"OpenAIMetadataTagger", | ||
"create_metadata_tagger", | ||
] |