langchain-anthropic


Namelangchain-anthropic JSON
Version 0.3.7 PyPI version JSON
download
home_pageNone
SummaryAn integration package connecting AnthropicMessages and LangChain
upload_time2025-02-06 22:12:55
maintainerNone
docs_urlNone
authorNone
requires_python<4.0,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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": null,
    "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/70/b0/84cfe0b4b829bcdc99fbb1a06973a6f3109b4e326292cdf5fa46f88dbf2f/langchain_anthropic-0.3.7.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```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An integration package connecting AnthropicMessages and LangChain",
    "version": "0.3.7",
    "project_urls": {
        "Release Notes": "https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-anthropic%3D%3D0%22&expanded=true",
        "Source Code": "https://github.com/langchain-ai/langchain/tree/master/libs/partners/anthropic",
        "repository": "https://github.com/langchain-ai/langchain"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f3b3111e1f41b0044687ec0c34c921ad52d33d2802282b1bc45343d5dd923fb6",
                "md5": "83dc3513c48d9e859b1f3cf46fa46fc0",
                "sha256": "adec0a1daabd3c25249753c6cd625654917fb9e3feee68e72c7dc3f4449c0f3c"
            },
            "downloads": -1,
            "filename": "langchain_anthropic-0.3.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "83dc3513c48d9e859b1f3cf46fa46fc0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 22998,
            "upload_time": "2025-02-06T22:12:51",
            "upload_time_iso_8601": "2025-02-06T22:12:51.940319Z",
            "url": "https://files.pythonhosted.org/packages/f3/b3/111e1f41b0044687ec0c34c921ad52d33d2802282b1bc45343d5dd923fb6/langchain_anthropic-0.3.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "70b084cfe0b4b829bcdc99fbb1a06973a6f3109b4e326292cdf5fa46f88dbf2f",
                "md5": "d41c76b3d2df6891ed6b381006bc726e",
                "sha256": "534cd1867bc41711cd8c3d0a0bc055e6c5a4215953c87260209a90dc5816f30d"
            },
            "downloads": -1,
            "filename": "langchain_anthropic-0.3.7.tar.gz",
            "has_sig": false,
            "md5_digest": "d41c76b3d2df6891ed6b381006bc726e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 39838,
            "upload_time": "2025-02-06T22:12:55",
            "upload_time_iso_8601": "2025-02-06T22:12:55.313248Z",
            "url": "https://files.pythonhosted.org/packages/70/b0/84cfe0b4b829bcdc99fbb1a06973a6f3109b4e326292cdf5fa46f88dbf2f/langchain_anthropic-0.3.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-06 22:12:55",
    "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"
}
        
Elapsed time: 8.42063s