[feat] Added backwards compatibility for OllamaEmbeddings initialization (migration from langchain_community.embeddings
to langchain_ollama.embeddings
#29296
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
langchain_community.embeddings
tolangchain_ollama.embeddings
: "langchain_ollama"OllamaEmbeddings
fromlangchain_community.embeddings
is deprecated, code is being shifted to ``langchain_ollama.embeddings. However, this does not offer backward compatibility of initializing the parameters and
OllamaEmbeddings` object.OllamaEmbeddings
oflangchain_ollama.embeddings
after migration fromlangchain_community.embeddings
#29294Additional Information
Previously,
OllamaEmbeddings
fromlangchain_community.embeddings
used to support the following options:langchain/libs/community/langchain_community/embeddings/ollama.py
Lines 125 to 139 in e9abe58
However, in the new package
from langchain_ollama import OllamaEmbeddings
, there is no method to set these options. I have added these parameters to resolve this issue.This issue was also discussed in #29113