Skip to content

Anthropic ​

Anthropic是一家人工智能安全和研究公司,也是Claude的创建者。本页面涵盖了Anthropic模型与LangChain之间的所有集成。

安装和设置 ​

要使用Anthropic模型,您需要安装一个 Python 包:

bash
pip install -U langchain-anthropic

您需要设置ANTHROPIC_API_KEY环境变量。您可以在这里获取 Anthropic 的 API 密钥。

语言模型 ​

[Legacy] 人类中心语言模型 ​

注意:Anthropic语言模型仅支持旧版Claude 2模型。要使用最新的Claude 3模型,请改用ChatAnthropic。

查看使用示例。

python
from langchain_anthropic import AnthropicLLM
model = AnthropicLLM(model='claude-2.1')

聊天模型 ​

ChatAnthropic ​

查看使用示例。

python
from langchain_anthropic import ChatAnthropic
model = ChatAnthropic(model='claude-3-opus-20240229')

基于 MIT 许可发布 共建 共享 共管