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

Uploaded Source

Built Distribution

langchain_anthropic-0.1.16-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_anthropic-0.1.16.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for langchain_anthropic-0.1.16.tar.gz
Algorithm Hash digest
SHA256 28187dfb19389772e0abba98eeb0210ed3d99ab0a73f2e6707aa46c9bbbbe407
MD5 efcc666a01a2c9b1b54358d467767078
BLAKE2b-256 46f2b46b2e1c62b98783390d326137b4d158ff627b35a41d9828d6be342054df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_anthropic-0.1.16-py3-none-any.whl
Algorithm Hash digest
SHA256 0d3f66b7ffb2d4ef739ef87c4b096f0dbbf0ce12f988205d1fcaa1da2c9d09fa
MD5 bc03c3dba3bc62c4f5a04e393d36d20a
BLAKE2b-256 1f05fc30c0cd92b309e91ed2160fecfcfa046ab6d7cfca3eaf722b97c16bd18b

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