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

Uploaded Source

Built Distribution

langchain_anthropic-0.1.2-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_anthropic-0.1.2.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for langchain_anthropic-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a0f20a5aa18427dd8ed72e6a8ad5d63765a76b1e4bb46d620792bdd53aa8b3af
MD5 f45256db241bdf1b1feed9949101b54e
BLAKE2b-256 1b10d5e85fea75f497df4456c4f30f4e4c804fb621978f585b2bb2aaf38be857

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_anthropic-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 35de88e0d1938c0826231b410e1215c2ca8455d2df075c0eee2d0ac524569542
MD5 6601dc67b84be50c92f25e136a4f5cc2
BLAKE2b-256 a4c5988e60196404610ae323a50d012b28194805f12bd719eb9f7300fc77637e

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