mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-07 20:15:40 +00:00
.. | ||
langchain_ollama | ||
scripts | ||
tests | ||
.gitignore | ||
LICENSE | ||
Makefile | ||
pyproject.toml | ||
README.md | ||
uv.lock |
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).
To run integration tests (make integration_tests
), you will need the following models installed in your Ollama server:
llama3.1
deepseek-r1:1.5b
Install these models by running:
ollama pull <name-of-model>
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")