mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
Co-authored-by: Mohammad Mohtashim <45242107+keenborder786@users.noreply.github.com> Co-authored-by: Caspar Broekhuizen <caspar@langchain.dev> Co-authored-by: ccurme <chester.curme@gmail.com> Co-authored-by: Christophe Bornet <cbornet@hotmail.com> Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com> Co-authored-by: Sadra Barikbin <sadraqazvin1@yahoo.com> Co-authored-by: Vadym Barda <vadim.barda@gmail.com>
1.5 KiB
1.5 KiB
langchain-ollama
This package contains the LangChain integration with Ollama
Installation
pip install -U langchain-ollama
For the package to work, you will need to install and run the Ollama server locally (download).
Chat Models
ChatOllama class exposes chat models from Ollama.
from langchain_ollama import ChatOllama
llm = ChatOllama(model="llama3.1")
llm.invoke("Sing a ballad of LangChain.")
Embeddings
OllamaEmbeddings class exposes embeddings from Ollama.
from langchain_ollama import OllamaEmbeddings
embeddings = OllamaEmbeddings(model="llama3.1")
embeddings.embed_query("What is the meaning of life?")
LLMs
OllamaLLM class exposes traditional LLMs from Ollama.
from langchain_ollama import OllamaLLM
llm = OllamaLLM(model="llama3.1")
llm.invoke("The meaning of life is")
Development
Running Tests
To run integration tests (make integration_tests), you will need the following models installed in your Ollama server:
llama3.1deepseek-r1:1.5bgpt-oss:20b
Install these models by running:
ollama pull <name-of-model>