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

Uploaded Source

Built Distribution

langchain_anthropic-0.1.13-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for langchain_anthropic-0.1.13.tar.gz
Algorithm Hash digest
SHA256 32e7ac51e1874c47e1a20493e75f5bfc88b0ffeaf5f1aed6091547e1ae44bb85
MD5 e6dce20607180ac0ad3e42e75e469a7d
BLAKE2b-256 b56bd46280bb30b2a1f7639288c2140ecb194603b46d182462c7799f98a64a19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_anthropic-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 121f6f480da7685c239573d98322adb94fe486d40651ac341637f65da36881de
MD5 7ca127bef196c8cbaed35b2fc0c04ef3
BLAKE2b-256 d1b71f0f448592a7285213c6e33898230bc595698fadf13dc7bc7c00d3f38998

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