Cohere 是一家加拿大初创公司,提供自然语言处理模型,帮助公司改善人机交互。
安装和设置
- 安装 Python SDK
COHERE_API_KEY)
Cohere LangChain 集成
| API | description | 端点文档 | 导入 | 使用示例 |
|---|---|---|---|---|
| 聊天 | 构建聊天机器人 | 聊天 | 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 重排序器 的用法以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。