Skip to main content

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

langchain_anthropic-0.2.0.dev1.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

langchain_anthropic-0.2.0.dev1-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file langchain_anthropic-0.2.0.dev1.tar.gz.

File metadata

File hashes

Hashes for langchain_anthropic-0.2.0.dev1.tar.gz
Algorithm Hash digest
SHA256 45d82164d85e587ce196d57a52d4229fec791c96c338caa0873f545b4b7105c0
MD5 2ba1ae889359c65432f56570ed227d6f
BLAKE2b-256 1a77521b4e85f0538a27a2bdbb0a68400d4438db3e019be028057ba5ea246756

See more details on using hashes here.

File details

Details for the file langchain_anthropic-0.2.0.dev1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_anthropic-0.2.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7d5b04a47120e0d68b77886b25eccd4a1a19e22454ac5216779576578c09218
MD5 4e7d6a2d23c08d7abdf97202a12df899
BLAKE2b-256 47f548c65ae7b1da930e69f37b2a4a990cb5bb4d73b332e2d10053bcf2c4e3ee

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page