# 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/5d/b4/5b54844307decc73416be757dbeba1e4cd62e0cd7e9d6e1b7e30eb17ab4d/langchain_anthropic-0.3.0.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.0",
"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": "c2bb8f1cb2c5ab344484cbecd1009c84ed70cd7d8a1df58196b5a35bb7fb4da1",
"md5": "451940536f077ec232de248045fb977b",
"sha256": "96b74a9adfcc092cc2ae137d4189ca50e8f5ad9635618024f7c98d8f9fc1076a"
},
"downloads": -1,
"filename": "langchain_anthropic-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "451940536f077ec232de248045fb977b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 22152,
"upload_time": "2024-11-12T20:04:32",
"upload_time_iso_8601": "2024-11-12T20:04:32.659780Z",
"url": "https://files.pythonhosted.org/packages/c2/bb/8f1cb2c5ab344484cbecd1009c84ed70cd7d8a1df58196b5a35bb7fb4da1/langchain_anthropic-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5db45b54844307decc73416be757dbeba1e4cd62e0cd7e9d6e1b7e30eb17ab4d",
"md5": "3bf35d63174228f29443a18ea1bc6466",
"sha256": "f9b5cbdbf2d5b3432f78f056e474efb10a2c1e37f9a471d3aceb50a0d9f945df"
},
"downloads": -1,
"filename": "langchain_anthropic-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "3bf35d63174228f29443a18ea1bc6466",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 20619,
"upload_time": "2024-11-12T20:04:34",
"upload_time_iso_8601": "2024-11-12T20:04:34.190286Z",
"url": "https://files.pythonhosted.org/packages/5d/b4/5b54844307decc73416be757dbeba1e4cd62e0cd7e9d6e1b7e30eb17ab4d/langchain_anthropic-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-12 20:04:34",
"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"
}