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.8rc1.tar.gz
.
File metadata
- Download URL: langchain_anthropic-0.1.8rc1.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d53ba16fbc24b9e165d305327474908244df721b4202dae95d5b3ac211d7e8d8 |
|
MD5 | d48adf4660af565e05b455bbccedd46f |
|
BLAKE2b-256 | a5fe44f0c10a3557aca67639610754b8c337c3b0e0a6464e302cf7746d36ac3d |
File details
Details for the file langchain_anthropic-0.1.8rc1-py3-none-any.whl
.
File metadata
- Download URL: langchain_anthropic-0.1.8rc1-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c881a35107576833569dbd13b7098b833d38fa791ef925db93b3e5a168b55b09 |
|
MD5 | 4b58d236b392062e4596854cee723663 |
|
BLAKE2b-256 | 49969f535677124326a86d8f3c23e9e8b18d865044f295cd8fad6dc05f8c3096 |