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

Uploaded Source

Built Distribution

langchain_anthropic-0.3.1-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_anthropic-0.3.1.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for langchain_anthropic-0.3.1.tar.gz
Algorithm Hash digest
SHA256 4dc1b9a685d6b2a9e55231e4c92248bb7452b7821f6b64a5607737cdf8ba98ef
MD5 589d7902d3b5ad0ec3328e412cdda950
BLAKE2b-256 9357a4cd984afd45a6b7793178db4595914d8625b69382bbe51f18513c19f641

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_anthropic-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c95ca2e381798babdb8e55e5ed241342e0ea9bc2f15721cdbace87d23992d29e
MD5 042a06b67d45c706e0add9d636389c85
BLAKE2b-256 8973af53ffcb5262e8d16ca0b0d8b319b542f1cff78ba5ad1049e680bbcc16c8

See more details on using hashes here.

Supported by

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