langchain
БесплатноБез исполняемых скриптовНе проверенLangChain Python package — new create_agent() factory (builds a LangGraph agent from a model string + tools + middleware), plus a comprehensive middleware…
от enuno★ 17 звёзд на GitHubОб этом скилле
LangChain Skill
Expert assistance for the langchain Python package's new agent API: create_agent() — a high-level factory that builds a LangGraph-backed agent with composable middleware for cross-cutting concerns (HITL, PII, fallback, limits, summarization, etc.).
Install: pip install -U langchain
Reference: references/api.md (500 KB — full API reference).
When to Use This Skill
Activate when:
- Creating an agent with
create_agent()— using model strings, tools, and middleware - Using init_chat_model strings — e.g.
"anthropic:claude-sonnet-4-5"as themodelparam - Adding HITL approval gates — using
HumanInTheLoopMiddlewareper tool - Redacting PII — using
PIIMiddlewareto detect/redact/mask/hash PII in input or output - Adding model fallback — using
ModelFallbackMiddlewarefor automatic failover - Limiting model or tool calls — using
ModelCallLimitMiddlewareorToolCallLimitMiddleware - Auto-summarizing long conversations — using
SummarizationMiddlewareon token/message threshold - Retrying failed calls — using
ModelRetryMiddlewareorToolRetryMiddleware - Structured agent output — using
response_formatparam oncreate_agent() - Composing multiple middleware — stacking middleware in the
middlewarelist
Quick Reference
create_agent() — minimal agent
from langchain.agents import create_agent
from langchain_core.tools import tool
@tool
def check_weather(location: str) -> str:
"""Return the weather forecast for a location."""
return f"It's sunny and 22°C in {location}."
# model can be a string (uses init_chat_model) or a BaseChatModel instance
agent = create_agent(
model="anthropic:claude-sonnet-4-6", # or "openai:gpt-4o", "google:gemini-2.0-flash"
tools=[check_weather],
system_prompt="You are a helpful assistant.",
)
# Returns a CompiledStateGraph (standard LangGraph interface)
for chunk in agent.stream(
{"messages": [{"role": "user", "content": "What's the weather in Paris?"}]},
stream_mode="updates",
):
print(chunk)
HumanInTheLoopMiddleware — per-tool approval gates
from langchain.agents import create_agent
from langchain.agents.middleware import HumanInTheLoopMiddleware
from langchain_core.tools import tool
@tool
def delete_file(path: str) -> str:
"""Delete a file from the filesystem."""
import os; os.remove(path); return f"Deleted {path}"
@tool
def read_file(path: str) -> str:
"""Read file contents."""
return open(path).read()
hitl = HumanInTheLoopMiddleware(
interrupt_on={
"delete_file": True, # all decisions: approve/edit/reject/respond
"read_file": False, # auto-approve (no interrupt)
# "write_file": InterruptOnConfig(approve=True, reject=True, description="Approve write?")
}
)
agent = create_agent(
model="anthropic:claude-sonnet-4-6",
tools=[delete_file, read_file],
middleware=[hitl],
checkpointer=..., # required for HITL interrupts
)
# Resume after interrupt (same as LangGraph interrupt pattern)
from langchain_core.messages import HumanMessage
from langgraph.types import Command
agent.invoke(Command(resume="approve"), config={"configurable": {"thread_id": "1"}})
PIIMiddleware — detect and handle PII
from langchain.agents import create_agent
from langchain.agents.middleware import PIIMiddleware
# Redact emails and credit cards from user input
pii = PIIMiddleware(
"email",
strategy="redact", # "block" | "redact" | "mask" | "hash"
apply_to_input=True, # scan user messages
apply_to_output=False, # don't scan agent responses
apply_to_tool_results=False,
)
# Stack multiple PII middleware
agent = create_agent(
model="openai:gpt-4o",
tools=[],
middleware=[
PIIMiddleware("email", strategy="redact"),
PIIMiddleware("credit_card", strategy="mask"), # ****-****-****-1234
PIIMiddleware("ip", strategy="hash"),
],
)
ModelFallbackMiddleware — automatic model failover
from langchain.agents import create_agent
from langchain.agents.middleware import ModelFallbackMiddleware
fallback = ModelFallbackMiddleware(
"openai:gpt-4o-mini", # try first on error
"anthropic:claude-haiku-4-5-20251001", # then this
# additional fallbacks...
)
agent = create_agent(
model="openai:gpt-4o", # primary model
tools=[...],
middleware=[fallback],
)
SummarizationMiddleware — auto-compress long conversations
from langchain.agents import create_agent
from langchain.agents.middleware import SummarizationMiddleware
summarizer = SummarizationMiddleware(
model="openai:gpt-4o-mini", # model to generate summaries
trigger=[
("fraction", 0.8), # trigger at 80% of model's context window
("messages", 100), # or at 100 messages, whichever first
],
keep=("messages", 20),
Установить langchain в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл langchain?
LangChain Python package — new create_agent() factory (builds a LangGraph agent from a model string + tools + middleware), plus a comprehensive middleware system covering HITL, PII redaction, model fallback, rate limiting, auto-summarization, context editing, shell tools, and todo planning.
Как установить скилл langchain?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл langchain запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic