Skip to main content

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: ")

Metadata

Release files for gigachain-anthropic 0.1.23

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gigachain-anthropic 0.1.23
File Size Uploaded
gigachain_anthropic-0.1.23.tar.gz 20.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gigachain-anthropic 0.1.23
File Interpreter ABI Platform
gigachain_anthropic-0.1.23-py3-none-any.whl Python 3 none any Details

Total release size: 41.8 kB

Release files / gigachain_anthropic-0.1.23.tar.gz

Download URL gigachain_anthropic-0.1.23.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
204efb0c3f36baa285dff2d528682587ba7ca85e76feb636ca0a6f972e815800
BLAKE2b-256 checksum
How to use checksums
939c831e49985afb9044c5eadea8eb7747bd7ae3cbc5642093834e070b22fba0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.5 Darwin/23.5.0

Release files / gigachain_anthropic-0.1.23-py3-none-any.whl

Download URL gigachain_anthropic-0.1.23-py3-none-any.whl
Size 21.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9be99a8817ed266a49e22625f49798e02d2db769d56c406d7195077134a2ace
BLAKE2b-256 checksum
How to use checksums
4a8812685b94a3e90bb64963b92b210b5b1ce40b152fbac9c4f54b177b57e3d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.5 Darwin/23.5.0

Release history Release notifications | RSS feed

This release

0.1.23 This release

2 release files

0.1.13

2 release files

0.1.8

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page