|
11 | 11 | """ |
12 | 12 |
|
13 | 13 |
|
| 14 | +import importlib |
14 | 15 | import logging |
15 | 16 | from typing import Any |
16 | 17 |
|
17 | | -from langchain_community.embeddings.aleph_alpha import ( |
18 | | - AlephAlphaAsymmetricSemanticEmbedding, |
19 | | - AlephAlphaSymmetricSemanticEmbedding, |
20 | | -) |
21 | | -from langchain_community.embeddings.awa import AwaEmbeddings |
22 | | -from langchain_community.embeddings.azure_openai import AzureOpenAIEmbeddings |
23 | | -from langchain_community.embeddings.baichuan import BaichuanTextEmbeddings |
24 | | -from langchain_community.embeddings.baidu_qianfan_endpoint import ( |
25 | | - QianfanEmbeddingsEndpoint, |
26 | | -) |
27 | | -from langchain_community.embeddings.bedrock import BedrockEmbeddings |
28 | | -from langchain_community.embeddings.bookend import BookendEmbeddings |
29 | | -from langchain_community.embeddings.clarifai import ClarifaiEmbeddings |
30 | | -from langchain_community.embeddings.cohere import CohereEmbeddings |
31 | | -from langchain_community.embeddings.dashscope import DashScopeEmbeddings |
32 | | -from langchain_community.embeddings.databricks import DatabricksEmbeddings |
33 | | -from langchain_community.embeddings.deepinfra import DeepInfraEmbeddings |
34 | | -from langchain_community.embeddings.edenai import EdenAiEmbeddings |
35 | | -from langchain_community.embeddings.elasticsearch import ElasticsearchEmbeddings |
36 | | -from langchain_community.embeddings.embaas import EmbaasEmbeddings |
37 | | -from langchain_community.embeddings.ernie import ErnieEmbeddings |
38 | | -from langchain_community.embeddings.fake import ( |
39 | | - DeterministicFakeEmbedding, |
40 | | - FakeEmbeddings, |
41 | | -) |
42 | | -from langchain_community.embeddings.fastembed import FastEmbedEmbeddings |
43 | | -from langchain_community.embeddings.google_palm import GooglePalmEmbeddings |
44 | | -from langchain_community.embeddings.gpt4all import GPT4AllEmbeddings |
45 | | -from langchain_community.embeddings.gradient_ai import GradientEmbeddings |
46 | | -from langchain_community.embeddings.huggingface import ( |
47 | | - HuggingFaceBgeEmbeddings, |
48 | | - HuggingFaceEmbeddings, |
49 | | - HuggingFaceInferenceAPIEmbeddings, |
50 | | - HuggingFaceInstructEmbeddings, |
51 | | -) |
52 | | -from langchain_community.embeddings.huggingface_hub import HuggingFaceHubEmbeddings |
53 | | -from langchain_community.embeddings.infinity import InfinityEmbeddings |
54 | | -from langchain_community.embeddings.infinity_local import InfinityEmbeddingsLocal |
55 | | -from langchain_community.embeddings.javelin_ai_gateway import JavelinAIGatewayEmbeddings |
56 | | -from langchain_community.embeddings.jina import JinaEmbeddings |
57 | | -from langchain_community.embeddings.johnsnowlabs import JohnSnowLabsEmbeddings |
58 | | -from langchain_community.embeddings.laser import LaserEmbeddings |
59 | | -from langchain_community.embeddings.llamacpp import LlamaCppEmbeddings |
60 | | -from langchain_community.embeddings.llamafile import LlamafileEmbeddings |
61 | | -from langchain_community.embeddings.llm_rails import LLMRailsEmbeddings |
62 | | -from langchain_community.embeddings.localai import LocalAIEmbeddings |
63 | | -from langchain_community.embeddings.minimax import MiniMaxEmbeddings |
64 | | -from langchain_community.embeddings.mlflow import ( |
65 | | - MlflowCohereEmbeddings, |
66 | | - MlflowEmbeddings, |
67 | | -) |
68 | | -from langchain_community.embeddings.mlflow_gateway import MlflowAIGatewayEmbeddings |
69 | | -from langchain_community.embeddings.modelscope_hub import ModelScopeEmbeddings |
70 | | -from langchain_community.embeddings.mosaicml import MosaicMLInstructorEmbeddings |
71 | | -from langchain_community.embeddings.nemo import NeMoEmbeddings |
72 | | -from langchain_community.embeddings.nlpcloud import NLPCloudEmbeddings |
73 | | -from langchain_community.embeddings.oci_generative_ai import OCIGenAIEmbeddings |
74 | | -from langchain_community.embeddings.octoai_embeddings import OctoAIEmbeddings |
75 | | -from langchain_community.embeddings.ollama import OllamaEmbeddings |
76 | | -from langchain_community.embeddings.openai import OpenAIEmbeddings |
77 | | -from langchain_community.embeddings.optimum_intel import QuantizedBiEncoderEmbeddings |
78 | | -from langchain_community.embeddings.sagemaker_endpoint import ( |
79 | | - SagemakerEndpointEmbeddings, |
80 | | -) |
81 | | -from langchain_community.embeddings.self_hosted import SelfHostedEmbeddings |
82 | | -from langchain_community.embeddings.self_hosted_hugging_face import ( |
83 | | - SelfHostedHuggingFaceEmbeddings, |
84 | | - SelfHostedHuggingFaceInstructEmbeddings, |
85 | | -) |
86 | | -from langchain_community.embeddings.sentence_transformer import ( |
87 | | - SentenceTransformerEmbeddings, |
88 | | -) |
89 | | -from langchain_community.embeddings.spacy_embeddings import SpacyEmbeddings |
90 | | -from langchain_community.embeddings.sparkllm import SparkLLMTextEmbeddings |
91 | | -from langchain_community.embeddings.tensorflow_hub import TensorflowHubEmbeddings |
92 | | -from langchain_community.embeddings.vertexai import VertexAIEmbeddings |
93 | | -from langchain_community.embeddings.volcengine import VolcanoEmbeddings |
94 | | -from langchain_community.embeddings.voyageai import VoyageEmbeddings |
95 | | -from langchain_community.embeddings.xinference import XinferenceEmbeddings |
| 18 | +_module_lookup = { |
| 19 | + "AlephAlphaAsymmetricSemanticEmbedding": "langchain_community.embeddings.aleph_alpha", # noqa: E501 |
| 20 | + "AlephAlphaSymmetricSemanticEmbedding": "langchain_community.embeddings.aleph_alpha", # noqa: E501 |
| 21 | + "AwaEmbeddings": "langchain_community.embeddings.awa", |
| 22 | + "AzureOpenAIEmbeddings": "langchain_community.embeddings.azure_openai", |
| 23 | + "BaichuanTextEmbeddings": "langchain_community.embeddings.baichuan", |
| 24 | + "BedrockEmbeddings": "langchain_community.embeddings.bedrock", |
| 25 | + "BookendEmbeddings": "langchain_community.embeddings.bookend", |
| 26 | + "ClarifaiEmbeddings": "langchain_community.embeddings.clarifai", |
| 27 | + "CohereEmbeddings": "langchain_community.embeddings.cohere", |
| 28 | + "DashScopeEmbeddings": "langchain_community.embeddings.dashscope", |
| 29 | + "DatabricksEmbeddings": "langchain_community.embeddings.databricks", |
| 30 | + "DeepInfraEmbeddings": "langchain_community.embeddings.deepinfra", |
| 31 | + "DeterministicFakeEmbedding": "langchain_community.embeddings.fake", |
| 32 | + "EdenAiEmbeddings": "langchain_community.embeddings.edenai", |
| 33 | + "ElasticsearchEmbeddings": "langchain_community.embeddings.elasticsearch", |
| 34 | + "EmbaasEmbeddings": "langchain_community.embeddings.embaas", |
| 35 | + "ErnieEmbeddings": "langchain_community.embeddings.ernie", |
| 36 | + "FakeEmbeddings": "langchain_community.embeddings.fake", |
| 37 | + "FastEmbedEmbeddings": "langchain_community.embeddings.fastembed", |
| 38 | + "GPT4AllEmbeddings": "langchain_community.embeddings.gpt4all", |
| 39 | + "GooglePalmEmbeddings": "langchain_community.embeddings.google_palm", |
| 40 | + "GradientEmbeddings": "langchain_community.embeddings.gradient_ai", |
| 41 | + "HuggingFaceBgeEmbeddings": "langchain_community.embeddings.huggingface", |
| 42 | + "HuggingFaceEmbeddings": "langchain_community.embeddings.huggingface", |
| 43 | + "HuggingFaceHubEmbeddings": "langchain_community.embeddings.huggingface_hub", |
| 44 | + "HuggingFaceInferenceAPIEmbeddings": "langchain_community.embeddings.huggingface", |
| 45 | + "HuggingFaceInstructEmbeddings": "langchain_community.embeddings.huggingface", |
| 46 | + "InfinityEmbeddings": "langchain_community.embeddings.infinity", |
| 47 | + "InfinityEmbeddingsLocal": "langchain_community.embeddings.infinity_local", |
| 48 | + "JavelinAIGatewayEmbeddings": "langchain_community.embeddings.javelin_ai_gateway", |
| 49 | + "JinaEmbeddings": "langchain_community.embeddings.jina", |
| 50 | + "JohnSnowLabsEmbeddings": "langchain_community.embeddings.johnsnowlabs", |
| 51 | + "LLMRailsEmbeddings": "langchain_community.embeddings.llm_rails", |
| 52 | + "LaserEmbeddings": "langchain_community.embeddings.laser", |
| 53 | + "LlamaCppEmbeddings": "langchain_community.embeddings.llamacpp", |
| 54 | + "LlamafileEmbeddings": "langchain_community.embeddings.llamafile", |
| 55 | + "LocalAIEmbeddings": "langchain_community.embeddings.localai", |
| 56 | + "MiniMaxEmbeddings": "langchain_community.embeddings.minimax", |
| 57 | + "MlflowAIGatewayEmbeddings": "langchain_community.embeddings.mlflow_gateway", |
| 58 | + "MlflowCohereEmbeddings": "langchain_community.embeddings.mlflow", |
| 59 | + "MlflowEmbeddings": "langchain_community.embeddings.mlflow", |
| 60 | + "ModelScopeEmbeddings": "langchain_community.embeddings.modelscope_hub", |
| 61 | + "MosaicMLInstructorEmbeddings": "langchain_community.embeddings.mosaicml", |
| 62 | + "NLPCloudEmbeddings": "langchain_community.embeddings.nlpcloud", |
| 63 | + "NeMoEmbeddings": "langchain_community.embeddings.nemo", |
| 64 | + "OCIGenAIEmbeddings": "langchain_community.embeddings.oci_generative_ai", |
| 65 | + "OctoAIEmbeddings": "langchain_community.embeddings.octoai_embeddings", |
| 66 | + "OllamaEmbeddings": "langchain_community.embeddings.ollama", |
| 67 | + "OpenAIEmbeddings": "langchain_community.embeddings.openai", |
| 68 | + "QianfanEmbeddingsEndpoint": "langchain_community.embeddings.baidu_qianfan_endpoint", # noqa: E501 |
| 69 | + "QuantizedBiEncoderEmbeddings": "langchain_community.embeddings.optimum_intel", |
| 70 | + "SagemakerEndpointEmbeddings": "langchain_community.embeddings.sagemaker_endpoint", |
| 71 | + "SelfHostedEmbeddings": "langchain_community.embeddings.self_hosted", |
| 72 | + "SelfHostedHuggingFaceEmbeddings": "langchain_community.embeddings.self_hosted_hugging_face", # noqa: E501 |
| 73 | + "SelfHostedHuggingFaceInstructEmbeddings": "langchain_community.embeddings.self_hosted_hugging_face", # noqa: E501 |
| 74 | + "SentenceTransformerEmbeddings": "langchain_community.embeddings.sentence_transformer", # noqa: E501 |
| 75 | + "SpacyEmbeddings": "langchain_community.embeddings.spacy_embeddings", |
| 76 | + "SparkLLMTextEmbeddings": "langchain_community.embeddings.sparkllm", |
| 77 | + "TensorflowHubEmbeddings": "langchain_community.embeddings.tensorflow_hub", |
| 78 | + "VertexAIEmbeddings": "langchain_community.embeddings.vertexai", |
| 79 | + "VolcanoEmbeddings": "langchain_community.embeddings.volcengine", |
| 80 | + "VoyageEmbeddings": "langchain_community.embeddings.voyageai", |
| 81 | + "XinferenceEmbeddings": "langchain_community.embeddings.xinference", |
| 82 | +} |
| 83 | + |
| 84 | + |
| 85 | +def __getattr__(name: str) -> Any: |
| 86 | + if name in _module_lookup: |
| 87 | + module = importlib.import_module(_module_lookup[name]) |
| 88 | + return getattr(module, name) |
| 89 | + raise AttributeError(f"module {__name__} has no attribute {name}") |
96 | 90 |
|
97 | | -logger = logging.getLogger(__name__) |
98 | 91 |
|
99 | | -__all__ = [ |
100 | | - "OpenAIEmbeddings", |
101 | | - "AzureOpenAIEmbeddings", |
102 | | - "BaichuanTextEmbeddings", |
103 | | - "ClarifaiEmbeddings", |
104 | | - "CohereEmbeddings", |
105 | | - "DatabricksEmbeddings", |
106 | | - "ElasticsearchEmbeddings", |
107 | | - "FastEmbedEmbeddings", |
108 | | - "HuggingFaceEmbeddings", |
109 | | - "HuggingFaceInferenceAPIEmbeddings", |
110 | | - "InfinityEmbeddings", |
111 | | - "InfinityEmbeddingsLocal", |
112 | | - "GradientEmbeddings", |
113 | | - "JinaEmbeddings", |
114 | | - "LaserEmbeddings", |
115 | | - "LlamaCppEmbeddings", |
116 | | - "LlamafileEmbeddings", |
117 | | - "LLMRailsEmbeddings", |
118 | | - "HuggingFaceHubEmbeddings", |
119 | | - "MlflowEmbeddings", |
120 | | - "MlflowCohereEmbeddings", |
121 | | - "MlflowAIGatewayEmbeddings", |
122 | | - "ModelScopeEmbeddings", |
123 | | - "TensorflowHubEmbeddings", |
124 | | - "SagemakerEndpointEmbeddings", |
125 | | - "HuggingFaceInstructEmbeddings", |
126 | | - "MosaicMLInstructorEmbeddings", |
127 | | - "SelfHostedEmbeddings", |
128 | | - "SelfHostedHuggingFaceEmbeddings", |
129 | | - "SelfHostedHuggingFaceInstructEmbeddings", |
130 | | - "FakeEmbeddings", |
131 | | - "DeterministicFakeEmbedding", |
132 | | - "AlephAlphaAsymmetricSemanticEmbedding", |
133 | | - "AlephAlphaSymmetricSemanticEmbedding", |
134 | | - "SentenceTransformerEmbeddings", |
135 | | - "GooglePalmEmbeddings", |
136 | | - "MiniMaxEmbeddings", |
137 | | - "VertexAIEmbeddings", |
138 | | - "BedrockEmbeddings", |
139 | | - "DeepInfraEmbeddings", |
140 | | - "EdenAiEmbeddings", |
141 | | - "DashScopeEmbeddings", |
142 | | - "EmbaasEmbeddings", |
143 | | - "OctoAIEmbeddings", |
144 | | - "SpacyEmbeddings", |
145 | | - "NLPCloudEmbeddings", |
146 | | - "GPT4AllEmbeddings", |
147 | | - "XinferenceEmbeddings", |
148 | | - "LocalAIEmbeddings", |
149 | | - "AwaEmbeddings", |
150 | | - "HuggingFaceBgeEmbeddings", |
151 | | - "ErnieEmbeddings", |
152 | | - "JavelinAIGatewayEmbeddings", |
153 | | - "OllamaEmbeddings", |
154 | | - "QianfanEmbeddingsEndpoint", |
155 | | - "JohnSnowLabsEmbeddings", |
156 | | - "VoyageEmbeddings", |
157 | | - "BookendEmbeddings", |
158 | | - "VolcanoEmbeddings", |
159 | | - "OCIGenAIEmbeddings", |
160 | | - "QuantizedBiEncoderEmbeddings", |
161 | | - "NeMoEmbeddings", |
162 | | - "SparkLLMTextEmbeddings", |
163 | | -] |
| 92 | +__all__ = list(_module_lookup.keys()) |
| 93 | + |
| 94 | +logger = logging.getLogger(__name__) |
164 | 95 |
|
165 | 96 |
|
166 | 97 | # TODO: this is in here to maintain backwards compatibility |
|
0 commit comments