mirror of
https://github.com/hwchase17/langchain.git
synced 2026-04-14 16:39:11 +00:00
Compare commits
7 Commits
langchain-
...
erick/docs
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
024e8c2e0a | ||
|
|
66a3737a47 | ||
|
|
011a69e1cb | ||
|
|
233a5964b1 | ||
|
|
7202ce68c5 | ||
|
|
0bd2db6e83 | ||
|
|
36886e005d |
27
docs/docs/integrations/llms/index.mdx
Normal file
27
docs/docs/integrations/llms/index.mdx
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
sidebar_class_name: hidden
|
||||
keywords: [compatibility]
|
||||
custom_edit_url:
|
||||
---
|
||||
|
||||
# LLMs
|
||||
|
||||
:::info
|
||||
|
||||
If you'd like to write your own LLM, see [this how-to](/docs/how_to/custom_llm/).
|
||||
If you'd like to contribute an integration, see [Contributing integrations](/docs/contributing/integrations/).
|
||||
|
||||
:::
|
||||
|
||||
## Features (natively supported)
|
||||
All LLMs implement the Runnable interface, which comes with default implementations of all methods, ie. `ainvoke`, `batch`, `abatch`, `stream`, `astream`. This gives all LLMs basic support for async, streaming and batch, which by default is implemented as below:
|
||||
- *Async* support defaults to calling the respective sync method in asyncio's default thread pool executor. This lets other async functions in your application make progress while the LLM is being executed, by moving this call to a background thread.
|
||||
- *Streaming* support defaults to returning an `Iterator` (or `AsyncIterator` in the case of async streaming) of a single value, the final result returned by the underlying LLM provider. This obviously doesn't give you token-by-token streaming, which requires native support from the LLM provider, but ensures your code that expects an iterator of tokens can work for any of our LLM integrations.
|
||||
- *Batch* support defaults to calling the underlying LLM in parallel for each input by making use of a thread pool executor (in the sync batch case) or `asyncio.gather` (in the async batch case). The concurrency can be controlled with the `max_concurrency` key in `RunnableConfig`.
|
||||
|
||||
Each LLM integration can optionally provide native implementations for async, streaming or batch, which, for providers that support it, can be more efficient. The table shows, for each integration, which features have been implemented with native support.
|
||||
|
||||
import { CategoryTable } from '@theme/FeatureTables';
|
||||
|
||||
<CategoryTable category="llms" />
|
||||
@@ -7,108 +7,6 @@ sidebar_class_name: hidden
|
||||
|
||||
**Embedding model** classes are implemented by inheriting the [Embeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_core.embeddings.Embeddings.html) class.
|
||||
|
||||
This table lists all 100 derived classes.
|
||||
import { CategoryTable } from '@theme/FeatureTables';
|
||||
|
||||
|
||||
| Namespace 🔻 | Class |
|
||||
|------------|---------|
|
||||
| langchain.chains.hyde.base | [HypotheticalDocumentEmbedder](https://api.python.langchain.com/en/latest/chains/langchain.chains.hyde.base.HypotheticalDocumentEmbedder.html) |
|
||||
| langchain.embeddings.cache | [CacheBackedEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain.embeddings.cache.CacheBackedEmbeddings.html) |
|
||||
| langchain_ai21.embeddings | [AI21Embeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_ai21.embeddings.AI21Embeddings.html) |
|
||||
| langchain_aws.embeddings.bedrock | [BedrockEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_aws.embeddings.bedrock.BedrockEmbeddings.html) |
|
||||
| langchain_cohere.embeddings | [CohereEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_cohere.embeddings.CohereEmbeddings.html) |
|
||||
| langchain_community.embeddings.aleph_alpha | [AlephAlphaAsymmetricSemanticEmbedding](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.aleph_alpha.AlephAlphaAsymmetricSemanticEmbedding.html) |
|
||||
| langchain_community.embeddings.aleph_alpha | [AlephAlphaSymmetricSemanticEmbedding](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.aleph_alpha.AlephAlphaSymmetricSemanticEmbedding.html) |
|
||||
| langchain_community.embeddings.anyscale | [AnyscaleEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.anyscale.AnyscaleEmbeddings.html) |
|
||||
| langchain_community.embeddings.awa | [AwaEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.awa.AwaEmbeddings.html) |
|
||||
| langchain_community.embeddings.azure_openai | [AzureOpenAIEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.azure_openai.AzureOpenAIEmbeddings.html) |
|
||||
| langchain_community.embeddings.baichuan | [BaichuanTextEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.baichuan.BaichuanTextEmbeddings.html) |
|
||||
| langchain_community.embeddings.baidu_qianfan_endpoint | [QianfanEmbeddingsEndpoint](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.baidu_qianfan_endpoint.QianfanEmbeddingsEndpoint.html) |
|
||||
| langchain_community.embeddings.bedrock | [BedrockEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.bedrock.BedrockEmbeddings.html) |
|
||||
| langchain_community.embeddings.bookend | [BookendEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.bookend.BookendEmbeddings.html) |
|
||||
| langchain_community.embeddings.clarifai | [ClarifaiEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.clarifai.ClarifaiEmbeddings.html) |
|
||||
| langchain_community.embeddings.cloudflare_workersai | [CloudflareWorkersAIEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.cloudflare_workersai.CloudflareWorkersAIEmbeddings.html) |
|
||||
| langchain_community.embeddings.clova | [ClovaEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.clova.ClovaEmbeddings.html) |
|
||||
| langchain_community.embeddings.cohere | [CohereEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.cohere.CohereEmbeddings.html) |
|
||||
| langchain_community.embeddings.dashscope | [DashScopeEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.dashscope.DashScopeEmbeddings.html) |
|
||||
| langchain_community.embeddings.databricks | [DatabricksEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.databricks.DatabricksEmbeddings.html) |
|
||||
| langchain_community.embeddings.deepinfra | [DeepInfraEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.deepinfra.DeepInfraEmbeddings.html) |
|
||||
| langchain_community.embeddings.edenai | [EdenAiEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.edenai.EdenAiEmbeddings.html) |
|
||||
| langchain_community.embeddings.elasticsearch | [ElasticsearchEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.elasticsearch.ElasticsearchEmbeddings.html) |
|
||||
| langchain_community.embeddings.embaas | [EmbaasEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.embaas.EmbaasEmbeddings.html) |
|
||||
| langchain_community.embeddings.ernie | [ErnieEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.ernie.ErnieEmbeddings.html) |
|
||||
| langchain_community.embeddings.fake | [DeterministicFakeEmbedding](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.fake.DeterministicFakeEmbedding.html) |
|
||||
| langchain_community.embeddings.fake | [FakeEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.fake.FakeEmbeddings.html) |
|
||||
| langchain_community.embeddings.fastembed | [FastEmbedEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.fastembed.FastEmbedEmbeddings.html) |
|
||||
| langchain_community.embeddings.gigachat | [GigaChatEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.gigachat.GigaChatEmbeddings.html) |
|
||||
| langchain_community.embeddings.google_palm | [GooglePalmEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.google_palm.GooglePalmEmbeddings.html) |
|
||||
| langchain_community.embeddings.gpt4all | [GPT4AllEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.gpt4all.GPT4AllEmbeddings.html) |
|
||||
| langchain_community.embeddings.gradient_ai | [GradientEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.gradient_ai.GradientEmbeddings.html) |
|
||||
| langchain_community.embeddings.huggingface | [HuggingFaceBgeEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.huggingface.HuggingFaceBgeEmbeddings.html) |
|
||||
| langchain_community.embeddings.huggingface | [HuggingFaceEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.huggingface.HuggingFaceEmbeddings.html) |
|
||||
| langchain_community.embeddings.huggingface | [HuggingFaceInferenceAPIEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.huggingface.HuggingFaceInferenceAPIEmbeddings.html) |
|
||||
| langchain_community.embeddings.huggingface | [HuggingFaceInstructEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.huggingface.HuggingFaceInstructEmbeddings.html) |
|
||||
| langchain_community.embeddings.huggingface_hub | [HuggingFaceHubEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.huggingface_hub.HuggingFaceHubEmbeddings.html) |
|
||||
| langchain_community.embeddings.infinity | [InfinityEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.infinity.InfinityEmbeddings.html) |
|
||||
| langchain_community.embeddings.infinity_local | [InfinityEmbeddingsLocal](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.infinity_local.InfinityEmbeddingsLocal.html) |
|
||||
| langchain_community.embeddings.ipex_llm | [IpexLLMBgeEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.ipex_llm.IpexLLMBgeEmbeddings.html) |
|
||||
| langchain_community.embeddings.itrex | [QuantizedBgeEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.itrex.QuantizedBgeEmbeddings.html) |
|
||||
| langchain_community.embeddings.javelin_ai_gateway | [JavelinAIGatewayEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.javelin_ai_gateway.JavelinAIGatewayEmbeddings.html) |
|
||||
| langchain_community.embeddings.jina | [JinaEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.jina.JinaEmbeddings.html) |
|
||||
| langchain_community.embeddings.johnsnowlabs | [JohnSnowLabsEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.johnsnowlabs.JohnSnowLabsEmbeddings.html) |
|
||||
| langchain_community.embeddings.laser | [LaserEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.laser.LaserEmbeddings.html) |
|
||||
| langchain_community.embeddings.llamacpp | [LlamaCppEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.llamacpp.LlamaCppEmbeddings.html) |
|
||||
| langchain_community.embeddings.llamafile | [LlamafileEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.llamafile.LlamafileEmbeddings.html) |
|
||||
| langchain_community.embeddings.llm_rails | [LLMRailsEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.llm_rails.LLMRailsEmbeddings.html) |
|
||||
| langchain_community.embeddings.localai | [LocalAIEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.localai.LocalAIEmbeddings.html) |
|
||||
| langchain_community.embeddings.minimax | [MiniMaxEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.minimax.MiniMaxEmbeddings.html) |
|
||||
| langchain_community.embeddings.mlflow | [MlflowCohereEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.mlflow.MlflowCohereEmbeddings.html) |
|
||||
| langchain_community.embeddings.mlflow | [MlflowEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.mlflow.MlflowEmbeddings.html) |
|
||||
| langchain_community.embeddings.mlflow_gateway | [MlflowAIGatewayEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.mlflow_gateway.MlflowAIGatewayEmbeddings.html) |
|
||||
| langchain_community.embeddings.modelscope_hub | [ModelScopeEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.modelscope_hub.ModelScopeEmbeddings.html) |
|
||||
| langchain_community.embeddings.mosaicml | [MosaicMLInstructorEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.mosaicml.MosaicMLInstructorEmbeddings.html) |
|
||||
| langchain_community.embeddings.nemo | [NeMoEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.nemo.NeMoEmbeddings.html) |
|
||||
| langchain_community.embeddings.nlpcloud | [NLPCloudEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.nlpcloud.NLPCloudEmbeddings.html) |
|
||||
| langchain_community.embeddings.oci_generative_ai | [OCIGenAIEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.oci_generative_ai.OCIGenAIEmbeddings.html) |
|
||||
| langchain_community.embeddings.octoai_embeddings | [OctoAIEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.octoai_embeddings.OctoAIEmbeddings.html) |
|
||||
| langchain_community.embeddings.ollama | [OllamaEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.ollama.OllamaEmbeddings.html) |
|
||||
| langchain_community.embeddings.openai | [OpenAIEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openai.OpenAIEmbeddings.html) |
|
||||
| langchain_community.embeddings.openvino | [OpenVINOBgeEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openvino.OpenVINOBgeEmbeddings.html) |
|
||||
| langchain_community.embeddings.openvino | [OpenVINOEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openvino.OpenVINOEmbeddings.html) |
|
||||
| langchain_community.embeddings.optimum_intel | [QuantizedBiEncoderEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.optimum_intel.QuantizedBiEncoderEmbeddings.html) |
|
||||
| langchain_community.embeddings.oracleai | [OracleEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.oracleai.OracleEmbeddings.html) |
|
||||
| langchain_community.embeddings.ovhcloud | [OVHCloudEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.ovhcloud.OVHCloudEmbeddings.html) |
|
||||
| langchain_community.embeddings.premai | [PremAIEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.premai.PremAIEmbeddings.html) |
|
||||
| langchain_community.embeddings.sagemaker_endpoint | [SagemakerEndpointEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.sagemaker_endpoint.SagemakerEndpointEmbeddings.html) |
|
||||
| langchain_community.embeddings.sambanova | [SambaStudioEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.sambanova.SambaStudioEmbeddings.html) |
|
||||
| langchain_community.embeddings.self_hosted | [SelfHostedEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted.SelfHostedEmbeddings.html) |
|
||||
| langchain_community.embeddings.self_hosted_hugging_face | [SelfHostedHuggingFaceEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings.html) |
|
||||
| langchain_community.embeddings.self_hosted_hugging_face | [SelfHostedHuggingFaceInstructEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceInstructEmbeddings.html) |
|
||||
| langchain_community.embeddings.solar | [SolarEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.solar.SolarEmbeddings.html) |
|
||||
| langchain_community.embeddings.spacy_embeddings | [SpacyEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.spacy_embeddings.SpacyEmbeddings.html) |
|
||||
| langchain_community.embeddings.sparkllm | [SparkLLMTextEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.sparkllm.SparkLLMTextEmbeddings.html) |
|
||||
| langchain_community.embeddings.tensorflow_hub | [TensorflowHubEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.tensorflow_hub.TensorflowHubEmbeddings.html) |
|
||||
| langchain_community.embeddings.text2vec | [Text2vecEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.text2vec.Text2vecEmbeddings.html) |
|
||||
| langchain_community.embeddings.titan_takeoff | [TitanTakeoffEmbed](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.titan_takeoff.TitanTakeoffEmbed.html) |
|
||||
| langchain_community.embeddings.vertexai | [VertexAIEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.vertexai.VertexAIEmbeddings.html) |
|
||||
| langchain_community.embeddings.volcengine | [VolcanoEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.volcengine.VolcanoEmbeddings.html) |
|
||||
| langchain_community.embeddings.voyageai | [VoyageEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.voyageai.VoyageEmbeddings.html) |
|
||||
| langchain_community.embeddings.xinference | [XinferenceEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.xinference.XinferenceEmbeddings.html) |
|
||||
| langchain_community.embeddings.yandex | [YandexGPTEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.yandex.YandexGPTEmbeddings.html) |
|
||||
| langchain_community.embeddings.zhipuai | [ZhipuAIEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.zhipuai.ZhipuAIEmbeddings.html) |
|
||||
| langchain_core.embeddings.fake | [DeterministicFakeEmbedding](https://api.python.langchain.com/en/latest/embeddings/langchain_core.embeddings.fake.DeterministicFakeEmbedding.html) |
|
||||
| langchain_core.embeddings.fake | [FakeEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_core.embeddings.fake.FakeEmbeddings.html) |
|
||||
| langchain_elasticsearch.embeddings | [ElasticsearchEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_elasticsearch.embeddings.ElasticsearchEmbeddings.html) |
|
||||
| langchain_fireworks.embeddings | [FireworksEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_fireworks.embeddings.FireworksEmbeddings.html) |
|
||||
| langchain_google_genai.embeddings | [GoogleGenerativeAIEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_google_genai.embeddings.GoogleGenerativeAIEmbeddings.html) |
|
||||
| langchain_google_genai.google_vector_store | [ServerSideEmbedding](https://api.python.langchain.com/en/latest/google_vector_store/langchain_google_genai.google_vector_store.ServerSideEmbedding.html) |
|
||||
| langchain_google_vertexai.embeddings | [VertexAIEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_google_vertexai.embeddings.VertexAIEmbeddings.html) |
|
||||
| langchain_huggingface.embeddings.huggingface | [HuggingFaceEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_huggingface.embeddings.huggingface.HuggingFaceEmbeddings.html) |
|
||||
| langchain_huggingface.embeddings.huggingface_endpoint | [HuggingFaceEndpointEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_huggingface.embeddings.huggingface_endpoint.HuggingFaceEndpointEmbeddings.html) |
|
||||
| langchain_ibm.embeddings | [WatsonxEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_ibm.embeddings.WatsonxEmbeddings.html) |
|
||||
| langchain_mistralai.embeddings | [MistralAIEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_mistralai.embeddings.MistralAIEmbeddings.html) |
|
||||
| langchain_nomic.embeddings | [NomicEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_nomic.embeddings.NomicEmbeddings.html) |
|
||||
| langchain_nvidia_ai_endpoints.embeddings | [NVIDIAEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_nvidia_ai_endpoints.embeddings.NVIDIAEmbeddings.html) |
|
||||
| langchain_together.embeddings | [TogetherEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_together.embeddings.TogetherEmbeddings.html) |
|
||||
| langchain_upstage.embeddings | [UpstageEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_upstage.embeddings.UpstageEmbeddings.html) |
|
||||
| langchain_voyageai.embeddings | [VoyageAIEmbeddings](https://api.python.langchain.com/en/latest/embeddings/langchain_voyageai.embeddings.VoyageAIEmbeddings.html) |
|
||||
<CategoryTable category="text_embedding" />
|
||||
|
||||
@@ -4,14 +4,6 @@ from pathlib import Path
|
||||
from langchain_community import llms
|
||||
from langchain_core.language_models.llms import LLM, BaseLLM
|
||||
|
||||
LLM_IGNORE = ("FakeListLLM", "OpenAIChat", "PromptLayerOpenAIChat")
|
||||
LLM_FEAT_TABLE_CORRECTION = {
|
||||
"TextGen": {"_astream": False, "_agenerate": False},
|
||||
"Ollama": {
|
||||
"_stream": False,
|
||||
},
|
||||
"PromptLayerOpenAI": {"batch_generate": False, "batch_agenerate": False},
|
||||
}
|
||||
CHAT_MODEL_IGNORE = ("FakeListChatModel", "HumanInputChatModel")
|
||||
|
||||
CHAT_MODEL_FEAT_TABLE = {
|
||||
@@ -133,36 +125,6 @@ CHAT_MODEL_FEAT_TABLE = {
|
||||
for feats in CHAT_MODEL_FEAT_TABLE.values():
|
||||
feats["structured_output"] = feats.get("tool_calling", False)
|
||||
|
||||
|
||||
LLM_TEMPLATE = """\
|
||||
---
|
||||
sidebar_position: 1
|
||||
sidebar_class_name: hidden
|
||||
keywords: [compatibility]
|
||||
custom_edit_url:
|
||||
---
|
||||
|
||||
# LLMs
|
||||
|
||||
:::info
|
||||
|
||||
If you'd like to write your own LLM, see [this how-to](/docs/how_to/custom_llm/).
|
||||
If you'd like to contribute an integration, see [Contributing integrations](/docs/contributing/integrations/).
|
||||
|
||||
:::
|
||||
|
||||
## Features (natively supported)
|
||||
All LLMs implement the Runnable interface, which comes with default implementations of all methods, ie. `ainvoke`, `batch`, `abatch`, `stream`, `astream`. This gives all LLMs basic support for async, streaming and batch, which by default is implemented as below:
|
||||
- *Async* support defaults to calling the respective sync method in asyncio's default thread pool executor. This lets other async functions in your application make progress while the LLM is being executed, by moving this call to a background thread.
|
||||
- *Streaming* support defaults to returning an `Iterator` (or `AsyncIterator` in the case of async streaming) of a single value, the final result returned by the underlying LLM provider. This obviously doesn't give you token-by-token streaming, which requires native support from the LLM provider, but ensures your code that expects an iterator of tokens can work for any of our LLM integrations.
|
||||
- *Batch* support defaults to calling the underlying LLM in parallel for each input by making use of a thread pool executor (in the sync batch case) or `asyncio.gather` (in the async batch case). The concurrency can be controlled with the `max_concurrency` key in `RunnableConfig`.
|
||||
|
||||
Each LLM integration can optionally provide native implementations for async, streaming or batch, which, for providers that support it, can be more efficient. The table shows, for each integration, which features have been implemented with native support.
|
||||
|
||||
{table}
|
||||
|
||||
"""
|
||||
|
||||
CHAT_MODEL_TEMPLATE = """\
|
||||
---
|
||||
sidebar_position: 0
|
||||
@@ -196,60 +158,6 @@ the feature.
|
||||
"""
|
||||
|
||||
|
||||
def get_llm_table():
|
||||
llm_feat_table = {}
|
||||
for cm in llms.__all__:
|
||||
llm_feat_table[cm] = {}
|
||||
cls = getattr(llms, cm)
|
||||
if issubclass(cls, LLM):
|
||||
for feat in ("_stream", "_astream", ("_acall", "_agenerate")):
|
||||
if isinstance(feat, tuple):
|
||||
feat, name = feat
|
||||
else:
|
||||
feat, name = feat, feat
|
||||
llm_feat_table[cm][name] = getattr(cls, feat) != getattr(LLM, feat)
|
||||
else:
|
||||
for feat in [
|
||||
"_stream",
|
||||
"_astream",
|
||||
("_generate", "batch_generate"),
|
||||
"_agenerate",
|
||||
("_agenerate", "batch_agenerate"),
|
||||
]:
|
||||
if isinstance(feat, tuple):
|
||||
feat, name = feat
|
||||
else:
|
||||
feat, name = feat, feat
|
||||
llm_feat_table[cm][name] = getattr(cls, feat) != getattr(BaseLLM, feat)
|
||||
final_feats = {
|
||||
k: v
|
||||
for k, v in {**llm_feat_table, **LLM_FEAT_TABLE_CORRECTION}.items()
|
||||
if k not in LLM_IGNORE
|
||||
}
|
||||
|
||||
header = [
|
||||
"model",
|
||||
"_agenerate",
|
||||
"_stream",
|
||||
"_astream",
|
||||
"batch_generate",
|
||||
"batch_agenerate",
|
||||
]
|
||||
title = [
|
||||
"Model",
|
||||
"Invoke",
|
||||
"Async invoke",
|
||||
"Stream",
|
||||
"Async stream",
|
||||
"Batch",
|
||||
"Async batch",
|
||||
]
|
||||
rows = [title, [":-"] + [":-:"] * (len(title) - 1)]
|
||||
for llm, feats in sorted(final_feats.items()):
|
||||
rows += [[llm, "✅"] + ["✅" if feats.get(h) else "❌" for h in header[1:]]]
|
||||
return "\n".join(["|".join(row) for row in rows])
|
||||
|
||||
|
||||
def get_chat_model_table() -> str:
|
||||
"""Get the table of chat models."""
|
||||
header = [
|
||||
@@ -298,15 +206,9 @@ def get_chat_model_table() -> str:
|
||||
if __name__ == "__main__":
|
||||
output_dir = Path(sys.argv[1])
|
||||
output_integrations_dir = output_dir / "integrations"
|
||||
output_integrations_dir_llms = output_integrations_dir / "llms"
|
||||
output_integrations_dir_chat = output_integrations_dir / "chat"
|
||||
output_integrations_dir_llms.mkdir(parents=True, exist_ok=True)
|
||||
output_integrations_dir_chat.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
llm_page = LLM_TEMPLATE.format(table=get_llm_table())
|
||||
|
||||
with open(output_integrations_dir / "llms" / "index.mdx", "w") as f:
|
||||
f.write(llm_page)
|
||||
chat_model_page = CHAT_MODEL_TEMPLATE.format(table=get_chat_model_table())
|
||||
with open(output_integrations_dir / "chat" / "index.mdx", "w") as f:
|
||||
f.write(chat_model_page)
|
||||
|
||||
73
docs/src/theme/FeatureTables.tsx
Normal file
73
docs/src/theme/FeatureTables.tsx
Normal file
@@ -0,0 +1,73 @@
|
||||
import React from "react";
|
||||
|
||||
interface Column {
|
||||
title: string | React.ReactNode;
|
||||
formatter: (item: any) => React.ReactNode;
|
||||
}
|
||||
interface Category {
|
||||
link: string;
|
||||
columns: Column[];
|
||||
items: any[];
|
||||
}
|
||||
|
||||
const FeatureTables: Record<string, Category> = {
|
||||
llms: {
|
||||
link: "/docs/integrations/llms",
|
||||
columns: [
|
||||
{title: "Model", formatter: (item) => <a href={item.link}>{item.name}</a>},
|
||||
|
||||
],
|
||||
items:[
|
||||
{
|
||||
name: "Anthropic",
|
||||
link: "anthropic.ipynb",
|
||||
package: "langchain-anthropic",
|
||||
}
|
||||
]
|
||||
},
|
||||
text_embedding: {
|
||||
link: "/docs/integrations/text_embedding",
|
||||
columns: [],
|
||||
items:[
|
||||
{
|
||||
name: "Cohere",
|
||||
link: "cohere.ipynb",
|
||||
package: "langchain-cohere",
|
||||
}
|
||||
]
|
||||
},
|
||||
};
|
||||
|
||||
function toTable(columns: Column[], items: any[]) {
|
||||
const headers = columns.map((col) => col.title);
|
||||
return (
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{headers.map((header) => <th>{header}</th>)}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{items.map((item) => (
|
||||
<tr>
|
||||
{columns.map((col) => <td>{col.formatter(item)}</td>)}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
);
|
||||
}
|
||||
|
||||
export function CategoryTable({category}: {category: string}) {
|
||||
const cat = FeatureTables[category];
|
||||
return toTable(cat.columns, cat.items);
|
||||
}
|
||||
|
||||
export function ItemTable({category, item}: {category: string, item: string}) {
|
||||
const cat = FeatureTables[category];
|
||||
const row = cat.items.find((i) => i.name === item);
|
||||
if (!row) {
|
||||
throw new Error(`Item ${item} not found in category ${category}`);
|
||||
}
|
||||
return toTable(cat.columns, [row]);
|
||||
}
|
||||
Reference in New Issue
Block a user