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.1.7.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

langchain_anthropic-0.1.7-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file langchain_anthropic-0.1.7.tar.gz.

File metadata

  • Download URL: langchain_anthropic-0.1.7.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for langchain_anthropic-0.1.7.tar.gz
Algorithm Hash digest
SHA256 113a7bcc297798692c64f569a73c0681450a706d9d6acdcac0102511b2958fac
MD5 e2841c9a310a3f0301b8a1666ff25f04
BLAKE2b-256 fbe1541988fc259c4a65b5b2b74ea8dd79e984f552c68135d158af4d06d82060

See more details on using hashes here.

File details

Details for the file langchain_anthropic-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_anthropic-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ae022d98eadeb8151145e417d0e2edc350740a117724a08d6b5d17481379c007
MD5 aa3bda32e944a70912b815cd90de93a0
BLAKE2b-256 0f46b5405440343dac8095c3257dae9de907eb5863611c7abcb11e61e4f43a88

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