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.14rc1.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

langchain_anthropic-0.1.14rc1-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file langchain_anthropic-0.1.14rc1.tar.gz.

File metadata

File hashes

Hashes for langchain_anthropic-0.1.14rc1.tar.gz
Algorithm Hash digest
SHA256 5b2d1a6257b132f42efab6c5db2e1bdbcf1f94dcaf0ff37c9be67cc3005b1ff7
MD5 e6ce6b28d88163858e622c737092d43f
BLAKE2b-256 87d82371286294e04f480167cfccf3886d20299d4c6ce77b028102156223f4ef

See more details on using hashes here.

File details

Details for the file langchain_anthropic-0.1.14rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_anthropic-0.1.14rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 aeea9a88fc8b403c4ca15310da4f0a3fe2d11b81434a61bf3516a9bb4a007ce3
MD5 f5917e29e9ffbf6e387f467f3b4f94c7
BLAKE2b-256 b073233fdb4676f3f2dde5619a2f7237530a6d795772c4713c1c8acdad3394d1

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