langchain-perplexity
БесплатноБез исполняемых скриптовНе проверенLangChain Perplexity AI integration — ChatPerplexity (chat model with built-in web search and date/domain filtering), PerplexitySearchRetriever for RAG…
от enuno★ 17 звёзд на GitHubОб этом скилле
LangChain Perplexity Skill
Expert assistance for langchain-perplexity: Perplexity AI integration for LangChain. The key differentiator is ChatPerplexity — a chat model with real-time web search built in at the model level, plus domain filtering, date filtering, and reasoning model support.
Install: pip install -U langchain-perplexity
Setup: export PPLX_API_KEY=your_api_key
Reference: references/api.md (500 KB — full API reference).
When to Use This Skill
Activate when:
- Using ChatPerplexity — chat completions with built-in real-time web search
- Filtering web search by domain — using
search_domain_filterto restrict sources - Filtering by date — using
search_recency_filter,search_after_date_filter, orsearch_before_date_filter - Disabling web search — setting
disable_search=Trueto use Perplexity as a plain LLM - Using reasoning models — setting
reasoning_effortonsonar-reasoningorsonar-deep-research - Parsing reasoning output — using
ReasoningJsonOutputParserorstrip_think_tags()to clean<think>tags - Web search for RAG — using
PerplexitySearchRetrieverto retrieve live search results as documents - Search as a tool — using
PerplexitySearchResultsin a tool-calling agent - Generating embeddings — using
PerplexityEmbeddings - Returning images or related questions — setting
return_images=Trueorreturn_related_questions=True
Quick Reference
ChatPerplexity — basic usage
from langchain_perplexity import ChatPerplexity
model = ChatPerplexity(
model="sonar", # sonar | sonar-pro | sonar-reasoning | sonar-deep-research
temperature=0.7,
max_tokens=1024,
# pplx_api_key="...", # or set PPLX_API_KEY env var
)
# Invoke (web search runs automatically)
messages = [
("system", "You are a helpful assistant."),
("human", "What are the latest LangChain releases?"),
]
response = model.invoke(messages)
print(response.content)
print(response.response_metadata) # includes citations, search results
# Stream
for chunk in model.stream(messages):
print(chunk.content, end="", flush=True)
Filter web search by domain and recency
from langchain_perplexity import ChatPerplexity
model = ChatPerplexity(
model="sonar-pro",
search_domain_filter=["arxiv.org", "github.com"], # only these sources
search_recency_filter="week", # hour|day|week|month
# search_after_date_filter="2025-01-01", # ISO date string
# search_before_date_filter="2026-01-01",
return_images=False,
return_related_questions=True,
)
response = model.invoke("What are recent advances in RAG systems?")
Disable web search (use as plain LLM)
from langchain_perplexity import ChatPerplexity
model = ChatPerplexity(
model="sonar",
disable_search=True, # turn off web search entirely
temperature=0.5,
)
response = model.invoke("Explain transformer attention mechanisms.")
Reasoning model with effort control
from langchain_perplexity import ChatPerplexity
model = ChatPerplexity(
model="sonar-reasoning",
reasoning_effort="high", # low | medium | high
temperature=0.2,
)
response = model.invoke("Prove that sqrt(2) is irrational.")
print(response.content) # final answer (think tags stripped or separated)
Parse reasoning model output
from langchain_perplexity import ChatPerplexity
from langchain_perplexity.output_parsers import (
ReasoningJsonOutputParser,
ReasoningStructuredOutputParser,
strip_think_tags,
)
model = ChatPerplexity(model="sonar-reasoning")
raw = model.invoke("What is 17 * 23? Respond with JSON: {result: number}")
# Option 1: strip <think> tags from raw content
clean_content = strip_think_tags(raw.content)
# Option 2: parse reasoning + answer as structured JSON
parser = ReasoningJsonOutputParser()
parsed = parser.parse(raw.content)
# parsed["thinking"] → reasoning trace
# parsed["answer"] → final answer
# Option 3: structured output with Pydantic
from pydantic import BaseModel
class MathResult(BaseModel):
result: int
structured_parser = ReasoningStructuredOutputParser.from_pydantic(MathResult)
result = structured_parser.parse(raw.content)
Structured output with ChatPerplexity
from langchain_perplexity import ChatPerplexity
from pydantic import BaseModel, Field
class SearchSummary(BaseModel):
topic: str = Field(description="The main topic")
key_points: list[str] = Field(description="Key findings")
sources: list[str] = Field(description="Source URLs cited")
model = ChatPerplexity(model="sonar-pro")
structured = model.with_structured_output(SearchSummary)
result = structured.invoke("What are the main features of LangGraph?")
print(result.key_points)
PerplexitySearchRetriever — live web search for RAG
from langchain_perplexity import PerplexitySearchRetriev
Установить langchain-perplexity в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл langchain-perplexity?
LangChain Perplexity AI integration — ChatPerplexity (chat model with built-in web search and date/domain filtering), PerplexitySearchRetriever for RAG, PerplexitySearchResults tool, PerplexityEmbeddings, and reasoning output parsers (ReasoningJsonOutputParser, strip_think_tags).
Как установить скилл langchain-perplexity?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл langchain-perplexity запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
agent-skill-stack
Find, evaluate, and assemble the smallest compatible set of AI Agent Skills for an end-to-end natural-language goal. Use when a user wants Skills for a…
от GitHubbuild-evidence-map
Build an auditable evidence map for a contested technical choice, research synthesis, proposal review, or consequential decision. Use when Copilot must…
от GitHubpinecone-rag
Build production RAG pipelines and persistent agent memory using Pinecone as the vector database backend. ALWAYS USE THIS SKILL when the user mentions…
от GitHubqdrant-monitoring-debugging
Diagnoses Qdrant production issues using metrics and observability tools. Use when someone reports 'optimizer stuck', 'indexing too slow', 'memory too high'…
от GitHub