An integration package connecting Cohere and LangChain
Maintained. Last release 6 months ago, commits in 11 of the last 26 weeks. Weaker on release cadence.
pip install langchain-cohereLangchain-Cohere
This package contains the LangChain integrations for Cohere.
Cohere empowers every developer and enterprise to build amazing products and capture true business value with language AI.
Installation
- Install the
langchain-coherepackage:
pip install langchain-cohere
- Get a Cohere API key and set it as an environment variable (
COHERE_API_KEY)
Migration from langchain-community
Cohere's integrations used to be part of the langchain-community package, but since version 0.0.30 the integration in langchain-community has been deprecated in favour langchain-cohere.
The two steps to migrate are:
-
Import from langchain_cohere instead of langchain_community, for example:
from langchain_community.chat_models import ChatCohere->from langchain_cohere import ChatCoherefrom langchain_community.retrievers import CohereRagRetriever->from langchain_cohere import CohereRagRetrieverfrom langchain.embeddings import CohereEmbeddings->from langchain_cohere import CohereEmbeddingsfrom langchain.retrievers.document_compressors import CohereRerank->from langchain_cohere import CohereRerank
-
The Cohere Python SDK version is now managed by this package and only v5+ is supported.
- There's no longer a need to specify cohere as a dependency in requirements.txt/pyproject.toml (etc.)
Supported LangChain Integrations
| API | description | Endpoint docs | Import | Example usage |
|---|---|---|---|---|
| Chat | Build chat bots | chat | from langchain_cohere import ChatCohere | notebook |