rshvr/unofficial-cohere-best-practices
Overview
This skill provides a practical Cohere + LangChain integration reference for ChatCohere, CohereEmbeddings, CohereRerank, and CohereRagRetriever. It shows how to build RAG pipelines, agent tool-calling workflows, streaming responses, structured outputs, and best-practice settings for reliable tool use. Use it to accelerate building production-ready retrieval-augmented and agent-based apps with Cohere models in LangChain.
How this skill works
The skill documents the key LangChain wrappers for Cohere: ChatCohere for chat and streaming, CohereEmbeddings for vectorization, CohereRerank for candidate re-ranking and compression, and CohereRagRetriever for RAG retrieval patterns. It demonstrates how to compose these components into chains, bind tools to the LLM, and produce structured outputs via Pydantic models. Examples include vector store integration, contextual compression retrievers, streaming invocation, and a full RAG chain example wired end-to-end.
When to use it
- Building retrieval-augmented generation pipelines that combine embeddings + vector store + LLM
- Creating agents that call external tools with reliable tool-calling behavior
- Streaming outputs to UIs or progressive consumers
- Producing structured, type-safe outputs (Pydantic) from LLM responses
- Improving answer relevance by reranking candidate documents with CohereRerank
Best practices
- Set temperature low (e.g., 0.3) for predictable tool calling and factual outputs
- Use embed-english-v3.0 (or newer) for document and query embeddings to maximize vector search quality
- Combine FAISS (or another vector store) with CohereEmbeddings and a reranker for high-precision retrieval
- Use ContextualCompressionRetriever with CohereRerank to reduce prompt size while retaining relevance
- Leverage streaming for large outputs to improve UX and to handle long generations incrementally
- Wrap outputs with Pydantic models for deterministic structured parsing and downstream processing
Example use cases
- Customer support assistant that fetches relevant KB articles, reranks them, and answers with citations
- Agent that calls external tools (APIs) like weather or booking systems with predictable tool-call parsing
- RAG-powered search UI: embed documents, run vector search, compress with reranker, and answer user queries
- Content summarization pipeline that retrieves related docs, reranks, and produces structured summaries
- Internal knowledge assistant that returns typed entities (e.g., policy, date, owner) using structured output models
FAQ
Not all. Some special models like Command A Reasoning and Command A Vision are not supported in LangChain; use the native Cohere SDK for those models.
What settings improve tool-calling reliability?
Lower temperature (around 0.3), explicit prompt templates, and providing tool definitions to the LLM help. Bind tools via the LangChain tool decorator and inspect response.tool_calls for execution.
6 skills
This skill helps you build and optimize Cohere LangChain RAG pipelines and tool workflows by providing integrated chat, embeddings, and retriever examples.
This skill helps you leverage Cohere cookbooks to implement RAG, agents, embeddings, and enterprise patterns for production-grade AI applications.
This skill helps you leverage Cohere streaming for real-time text generation, tool use events, and RAG citations across apps.
This skill helps you integrate Cohere's TypeScript SDK for chat, embeddings, and tool use in Node.js or browser apps.
This skill helps Java/Kotlin developers integrate Cohere APIs efficiently, with examples for chat, embeddings, reranking, streaming, tools, and error handling.
This skill helps you leverage Cohere's Python SDK for chat, tool use, streaming, and RAG to build Python apps.