langchain-perplexity0.1.1
langchain-perplexity0.1.1
Published
An integration package connecting Perplexity and LangChain
pip install langchain-perplexity
Package Downloads
Authors
Project URLs
Requires Python
<4.0,>=3.9
langchain-perplexity
This package contains the LangChain integration with Perplexity.
Installation
pip install -U langchain-perplexity
And you should configure your perplexity credentials
and then set the PPLX_API_KEY
environment variable.
Usage
This package contains the ChatPerplexity
class, which is the recommended way to interface with Perplexity chat models.
import getpass
import os
if not os.environ.get("PPLX_API_KEY"):
os.environ["PPLX_API_KEY"] = getpass.getpass("Enter API key for Perplexity: ")
from langchain.chat_models import init_chat_model
llm = init_chat_model("llama-3.1-sonar-small-128k-online", model_provider="perplexity")
llm.invoke("Hello, world!")