initial commit
This commit is contained in:
204
venv/Lib/site-packages/langchain_classic/embeddings/__init__.py
Normal file
204
venv/Lib/site-packages/langchain_classic/embeddings/__init__.py
Normal file
@@ -0,0 +1,204 @@
|
||||
"""**Embedding models**.
|
||||
|
||||
**Embedding models** are wrappers around embedding models
|
||||
from different APIs and services.
|
||||
|
||||
Embedding models can be LLMs or not.
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
from langchain_classic.embeddings.base import init_embeddings
|
||||
from langchain_classic.embeddings.cache import CacheBackedEmbeddings
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import (
|
||||
AlephAlphaAsymmetricSemanticEmbedding,
|
||||
AlephAlphaSymmetricSemanticEmbedding,
|
||||
AwaEmbeddings,
|
||||
AzureOpenAIEmbeddings,
|
||||
BedrockEmbeddings,
|
||||
BookendEmbeddings,
|
||||
ClarifaiEmbeddings,
|
||||
CohereEmbeddings,
|
||||
DashScopeEmbeddings,
|
||||
DatabricksEmbeddings,
|
||||
DeepInfraEmbeddings,
|
||||
DeterministicFakeEmbedding,
|
||||
EdenAiEmbeddings,
|
||||
ElasticsearchEmbeddings,
|
||||
EmbaasEmbeddings,
|
||||
ErnieEmbeddings,
|
||||
FakeEmbeddings,
|
||||
FastEmbedEmbeddings,
|
||||
GooglePalmEmbeddings,
|
||||
GPT4AllEmbeddings,
|
||||
GradientEmbeddings,
|
||||
HuggingFaceBgeEmbeddings,
|
||||
HuggingFaceEmbeddings,
|
||||
HuggingFaceHubEmbeddings,
|
||||
HuggingFaceInferenceAPIEmbeddings,
|
||||
HuggingFaceInstructEmbeddings,
|
||||
InfinityEmbeddings,
|
||||
JavelinAIGatewayEmbeddings,
|
||||
JinaEmbeddings,
|
||||
JohnSnowLabsEmbeddings,
|
||||
LlamaCppEmbeddings,
|
||||
LocalAIEmbeddings,
|
||||
MiniMaxEmbeddings,
|
||||
MlflowAIGatewayEmbeddings,
|
||||
MlflowEmbeddings,
|
||||
ModelScopeEmbeddings,
|
||||
MosaicMLInstructorEmbeddings,
|
||||
NLPCloudEmbeddings,
|
||||
OctoAIEmbeddings,
|
||||
OllamaEmbeddings,
|
||||
OpenAIEmbeddings,
|
||||
OpenVINOEmbeddings,
|
||||
QianfanEmbeddingsEndpoint,
|
||||
SagemakerEndpointEmbeddings,
|
||||
SelfHostedEmbeddings,
|
||||
SelfHostedHuggingFaceEmbeddings,
|
||||
SelfHostedHuggingFaceInstructEmbeddings,
|
||||
SentenceTransformerEmbeddings,
|
||||
SpacyEmbeddings,
|
||||
TensorflowHubEmbeddings,
|
||||
VertexAIEmbeddings,
|
||||
VoyageEmbeddings,
|
||||
XinferenceEmbeddings,
|
||||
)
|
||||
|
||||
from langchain_classic.chains.hyde.base import HypotheticalDocumentEmbedder
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {
|
||||
"AlephAlphaAsymmetricSemanticEmbedding": "langchain_community.embeddings",
|
||||
"AlephAlphaSymmetricSemanticEmbedding": "langchain_community.embeddings",
|
||||
"AwaEmbeddings": "langchain_community.embeddings",
|
||||
"AzureOpenAIEmbeddings": "langchain_community.embeddings",
|
||||
"BedrockEmbeddings": "langchain_community.embeddings",
|
||||
"BookendEmbeddings": "langchain_community.embeddings",
|
||||
"ClarifaiEmbeddings": "langchain_community.embeddings",
|
||||
"CohereEmbeddings": "langchain_community.embeddings",
|
||||
"DashScopeEmbeddings": "langchain_community.embeddings",
|
||||
"DatabricksEmbeddings": "langchain_community.embeddings",
|
||||
"DeepInfraEmbeddings": "langchain_community.embeddings",
|
||||
"DeterministicFakeEmbedding": "langchain_community.embeddings",
|
||||
"EdenAiEmbeddings": "langchain_community.embeddings",
|
||||
"ElasticsearchEmbeddings": "langchain_community.embeddings",
|
||||
"EmbaasEmbeddings": "langchain_community.embeddings",
|
||||
"ErnieEmbeddings": "langchain_community.embeddings",
|
||||
"FakeEmbeddings": "langchain_community.embeddings",
|
||||
"FastEmbedEmbeddings": "langchain_community.embeddings",
|
||||
"GooglePalmEmbeddings": "langchain_community.embeddings",
|
||||
"GPT4AllEmbeddings": "langchain_community.embeddings",
|
||||
"GradientEmbeddings": "langchain_community.embeddings",
|
||||
"HuggingFaceBgeEmbeddings": "langchain_community.embeddings",
|
||||
"HuggingFaceEmbeddings": "langchain_community.embeddings",
|
||||
"HuggingFaceHubEmbeddings": "langchain_community.embeddings",
|
||||
"HuggingFaceInferenceAPIEmbeddings": "langchain_community.embeddings",
|
||||
"HuggingFaceInstructEmbeddings": "langchain_community.embeddings",
|
||||
"HypotheticalDocumentEmbedder": "langchain_classic.chains.hyde.base",
|
||||
"InfinityEmbeddings": "langchain_community.embeddings",
|
||||
"JavelinAIGatewayEmbeddings": "langchain_community.embeddings",
|
||||
"JinaEmbeddings": "langchain_community.embeddings",
|
||||
"JohnSnowLabsEmbeddings": "langchain_community.embeddings",
|
||||
"LlamaCppEmbeddings": "langchain_community.embeddings",
|
||||
"LocalAIEmbeddings": "langchain_community.embeddings",
|
||||
"MiniMaxEmbeddings": "langchain_community.embeddings",
|
||||
"MlflowAIGatewayEmbeddings": "langchain_community.embeddings",
|
||||
"MlflowEmbeddings": "langchain_community.embeddings",
|
||||
"ModelScopeEmbeddings": "langchain_community.embeddings",
|
||||
"MosaicMLInstructorEmbeddings": "langchain_community.embeddings",
|
||||
"NLPCloudEmbeddings": "langchain_community.embeddings",
|
||||
"OctoAIEmbeddings": "langchain_community.embeddings",
|
||||
"OllamaEmbeddings": "langchain_community.embeddings",
|
||||
"OpenAIEmbeddings": "langchain_community.embeddings",
|
||||
"OpenVINOEmbeddings": "langchain_community.embeddings",
|
||||
"QianfanEmbeddingsEndpoint": "langchain_community.embeddings",
|
||||
"SagemakerEndpointEmbeddings": "langchain_community.embeddings",
|
||||
"SelfHostedEmbeddings": "langchain_community.embeddings",
|
||||
"SelfHostedHuggingFaceEmbeddings": "langchain_community.embeddings",
|
||||
"SelfHostedHuggingFaceInstructEmbeddings": "langchain_community.embeddings",
|
||||
"SentenceTransformerEmbeddings": "langchain_community.embeddings",
|
||||
"SpacyEmbeddings": "langchain_community.embeddings",
|
||||
"TensorflowHubEmbeddings": "langchain_community.embeddings",
|
||||
"VertexAIEmbeddings": "langchain_community.embeddings",
|
||||
"VoyageEmbeddings": "langchain_community.embeddings",
|
||||
"XinferenceEmbeddings": "langchain_community.embeddings",
|
||||
}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"AlephAlphaAsymmetricSemanticEmbedding",
|
||||
"AlephAlphaSymmetricSemanticEmbedding",
|
||||
"AwaEmbeddings",
|
||||
"AzureOpenAIEmbeddings",
|
||||
"BedrockEmbeddings",
|
||||
"BookendEmbeddings",
|
||||
"CacheBackedEmbeddings",
|
||||
"ClarifaiEmbeddings",
|
||||
"CohereEmbeddings",
|
||||
"DashScopeEmbeddings",
|
||||
"DatabricksEmbeddings",
|
||||
"DeepInfraEmbeddings",
|
||||
"DeterministicFakeEmbedding",
|
||||
"EdenAiEmbeddings",
|
||||
"ElasticsearchEmbeddings",
|
||||
"EmbaasEmbeddings",
|
||||
"ErnieEmbeddings",
|
||||
"FakeEmbeddings",
|
||||
"FastEmbedEmbeddings",
|
||||
"GPT4AllEmbeddings",
|
||||
"GooglePalmEmbeddings",
|
||||
"GradientEmbeddings",
|
||||
"HuggingFaceBgeEmbeddings",
|
||||
"HuggingFaceEmbeddings",
|
||||
"HuggingFaceHubEmbeddings",
|
||||
"HuggingFaceInferenceAPIEmbeddings",
|
||||
"HuggingFaceInstructEmbeddings",
|
||||
"HypotheticalDocumentEmbedder",
|
||||
"InfinityEmbeddings",
|
||||
"JavelinAIGatewayEmbeddings",
|
||||
"JinaEmbeddings",
|
||||
"JohnSnowLabsEmbeddings",
|
||||
"LlamaCppEmbeddings",
|
||||
"LocalAIEmbeddings",
|
||||
"MiniMaxEmbeddings",
|
||||
"MlflowAIGatewayEmbeddings",
|
||||
"MlflowEmbeddings",
|
||||
"ModelScopeEmbeddings",
|
||||
"MosaicMLInstructorEmbeddings",
|
||||
"NLPCloudEmbeddings",
|
||||
"OctoAIEmbeddings",
|
||||
"OllamaEmbeddings",
|
||||
"OpenAIEmbeddings",
|
||||
"OpenVINOEmbeddings",
|
||||
"QianfanEmbeddingsEndpoint",
|
||||
"SagemakerEndpointEmbeddings",
|
||||
"SelfHostedEmbeddings",
|
||||
"SelfHostedHuggingFaceEmbeddings",
|
||||
"SelfHostedHuggingFaceInstructEmbeddings",
|
||||
"SentenceTransformerEmbeddings",
|
||||
"SpacyEmbeddings",
|
||||
"TensorflowHubEmbeddings",
|
||||
"VertexAIEmbeddings",
|
||||
"VoyageEmbeddings",
|
||||
"XinferenceEmbeddings",
|
||||
"init_embeddings",
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,30 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import (
|
||||
AlephAlphaAsymmetricSemanticEmbedding,
|
||||
AlephAlphaSymmetricSemanticEmbedding,
|
||||
)
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {
|
||||
"AlephAlphaAsymmetricSemanticEmbedding": "langchain_community.embeddings",
|
||||
"AlephAlphaSymmetricSemanticEmbedding": "langchain_community.embeddings",
|
||||
}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"AlephAlphaAsymmetricSemanticEmbedding",
|
||||
"AlephAlphaSymmetricSemanticEmbedding",
|
||||
]
|
||||
23
venv/Lib/site-packages/langchain_classic/embeddings/awa.py
Normal file
23
venv/Lib/site-packages/langchain_classic/embeddings/awa.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import AwaEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"AwaEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"AwaEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import AzureOpenAIEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"AzureOpenAIEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"AzureOpenAIEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import QianfanEmbeddingsEndpoint
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"QianfanEmbeddingsEndpoint": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"QianfanEmbeddingsEndpoint",
|
||||
]
|
||||
251
venv/Lib/site-packages/langchain_classic/embeddings/base.py
Normal file
251
venv/Lib/site-packages/langchain_classic/embeddings/base.py
Normal file
@@ -0,0 +1,251 @@
|
||||
import functools
|
||||
from importlib import util
|
||||
from typing import Any
|
||||
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.runnables import Runnable
|
||||
|
||||
_SUPPORTED_PROVIDERS = {
|
||||
"azure_openai": "langchain_openai",
|
||||
"bedrock": "langchain_aws",
|
||||
"cohere": "langchain_cohere",
|
||||
"google_genai": "langchain_google_genai",
|
||||
"google_vertexai": "langchain_google_vertexai",
|
||||
"huggingface": "langchain_huggingface",
|
||||
"mistralai": "langchain_mistralai",
|
||||
"ollama": "langchain_ollama",
|
||||
"openai": "langchain_openai",
|
||||
}
|
||||
|
||||
|
||||
def _get_provider_list() -> str:
|
||||
"""Get formatted list of providers and their packages."""
|
||||
return "\n".join(
|
||||
f" - {p}: {pkg.replace('_', '-')}" for p, pkg in _SUPPORTED_PROVIDERS.items()
|
||||
)
|
||||
|
||||
|
||||
def _parse_model_string(model_name: str) -> tuple[str, str]:
|
||||
"""Parse a model string into provider and model name components.
|
||||
|
||||
The model string should be in the format 'provider:model-name', where provider
|
||||
is one of the supported providers.
|
||||
|
||||
Args:
|
||||
model_name: A model string in the format 'provider:model-name'
|
||||
|
||||
Returns:
|
||||
A tuple of (provider, model_name)
|
||||
|
||||
```python
|
||||
_parse_model_string("openai:text-embedding-3-small")
|
||||
# Returns: ("openai", "text-embedding-3-small")
|
||||
|
||||
_parse_model_string("bedrock:amazon.titan-embed-text-v1")
|
||||
# Returns: ("bedrock", "amazon.titan-embed-text-v1")
|
||||
```
|
||||
|
||||
Raises:
|
||||
ValueError: If the model string is not in the correct format or
|
||||
the provider is unsupported
|
||||
|
||||
"""
|
||||
if ":" not in model_name:
|
||||
providers = _SUPPORTED_PROVIDERS
|
||||
msg = (
|
||||
f"Invalid model format '{model_name}'.\n"
|
||||
f"Model name must be in format 'provider:model-name'\n"
|
||||
f"Example valid model strings:\n"
|
||||
f" - openai:text-embedding-3-small\n"
|
||||
f" - bedrock:amazon.titan-embed-text-v1\n"
|
||||
f" - cohere:embed-english-v3.0\n"
|
||||
f"Supported providers: {providers}"
|
||||
)
|
||||
raise ValueError(msg)
|
||||
|
||||
provider, model = model_name.split(":", 1)
|
||||
provider = provider.lower().strip()
|
||||
model = model.strip()
|
||||
|
||||
if provider not in _SUPPORTED_PROVIDERS:
|
||||
msg = (
|
||||
f"Provider '{provider}' is not supported.\n"
|
||||
f"Supported providers and their required packages:\n"
|
||||
f"{_get_provider_list()}"
|
||||
)
|
||||
raise ValueError(msg)
|
||||
if not model:
|
||||
msg = "Model name cannot be empty"
|
||||
raise ValueError(msg)
|
||||
return provider, model
|
||||
|
||||
|
||||
def _infer_model_and_provider(
|
||||
model: str,
|
||||
*,
|
||||
provider: str | None = None,
|
||||
) -> tuple[str, str]:
|
||||
if not model.strip():
|
||||
msg = "Model name cannot be empty"
|
||||
raise ValueError(msg)
|
||||
if provider is None and ":" in model:
|
||||
provider, model_name = _parse_model_string(model)
|
||||
else:
|
||||
model_name = model
|
||||
|
||||
if not provider:
|
||||
providers = _SUPPORTED_PROVIDERS
|
||||
msg = (
|
||||
"Must specify either:\n"
|
||||
"1. A model string in format 'provider:model-name'\n"
|
||||
" Example: 'openai:text-embedding-3-small'\n"
|
||||
"2. Or explicitly set provider from: "
|
||||
f"{providers}"
|
||||
)
|
||||
raise ValueError(msg)
|
||||
|
||||
if provider not in _SUPPORTED_PROVIDERS:
|
||||
msg = (
|
||||
f"Provider '{provider}' is not supported.\n"
|
||||
f"Supported providers and their required packages:\n"
|
||||
f"{_get_provider_list()}"
|
||||
)
|
||||
raise ValueError(msg)
|
||||
return provider, model_name
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=len(_SUPPORTED_PROVIDERS))
|
||||
def _check_pkg(pkg: str) -> None:
|
||||
"""Check if a package is installed."""
|
||||
if not util.find_spec(pkg):
|
||||
msg = (
|
||||
f"Could not import {pkg} python package. "
|
||||
f"Please install it with `pip install {pkg}`"
|
||||
)
|
||||
raise ImportError(msg)
|
||||
|
||||
|
||||
def init_embeddings(
|
||||
model: str,
|
||||
*,
|
||||
provider: str | None = None,
|
||||
**kwargs: Any,
|
||||
) -> Embeddings | Runnable[Any, list[float]]:
|
||||
"""Initialize an embeddings model from a model name and optional provider.
|
||||
|
||||
!!! note
|
||||
Must have the integration package corresponding to the model provider
|
||||
installed.
|
||||
|
||||
Args:
|
||||
model: Name of the model to use.
|
||||
|
||||
Can be either:
|
||||
|
||||
- A model string like `"openai:text-embedding-3-small"`
|
||||
- Just the model name if the provider is specified separately or can be
|
||||
inferred.
|
||||
|
||||
See supported providers under the `provider` arg description.
|
||||
provider: Optional explicit provider name. If not specified, will attempt to
|
||||
parse from the model string in the `model` arg.
|
||||
|
||||
Supported providers:
|
||||
|
||||
- `openai` -> [`langchain-openai`](https://docs.langchain.com/oss/python/integrations/providers/openai)
|
||||
- `azure_openai` -> [`langchain-openai`](https://docs.langchain.com/oss/python/integrations/providers/openai)
|
||||
- `bedrock` -> [`langchain-aws`](https://docs.langchain.com/oss/python/integrations/providers/aws)
|
||||
- `cohere` -> [`langchain-cohere`](https://docs.langchain.com/oss/python/integrations/providers/cohere)
|
||||
- `google_genai` -> [`langchain-google-genai`](https://docs.langchain.com/oss/python/integrations/providers/google)
|
||||
- `google_vertexai` -> [`langchain-google-vertexai`](https://docs.langchain.com/oss/python/integrations/providers/google)
|
||||
- `huggingface` -> [`langchain-huggingface`](https://docs.langchain.com/oss/python/integrations/providers/huggingface)
|
||||
- `mistralai` -> [`langchain-mistralai`](https://docs.langchain.com/oss/python/integrations/providers/mistralai)
|
||||
- `ollama` -> [`langchain-ollama`](https://docs.langchain.com/oss/python/integrations/providers/ollama)
|
||||
|
||||
**kwargs: Additional model-specific parameters passed to the embedding model.
|
||||
These vary by provider, see the provider-specific documentation for details.
|
||||
|
||||
Returns:
|
||||
An `Embeddings` instance that can generate embeddings for text.
|
||||
|
||||
Raises:
|
||||
ValueError: If the model provider is not supported or cannot be determined
|
||||
ImportError: If the required provider package is not installed
|
||||
|
||||
???+ note "Example Usage"
|
||||
|
||||
```python
|
||||
# Using a model string
|
||||
model = init_embeddings("openai:text-embedding-3-small")
|
||||
model.embed_query("Hello, world!")
|
||||
|
||||
# Using explicit provider
|
||||
model = init_embeddings(model="text-embedding-3-small", provider="openai")
|
||||
model.embed_documents(["Hello, world!", "Goodbye, world!"])
|
||||
|
||||
# With additional parameters
|
||||
model = init_embeddings("openai:text-embedding-3-small", api_key="sk-...")
|
||||
```
|
||||
|
||||
!!! version-added "Added in `langchain` 0.3.9"
|
||||
|
||||
"""
|
||||
if not model:
|
||||
providers = _SUPPORTED_PROVIDERS.keys()
|
||||
msg = (
|
||||
f"Must specify model name. Supported providers are: {', '.join(providers)}"
|
||||
)
|
||||
raise ValueError(msg)
|
||||
|
||||
provider, model_name = _infer_model_and_provider(model, provider=provider)
|
||||
pkg = _SUPPORTED_PROVIDERS[provider]
|
||||
_check_pkg(pkg)
|
||||
|
||||
if provider == "openai":
|
||||
from langchain_openai import OpenAIEmbeddings
|
||||
|
||||
return OpenAIEmbeddings(model=model_name, **kwargs)
|
||||
if provider == "azure_openai":
|
||||
from langchain_openai import AzureOpenAIEmbeddings
|
||||
|
||||
return AzureOpenAIEmbeddings(model=model_name, **kwargs)
|
||||
if provider == "google_genai":
|
||||
from langchain_google_genai import GoogleGenerativeAIEmbeddings
|
||||
|
||||
return GoogleGenerativeAIEmbeddings(model=model_name, **kwargs)
|
||||
if provider == "google_vertexai":
|
||||
from langchain_google_vertexai import VertexAIEmbeddings
|
||||
|
||||
return VertexAIEmbeddings(model=model_name, **kwargs)
|
||||
if provider == "bedrock":
|
||||
from langchain_aws import BedrockEmbeddings
|
||||
|
||||
return BedrockEmbeddings(model_id=model_name, **kwargs)
|
||||
if provider == "cohere":
|
||||
from langchain_cohere import CohereEmbeddings
|
||||
|
||||
return CohereEmbeddings(model=model_name, **kwargs)
|
||||
if provider == "mistralai":
|
||||
from langchain_mistralai import MistralAIEmbeddings
|
||||
|
||||
return MistralAIEmbeddings(model=model_name, **kwargs)
|
||||
if provider == "huggingface":
|
||||
from langchain_huggingface import HuggingFaceEmbeddings
|
||||
|
||||
return HuggingFaceEmbeddings(model_name=model_name, **kwargs)
|
||||
if provider == "ollama":
|
||||
from langchain_ollama import OllamaEmbeddings
|
||||
|
||||
return OllamaEmbeddings(model=model_name, **kwargs)
|
||||
msg = (
|
||||
f"Provider '{provider}' is not supported.\n"
|
||||
f"Supported providers and their required packages:\n"
|
||||
f"{_get_provider_list()}"
|
||||
)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"Embeddings", # This one is for backwards compatibility
|
||||
"init_embeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import BedrockEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"BedrockEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"BedrockEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import BookendEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"BookendEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"BookendEmbeddings",
|
||||
]
|
||||
370
venv/Lib/site-packages/langchain_classic/embeddings/cache.py
Normal file
370
venv/Lib/site-packages/langchain_classic/embeddings/cache.py
Normal file
@@ -0,0 +1,370 @@
|
||||
"""Module contains code for a cache backed embedder.
|
||||
|
||||
The cache backed embedder is a wrapper around an embedder that caches
|
||||
embeddings in a key-value store. The cache is used to avoid recomputing
|
||||
embeddings for the same text.
|
||||
|
||||
The text is hashed and the hash is used as the key in the cache.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import uuid
|
||||
import warnings
|
||||
from collections.abc import Callable, Sequence
|
||||
from typing import Literal, cast
|
||||
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.stores import BaseStore, ByteStore
|
||||
from langchain_core.utils.iter import batch_iterate
|
||||
|
||||
from langchain_classic.storage.encoder_backed import EncoderBackedStore
|
||||
|
||||
NAMESPACE_UUID = uuid.UUID(int=1985)
|
||||
|
||||
|
||||
def _sha1_hash_to_uuid(text: str) -> uuid.UUID:
|
||||
"""Return a UUID derived from *text* using SHA-1 (deterministic).
|
||||
|
||||
Deterministic and fast, **but not collision-resistant**.
|
||||
|
||||
A malicious attacker could try to create two different texts that hash to the same
|
||||
UUID. This may not necessarily be an issue in the context of caching embeddings,
|
||||
but new applications should swap this out for a stronger hash function like
|
||||
xxHash, BLAKE2 or SHA-256, which are collision-resistant.
|
||||
"""
|
||||
sha1_hex = hashlib.sha1(text.encode("utf-8"), usedforsecurity=False).hexdigest()
|
||||
# Embed the hex string in `uuid5` to obtain a valid UUID.
|
||||
return uuid.uuid5(NAMESPACE_UUID, sha1_hex)
|
||||
|
||||
|
||||
def _make_default_key_encoder(namespace: str, algorithm: str) -> Callable[[str], str]:
|
||||
"""Create a default key encoder function.
|
||||
|
||||
Args:
|
||||
namespace: Prefix that segregates keys from different embedding models.
|
||||
algorithm:
|
||||
* `'sha1'` - fast but not collision-resistant
|
||||
* `'blake2b'` - cryptographically strong, faster than SHA-1
|
||||
* `'sha256'` - cryptographically strong, slower than SHA-1
|
||||
* `'sha512'` - cryptographically strong, slower than SHA-1
|
||||
|
||||
Returns:
|
||||
A function that encodes a key using the specified algorithm.
|
||||
"""
|
||||
if algorithm == "sha1":
|
||||
_warn_about_sha1_encoder()
|
||||
|
||||
def _key_encoder(key: str) -> str:
|
||||
"""Encode a key using the specified algorithm."""
|
||||
if algorithm == "sha1":
|
||||
return f"{namespace}{_sha1_hash_to_uuid(key)}"
|
||||
if algorithm == "blake2b":
|
||||
return f"{namespace}{hashlib.blake2b(key.encode('utf-8')).hexdigest()}"
|
||||
if algorithm == "sha256":
|
||||
return f"{namespace}{hashlib.sha256(key.encode('utf-8')).hexdigest()}"
|
||||
if algorithm == "sha512":
|
||||
return f"{namespace}{hashlib.sha512(key.encode('utf-8')).hexdigest()}"
|
||||
msg = f"Unsupported algorithm: {algorithm}"
|
||||
raise ValueError(msg)
|
||||
|
||||
return _key_encoder
|
||||
|
||||
|
||||
def _value_serializer(value: Sequence[float]) -> bytes:
|
||||
"""Serialize a value."""
|
||||
return json.dumps(value).encode()
|
||||
|
||||
|
||||
def _value_deserializer(serialized_value: bytes) -> list[float]:
|
||||
"""Deserialize a value."""
|
||||
return cast("list[float]", json.loads(serialized_value.decode()))
|
||||
|
||||
|
||||
# The warning is global; track emission, so it appears only once.
|
||||
_warned_about_sha1: bool = False
|
||||
|
||||
|
||||
def _warn_about_sha1_encoder() -> None:
|
||||
"""Emit a one-time warning about SHA-1 collision weaknesses."""
|
||||
global _warned_about_sha1 # noqa: PLW0603
|
||||
if not _warned_about_sha1:
|
||||
warnings.warn(
|
||||
"Using default key encoder: SHA-1 is *not* collision-resistant. "
|
||||
"While acceptable for most cache scenarios, a motivated attacker "
|
||||
"can craft two different payloads that map to the same cache key. "
|
||||
"If that risk matters in your environment, supply a stronger "
|
||||
"encoder (e.g. SHA-256 or BLAKE2) via the `key_encoder` argument. "
|
||||
"If you change the key encoder, consider also creating a new cache, "
|
||||
"to avoid (the potential for) collisions with existing keys.",
|
||||
category=UserWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
_warned_about_sha1 = True
|
||||
|
||||
|
||||
class CacheBackedEmbeddings(Embeddings):
|
||||
"""Interface for caching results from embedding models.
|
||||
|
||||
The interface allows works with any store that implements
|
||||
the abstract store interface accepting keys of type str and values of list of
|
||||
floats.
|
||||
|
||||
If need be, the interface can be extended to accept other implementations
|
||||
of the value serializer and deserializer, as well as the key encoder.
|
||||
|
||||
Note that by default only document embeddings are cached. To cache query
|
||||
embeddings too, pass in a query_embedding_store to constructor.
|
||||
|
||||
Examples:
|
||||
```python
|
||||
from langchain_classic.embeddings import CacheBackedEmbeddings
|
||||
from langchain_classic.storage import LocalFileStore
|
||||
from langchain_openai import OpenAIEmbeddings
|
||||
|
||||
store = LocalFileStore("./my_cache")
|
||||
|
||||
underlying_embedder = OpenAIEmbeddings()
|
||||
embedder = CacheBackedEmbeddings.from_bytes_store(
|
||||
underlying_embedder, store, namespace=underlying_embedder.model
|
||||
)
|
||||
|
||||
# Embedding is computed and cached
|
||||
embeddings = embedder.embed_documents(["hello", "goodbye"])
|
||||
|
||||
# Embeddings are retrieved from the cache, no computation is done
|
||||
embeddings = embedder.embed_documents(["hello", "goodbye"])
|
||||
```
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
underlying_embeddings: Embeddings,
|
||||
document_embedding_store: BaseStore[str, list[float]],
|
||||
*,
|
||||
batch_size: int | None = None,
|
||||
query_embedding_store: BaseStore[str, list[float]] | None = None,
|
||||
) -> None:
|
||||
"""Initialize the embedder.
|
||||
|
||||
Args:
|
||||
underlying_embeddings: the embedder to use for computing embeddings.
|
||||
document_embedding_store: The store to use for caching document embeddings.
|
||||
batch_size: The number of documents to embed between store updates.
|
||||
query_embedding_store: The store to use for caching query embeddings.
|
||||
If `None`, query embeddings are not cached.
|
||||
"""
|
||||
super().__init__()
|
||||
self.document_embedding_store = document_embedding_store
|
||||
self.query_embedding_store = query_embedding_store
|
||||
self.underlying_embeddings = underlying_embeddings
|
||||
self.batch_size = batch_size
|
||||
|
||||
def embed_documents(self, texts: list[str]) -> list[list[float]]:
|
||||
"""Embed a list of texts.
|
||||
|
||||
The method first checks the cache for the embeddings.
|
||||
If the embeddings are not found, the method uses the underlying embedder
|
||||
to embed the documents and stores the results in the cache.
|
||||
|
||||
Args:
|
||||
texts: A list of texts to embed.
|
||||
|
||||
Returns:
|
||||
A list of embeddings for the given texts.
|
||||
"""
|
||||
vectors: list[list[float] | None] = self.document_embedding_store.mget(
|
||||
texts,
|
||||
)
|
||||
all_missing_indices: list[int] = [
|
||||
i for i, vector in enumerate(vectors) if vector is None
|
||||
]
|
||||
|
||||
for missing_indices in batch_iterate(self.batch_size, all_missing_indices):
|
||||
missing_texts = [texts[i] for i in missing_indices]
|
||||
missing_vectors = self.underlying_embeddings.embed_documents(missing_texts)
|
||||
self.document_embedding_store.mset(
|
||||
list(zip(missing_texts, missing_vectors, strict=False)),
|
||||
)
|
||||
for index, updated_vector in zip(
|
||||
missing_indices, missing_vectors, strict=False
|
||||
):
|
||||
vectors[index] = updated_vector
|
||||
|
||||
return cast(
|
||||
"list[list[float]]",
|
||||
vectors,
|
||||
) # Nones should have been resolved by now
|
||||
|
||||
async def aembed_documents(self, texts: list[str]) -> list[list[float]]:
|
||||
"""Embed a list of texts.
|
||||
|
||||
The method first checks the cache for the embeddings.
|
||||
If the embeddings are not found, the method uses the underlying embedder
|
||||
to embed the documents and stores the results in the cache.
|
||||
|
||||
Args:
|
||||
texts: A list of texts to embed.
|
||||
|
||||
Returns:
|
||||
A list of embeddings for the given texts.
|
||||
"""
|
||||
vectors: list[list[float] | None] = await self.document_embedding_store.amget(
|
||||
texts
|
||||
)
|
||||
all_missing_indices: list[int] = [
|
||||
i for i, vector in enumerate(vectors) if vector is None
|
||||
]
|
||||
|
||||
# batch_iterate supports None batch_size which returns all elements at once
|
||||
# as a single batch.
|
||||
for missing_indices in batch_iterate(self.batch_size, all_missing_indices):
|
||||
missing_texts = [texts[i] for i in missing_indices]
|
||||
missing_vectors = await self.underlying_embeddings.aembed_documents(
|
||||
missing_texts,
|
||||
)
|
||||
await self.document_embedding_store.amset(
|
||||
list(zip(missing_texts, missing_vectors, strict=False)),
|
||||
)
|
||||
for index, updated_vector in zip(
|
||||
missing_indices, missing_vectors, strict=False
|
||||
):
|
||||
vectors[index] = updated_vector
|
||||
|
||||
return cast(
|
||||
"list[list[float]]",
|
||||
vectors,
|
||||
) # Nones should have been resolved by now
|
||||
|
||||
def embed_query(self, text: str) -> list[float]:
|
||||
"""Embed query text.
|
||||
|
||||
By default, this method does not cache queries. To enable caching, set the
|
||||
`cache_query` parameter to `True` when initializing the embedder.
|
||||
|
||||
Args:
|
||||
text: The text to embed.
|
||||
|
||||
Returns:
|
||||
The embedding for the given text.
|
||||
"""
|
||||
if not self.query_embedding_store:
|
||||
return self.underlying_embeddings.embed_query(text)
|
||||
|
||||
(cached,) = self.query_embedding_store.mget([text])
|
||||
if cached is not None:
|
||||
return cached
|
||||
|
||||
vector = self.underlying_embeddings.embed_query(text)
|
||||
self.query_embedding_store.mset([(text, vector)])
|
||||
return vector
|
||||
|
||||
async def aembed_query(self, text: str) -> list[float]:
|
||||
"""Embed query text.
|
||||
|
||||
By default, this method does not cache queries. To enable caching, set the
|
||||
`cache_query` parameter to `True` when initializing the embedder.
|
||||
|
||||
Args:
|
||||
text: The text to embed.
|
||||
|
||||
Returns:
|
||||
The embedding for the given text.
|
||||
"""
|
||||
if not self.query_embedding_store:
|
||||
return await self.underlying_embeddings.aembed_query(text)
|
||||
|
||||
(cached,) = await self.query_embedding_store.amget([text])
|
||||
if cached is not None:
|
||||
return cached
|
||||
|
||||
vector = await self.underlying_embeddings.aembed_query(text)
|
||||
await self.query_embedding_store.amset([(text, vector)])
|
||||
return vector
|
||||
|
||||
@classmethod
|
||||
def from_bytes_store(
|
||||
cls,
|
||||
underlying_embeddings: Embeddings,
|
||||
document_embedding_cache: ByteStore,
|
||||
*,
|
||||
namespace: str = "",
|
||||
batch_size: int | None = None,
|
||||
query_embedding_cache: bool | ByteStore = False,
|
||||
key_encoder: Callable[[str], str]
|
||||
| Literal["sha1", "blake2b", "sha256", "sha512"] = "sha1",
|
||||
) -> CacheBackedEmbeddings:
|
||||
"""On-ramp that adds the necessary serialization and encoding to the store.
|
||||
|
||||
Args:
|
||||
underlying_embeddings: The embedder to use for embedding.
|
||||
document_embedding_cache: The cache to use for storing document embeddings.
|
||||
*,
|
||||
namespace: The namespace to use for document cache.
|
||||
This namespace is used to avoid collisions with other caches.
|
||||
For example, set it to the name of the embedding model used.
|
||||
batch_size: The number of documents to embed between store updates.
|
||||
query_embedding_cache: The cache to use for storing query embeddings.
|
||||
True to use the same cache as document embeddings.
|
||||
False to not cache query embeddings.
|
||||
key_encoder: Optional callable to encode keys. If not provided,
|
||||
a default encoder using SHA-1 will be used. SHA-1 is not
|
||||
collision-resistant, and a motivated attacker could craft two
|
||||
different texts that hash to the same cache key.
|
||||
|
||||
New applications should use one of the alternative encoders
|
||||
or provide a custom and strong key encoder function to avoid this risk.
|
||||
|
||||
If you change a key encoder in an existing cache, consider
|
||||
just creating a new cache, to avoid (the potential for)
|
||||
collisions with existing keys or having duplicate keys
|
||||
for the same text in the cache.
|
||||
|
||||
Returns:
|
||||
An instance of CacheBackedEmbeddings that uses the provided cache.
|
||||
"""
|
||||
if isinstance(key_encoder, str):
|
||||
key_encoder = _make_default_key_encoder(namespace, key_encoder)
|
||||
elif callable(key_encoder):
|
||||
# If a custom key encoder is provided, it should not be used with a
|
||||
# namespace.
|
||||
# A user can handle namespacing in directly their custom key encoder.
|
||||
if namespace:
|
||||
msg = (
|
||||
"Do not supply `namespace` when using a custom key_encoder; "
|
||||
"add any prefixing inside the encoder itself."
|
||||
)
|
||||
raise ValueError(msg)
|
||||
else:
|
||||
msg = ( # type: ignore[unreachable]
|
||||
"key_encoder must be either 'blake2b', 'sha1', 'sha256', 'sha512' "
|
||||
"or a callable that encodes keys."
|
||||
)
|
||||
raise ValueError(msg) # noqa: TRY004
|
||||
|
||||
document_embedding_store = EncoderBackedStore[str, list[float]](
|
||||
document_embedding_cache,
|
||||
key_encoder,
|
||||
_value_serializer,
|
||||
_value_deserializer,
|
||||
)
|
||||
if query_embedding_cache is True:
|
||||
query_embedding_store = document_embedding_store
|
||||
elif query_embedding_cache is False:
|
||||
query_embedding_store = None
|
||||
else:
|
||||
query_embedding_store = EncoderBackedStore[str, list[float]](
|
||||
query_embedding_cache,
|
||||
key_encoder,
|
||||
_value_serializer,
|
||||
_value_deserializer,
|
||||
)
|
||||
|
||||
return cls(
|
||||
underlying_embeddings,
|
||||
document_embedding_store,
|
||||
batch_size=batch_size,
|
||||
query_embedding_store=query_embedding_store,
|
||||
)
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import ClarifaiEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"ClarifaiEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"ClarifaiEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,29 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings.cloudflare_workersai import (
|
||||
CloudflareWorkersAIEmbeddings,
|
||||
)
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {
|
||||
"CloudflareWorkersAIEmbeddings": (
|
||||
"langchain_community.embeddings.cloudflare_workersai"
|
||||
),
|
||||
}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"CloudflareWorkersAIEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import CohereEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"CohereEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"CohereEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import DashScopeEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"DashScopeEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"DashScopeEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import DatabricksEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"DatabricksEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"DatabricksEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import DeepInfraEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"DeepInfraEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"DeepInfraEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import EdenAiEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"EdenAiEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"EdenAiEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import ElasticsearchEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"ElasticsearchEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"ElasticsearchEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import EmbaasEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"EmbaasEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"EmbaasEmbeddings",
|
||||
]
|
||||
23
venv/Lib/site-packages/langchain_classic/embeddings/ernie.py
Normal file
23
venv/Lib/site-packages/langchain_classic/embeddings/ernie.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import ErnieEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"ErnieEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"ErnieEmbeddings",
|
||||
]
|
||||
30
venv/Lib/site-packages/langchain_classic/embeddings/fake.py
Normal file
30
venv/Lib/site-packages/langchain_classic/embeddings/fake.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import (
|
||||
DeterministicFakeEmbedding,
|
||||
FakeEmbeddings,
|
||||
)
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {
|
||||
"FakeEmbeddings": "langchain_community.embeddings",
|
||||
"DeterministicFakeEmbedding": "langchain_community.embeddings",
|
||||
}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"DeterministicFakeEmbedding",
|
||||
"FakeEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import FastEmbedEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"FastEmbedEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"FastEmbedEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import GooglePalmEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"GooglePalmEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"GooglePalmEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import GPT4AllEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"GPT4AllEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"GPT4AllEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import GradientEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"GradientEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"GradientEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,36 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import (
|
||||
HuggingFaceBgeEmbeddings,
|
||||
HuggingFaceEmbeddings,
|
||||
HuggingFaceInferenceAPIEmbeddings,
|
||||
HuggingFaceInstructEmbeddings,
|
||||
)
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {
|
||||
"HuggingFaceEmbeddings": "langchain_community.embeddings",
|
||||
"HuggingFaceInstructEmbeddings": "langchain_community.embeddings",
|
||||
"HuggingFaceBgeEmbeddings": "langchain_community.embeddings",
|
||||
"HuggingFaceInferenceAPIEmbeddings": "langchain_community.embeddings",
|
||||
}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"HuggingFaceBgeEmbeddings",
|
||||
"HuggingFaceEmbeddings",
|
||||
"HuggingFaceInferenceAPIEmbeddings",
|
||||
"HuggingFaceInstructEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import HuggingFaceHubEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"HuggingFaceHubEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"HuggingFaceHubEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,30 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import InfinityEmbeddings
|
||||
from langchain_community.embeddings.infinity import (
|
||||
TinyAsyncOpenAIInfinityEmbeddingClient,
|
||||
)
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {
|
||||
"InfinityEmbeddings": "langchain_community.embeddings",
|
||||
"TinyAsyncOpenAIInfinityEmbeddingClient": "langchain_community.embeddings.infinity",
|
||||
}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"InfinityEmbeddings",
|
||||
"TinyAsyncOpenAIInfinityEmbeddingClient",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import JavelinAIGatewayEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"JavelinAIGatewayEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"JavelinAIGatewayEmbeddings",
|
||||
]
|
||||
23
venv/Lib/site-packages/langchain_classic/embeddings/jina.py
Normal file
23
venv/Lib/site-packages/langchain_classic/embeddings/jina.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import JinaEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"JinaEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"JinaEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import JohnSnowLabsEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"JohnSnowLabsEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"JohnSnowLabsEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import LlamaCppEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"LlamaCppEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"LlamaCppEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import LLMRailsEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"LLMRailsEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"LLMRailsEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import LocalAIEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"LocalAIEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"LocalAIEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import MiniMaxEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"MiniMaxEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"MiniMaxEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import MlflowEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"MlflowEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"MlflowEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import MlflowAIGatewayEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"MlflowAIGatewayEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"MlflowAIGatewayEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import ModelScopeEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"ModelScopeEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"ModelScopeEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import MosaicMLInstructorEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"MosaicMLInstructorEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"MosaicMLInstructorEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import NLPCloudEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"NLPCloudEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"NLPCloudEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import OctoAIEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"OctoAIEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"OctoAIEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import OllamaEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"OllamaEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"OllamaEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import OpenAIEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"OpenAIEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"OpenAIEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,30 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import SagemakerEndpointEmbeddings
|
||||
from langchain_community.embeddings.sagemaker_endpoint import (
|
||||
EmbeddingsContentHandler,
|
||||
)
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {
|
||||
"EmbeddingsContentHandler": "langchain_community.embeddings.sagemaker_endpoint",
|
||||
"SagemakerEndpointEmbeddings": "langchain_community.embeddings",
|
||||
}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"EmbeddingsContentHandler",
|
||||
"SagemakerEndpointEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import SelfHostedEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"SelfHostedEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"SelfHostedEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,30 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import (
|
||||
SelfHostedHuggingFaceEmbeddings,
|
||||
SelfHostedHuggingFaceInstructEmbeddings,
|
||||
)
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {
|
||||
"SelfHostedHuggingFaceEmbeddings": "langchain_community.embeddings",
|
||||
"SelfHostedHuggingFaceInstructEmbeddings": "langchain_community.embeddings",
|
||||
}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"SelfHostedHuggingFaceEmbeddings",
|
||||
"SelfHostedHuggingFaceInstructEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,21 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import SentenceTransformerEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"SentenceTransformerEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = ["SentenceTransformerEmbeddings"]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import SpacyEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"SpacyEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"SpacyEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import TensorflowHubEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"TensorflowHubEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"TensorflowHubEmbeddings",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from langchain_classic._api import create_importer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_community.embeddings import VertexAIEmbeddings
|
||||
|
||||
# Create a way to dynamically look up deprecated imports.
|
||||
# Used to consolidate logic for raising deprecation warnings and
|
||||
# handling optional imports.
|
||||
DEPRECATED_LOOKUP = {"VertexAIEmbeddings": "langchain_community.embeddings"}
|
||||
|
||||
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
"""Look up attributes dynamically."""
|
||||
return _import_attribute(name)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"VertexAIEmbeddings",
|
||||
]
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user