Cohere 是一家加拿大初创公司,提供自然语言处理模型,帮助企业改善人机交互。
安装和设置
- 安装 Python SDK:
COHERE_API_KEY)
Cohere LangChain 集成
| API | 描述 | 端点文档 | 导入 | 示例用法 |
|---|---|---|---|---|
| 聊天 | 构建聊天机器人 | 聊天 | from langchain_cohere import ChatCohere | cohere.ipynb |
| LLM | 生成文本 | 生成 | from langchain_cohere.llms import Cohere | cohere.ipynb |
| RAG 检索器 | 连接到外部数据源 | 聊天 + RAG | from langchain_classic.retrievers import CohereRagRetriever | cohere.ipynb |
| 文本嵌入 | 将字符串嵌入为向量 | 嵌入 | from langchain_cohere import CohereEmbeddings | cohere.ipynb |
| 重排序检索器 | 根据相关性对字符串进行排名 | 重排序 | from langchain_classic.retrievers.document_compressors import CohereRerank | cohere.ipynb |
快速复制示例
聊天
LLM
工具调用
ReAct 代理
该代理基于论文 ReAct: Synergizing Reasoning and Acting in Language Models。RAG 检索器
文本嵌入
重排序器
Cohere 重排序器 的用法Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

