# langchain-anthropic
This package contains the LangChain integration for Anthropic's generative models.
## Installation
`pip install -U langchain-anthropic`
## Chat Models
Anthropic recommends using their chat models over text completions.
You can see their recommended models [here](https://docs.anthropic.com/claude/docs/models-overview#model-recommendations).
To use, you should have an Anthropic API key configured. Initialize the model as:
```
from langchain_anthropic import ChatAnthropic
from langchain_core.messages import AIMessage, HumanMessage
model = ChatAnthropic(model="claude-3-opus-20240229", temperature=0, max_tokens=1024)
```
### Define the input message
`message = HumanMessage(content="What is the capital of France?")`
### Generate a response using the model
`response = model.invoke([message])`
For a more detailed walkthrough see [here](https://python.langchain.com/docs/integrations/chat/anthropic).
## LLMs (Legacy)
You can use the Claude 2 models for text completions.
```python
from langchain_anthropic import AnthropicLLM
model = AnthropicLLM(model="claude-2.1", temperature=0, max_tokens=1024)
response = model.invoke("The best restaurant in San Francisco is: ")
```
Raw data
{
"_id": null,
"home_page": "https://github.com/langchain-ai/langchain",
"name": "langchain-anthropic",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/93/57/a4cd984afd45a6b7793178db4595914d8625b69382bbe51f18513c19f641/langchain_anthropic-0.3.1.tar.gz",
"platform": null,
"description": "# langchain-anthropic\n\nThis package contains the LangChain integration for Anthropic's generative models.\n\n## Installation\n\n`pip install -U langchain-anthropic`\n\n## Chat Models\n\nAnthropic recommends using their chat models over text completions.\n\nYou can see their recommended models [here](https://docs.anthropic.com/claude/docs/models-overview#model-recommendations).\n\nTo use, you should have an Anthropic API key configured. Initialize the model as:\n\n```\nfrom langchain_anthropic import ChatAnthropic\nfrom langchain_core.messages import AIMessage, HumanMessage\n\nmodel = ChatAnthropic(model=\"claude-3-opus-20240229\", temperature=0, max_tokens=1024)\n```\n\n### Define the input message\n\n`message = HumanMessage(content=\"What is the capital of France?\")`\n\n### Generate a response using the model\n\n`response = model.invoke([message])`\n\nFor a more detailed walkthrough see [here](https://python.langchain.com/docs/integrations/chat/anthropic).\n\n## LLMs (Legacy)\n\nYou can use the Claude 2 models for text completions.\n\n```python\nfrom langchain_anthropic import AnthropicLLM\n\nmodel = AnthropicLLM(model=\"claude-2.1\", temperature=0, max_tokens=1024)\nresponse = model.invoke(\"The best restaurant in San Francisco is: \")\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An integration package connecting AnthropicMessages and LangChain",
"version": "0.3.1",
"project_urls": {
"Homepage": "https://github.com/langchain-ai/langchain",
"Release Notes": "https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-anthropic%3D%3D0%22&expanded=true",
"Repository": "https://github.com/langchain-ai/langchain",
"Source Code": "https://github.com/langchain-ai/langchain/tree/master/libs/partners/anthropic"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8973af53ffcb5262e8d16ca0b0d8b319b542f1cff78ba5ad1049e680bbcc16c8",
"md5": "042a06b67d45c706e0add9d636389c85",
"sha256": "c95ca2e381798babdb8e55e5ed241342e0ea9bc2f15721cdbace87d23992d29e"
},
"downloads": -1,
"filename": "langchain_anthropic-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "042a06b67d45c706e0add9d636389c85",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 22325,
"upload_time": "2024-12-19T16:08:28",
"upload_time_iso_8601": "2024-12-19T16:08:28.811925Z",
"url": "https://files.pythonhosted.org/packages/89/73/af53ffcb5262e8d16ca0b0d8b319b542f1cff78ba5ad1049e680bbcc16c8/langchain_anthropic-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9357a4cd984afd45a6b7793178db4595914d8625b69382bbe51f18513c19f641",
"md5": "589d7902d3b5ad0ec3328e412cdda950",
"sha256": "4dc1b9a685d6b2a9e55231e4c92248bb7452b7821f6b64a5607737cdf8ba98ef"
},
"downloads": -1,
"filename": "langchain_anthropic-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "589d7902d3b5ad0ec3328e412cdda950",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 20805,
"upload_time": "2024-12-19T16:08:29",
"upload_time_iso_8601": "2024-12-19T16:08:29.891051Z",
"url": "https://files.pythonhosted.org/packages/93/57/a4cd984afd45a6b7793178db4595914d8625b69382bbe51f18513c19f641/langchain_anthropic-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-19 16:08:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "langchain-ai",
"github_project": "langchain",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "langchain-anthropic"
}