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
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 gigachain_anthropic-0.1.23.tar.gz
.
File metadata
- Download URL: gigachain_anthropic-0.1.23.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 204efb0c3f36baa285dff2d528682587ba7ca85e76feb636ca0a6f972e815800 |
|
MD5 | 43cd508af3ca28dcab62b81e50f0efcc |
|
BLAKE2b-256 | 939c831e49985afb9044c5eadea8eb7747bd7ae3cbc5642093834e070b22fba0 |
File details
Details for the file gigachain_anthropic-0.1.23-py3-none-any.whl
.
File metadata
- Download URL: gigachain_anthropic-0.1.23-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9be99a8817ed266a49e22625f49798e02d2db769d56c406d7195077134a2ace |
|
MD5 | 376bf81ed3ef73bc818790f0920962cd |
|
BLAKE2b-256 | 4a8812685b94a3e90bb64963b92b210b5b1ce40b152fbac9c4f54b177b57e3d0 |