An integration package connecting AnthropicMessages and LangChain
Project description
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.
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.
LLMs (Legacy)
You can use the Claude 2 models for text completions.
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: ")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file langchain_anthropic-0.1.10.tar.gz
.
File metadata
- Download URL: langchain_anthropic-0.1.10.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5972c613753f1fabb049bd0ee381e9a857b76b44d937bd3331e5ba675ecf496 |
|
MD5 | b504597294d5c3b60d8de0e0eb93b3f2 |
|
BLAKE2b-256 | fbec12c1b79a00e039168a22b0c5ae4333941f38e560fe6df1a9748f3a44c887 |
File details
Details for the file langchain_anthropic-0.1.10-py3-none-any.whl
.
File metadata
- Download URL: langchain_anthropic-0.1.10-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd9cf39ebf0c59bd4b0acbceaaeddd1101a16b3c2aa242a08887ac92d07eeba1 |
|
MD5 | d3948f919321ab08b1fb2af9e007bac2 |
|
BLAKE2b-256 | 953c167565ea7ffb10b52247c9fc1c5cbba339ef0e31c1947cc2349591f932f4 |