mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-01 09:04:03 +00:00
refactor(langchain): use create_importer for HypotheticalDocumentEmbedder
This commit is contained in:
parent
3496e1739e
commit
4ed3c74aeb
@ -74,32 +74,12 @@ if TYPE_CHECKING:
|
|||||||
XinferenceEmbeddings,
|
XinferenceEmbeddings,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from langchain.chains.hyde.base import HypotheticalDocumentEmbedder
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# TODO: this is in here to maintain backwards compatibility
|
|
||||||
class HypotheticalDocumentEmbedder:
|
|
||||||
def __init__(self, *args: Any, **kwargs: Any):
|
|
||||||
logger.warning(
|
|
||||||
"Using a deprecated class. Please use "
|
|
||||||
"`from langchain.chains import HypotheticalDocumentEmbedder` instead",
|
|
||||||
)
|
|
||||||
from langchain.chains.hyde.base import HypotheticalDocumentEmbedder as H
|
|
||||||
|
|
||||||
return H(*args, **kwargs) # type: ignore[return-value] # noqa: PLE0101
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def from_llm(cls, *args: Any, **kwargs: Any) -> Any:
|
|
||||||
logger.warning(
|
|
||||||
"Using a deprecated class. Please use "
|
|
||||||
"`from langchain.chains import HypotheticalDocumentEmbedder` instead",
|
|
||||||
)
|
|
||||||
from langchain.chains.hyde.base import HypotheticalDocumentEmbedder as H
|
|
||||||
|
|
||||||
return H.from_llm(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
# Create a way to dynamically look up deprecated imports.
|
# Create a way to dynamically look up deprecated imports.
|
||||||
# Used to consolidate logic for raising deprecation warnings and
|
# Used to consolidate logic for raising deprecation warnings and
|
||||||
# handling optional imports.
|
# handling optional imports.
|
||||||
@ -130,6 +110,7 @@ DEPRECATED_LOOKUP = {
|
|||||||
"HuggingFaceHubEmbeddings": "langchain_community.embeddings",
|
"HuggingFaceHubEmbeddings": "langchain_community.embeddings",
|
||||||
"HuggingFaceInferenceAPIEmbeddings": "langchain_community.embeddings",
|
"HuggingFaceInferenceAPIEmbeddings": "langchain_community.embeddings",
|
||||||
"HuggingFaceInstructEmbeddings": "langchain_community.embeddings",
|
"HuggingFaceInstructEmbeddings": "langchain_community.embeddings",
|
||||||
|
"HypotheticalDocumentEmbedder": "langchain.chains.hyde.base",
|
||||||
"InfinityEmbeddings": "langchain_community.embeddings",
|
"InfinityEmbeddings": "langchain_community.embeddings",
|
||||||
"JavelinAIGatewayEmbeddings": "langchain_community.embeddings",
|
"JavelinAIGatewayEmbeddings": "langchain_community.embeddings",
|
||||||
"JinaEmbeddings": "langchain_community.embeddings",
|
"JinaEmbeddings": "langchain_community.embeddings",
|
||||||
@ -195,6 +176,7 @@ __all__ = [
|
|||||||
"HuggingFaceHubEmbeddings",
|
"HuggingFaceHubEmbeddings",
|
||||||
"HuggingFaceInferenceAPIEmbeddings",
|
"HuggingFaceInferenceAPIEmbeddings",
|
||||||
"HuggingFaceInstructEmbeddings",
|
"HuggingFaceInstructEmbeddings",
|
||||||
|
"HypotheticalDocumentEmbedder",
|
||||||
"InfinityEmbeddings",
|
"InfinityEmbeddings",
|
||||||
"JavelinAIGatewayEmbeddings",
|
"JavelinAIGatewayEmbeddings",
|
||||||
"JinaEmbeddings",
|
"JinaEmbeddings",
|
||||||
|
@ -11,6 +11,7 @@ EXPECTED_ALL = [
|
|||||||
"FastEmbedEmbeddings",
|
"FastEmbedEmbeddings",
|
||||||
"HuggingFaceEmbeddings",
|
"HuggingFaceEmbeddings",
|
||||||
"HuggingFaceInferenceAPIEmbeddings",
|
"HuggingFaceInferenceAPIEmbeddings",
|
||||||
|
"HypotheticalDocumentEmbedder",
|
||||||
"InfinityEmbeddings",
|
"InfinityEmbeddings",
|
||||||
"GradientEmbeddings",
|
"GradientEmbeddings",
|
||||||
"JinaEmbeddings",
|
"JinaEmbeddings",
|
||||||
|
@ -96,7 +96,7 @@ def test_no_more_changes_to_proxy_community() -> None:
|
|||||||
# most cases.
|
# most cases.
|
||||||
hash_ += len(str(sorted(deprecated_lookup.items())))
|
hash_ += len(str(sorted(deprecated_lookup.items())))
|
||||||
|
|
||||||
evil_magic_number = 38620
|
evil_magic_number = 38684
|
||||||
|
|
||||||
assert hash_ == evil_magic_number, (
|
assert hash_ == evil_magic_number, (
|
||||||
"If you're triggering this test, you're likely adding a new import "
|
"If you're triggering this test, you're likely adding a new import "
|
||||||
|
Loading…
Reference in New Issue
Block a user