langchain-components
LangChain Components
Complete reference for the LangChain ecosystem — models, agents, tools, retrieval, memory, middleware, streaming, multi-agent orchestration, LangGraph workflows, Deep Agents, and provider integrations for Python 3.10+.
Component Index
Models & Output
- Models — Chat models, tool calling, multimodal inputs, caching, rate limiting, custom models reference
- Messages — Message types (Human, AI, System, Tool), message operations, serialization, OpenAI format conversion reference
Agents
- Agents — create_agent, tools, structured output, guardrails, human-in-the-loop, context engineering reference
- Multi-Agent — Subagents, handoffs, skills, router, custom workflows, pattern selection reference
Tools & MCP
- Tools — Tool creation (@tool decorator, ToolNode), InjectedState, MCP integration, error handling reference
Retrieval & RAG
- Retrieval — Document loaders, text splitters, embeddings, vector stores, agentic RAG, semantic search reference
Memory
- Memory — Short-term (checkpointers, message trimming, summarization), long-term (store abstraction, namespaces) reference
Middleware & Streaming
- Middleware — 16 built-in middleware, custom middleware (decorator, class, wrap-style), execution order reference
- Streaming — Stream modes (updates, messages, custom), token streaming, useStream React hook reference
Runtime & Architecture
- Runtime — Dependency injection, context schemas, ToolRuntime, component architecture (5 layers) reference
Testing & Deployment
- Testing — Unit testing (GenericFakeChatModel), integration testing (AgentEvals), LangSmith observability reference
LangGraph
- LangGraph Core — Graph API, Functional API, workflows vs agents, state management, quickstart reference
- LangGraph State — Memory, persistence, durable execution, interrupts, checkpointers reference
- LangGraph Advanced — Subgraphs, time-travel, streaming, Graph API usage, Functional API usage reference
Deep Agents
- Deep Agents — Harness framework, models, subagents, skills, sandboxes, human-in-the-loop, long-term memory reference
Integrations
- Integrations — Chat models, document loaders, retrievers, embeddings, vector stores, tools, stores, splitters reference
- Providers — OpenAI, Anthropic, Google, AWS, Ollama setup and configuration reference
Quick Patterns
Create an Agent with Tools
from langchain.chat_models import init_chat_model
from langgraph.prebuilt import create_agent
model = init_chat_model("anthropic:claude-sonnet-4-20250514")
def get_weather(city: str) -> str:
"""Get weather for a city."""
return f"Sunny, 72F in {city}"
agent = create_agent(model, [get_weather])
response = agent.invoke(
{"messages": [{"role": "user", "content": "What's the weather in SF?"}]}
)
Structured Output
from pydantic import BaseModel
class SearchQuery(BaseModel):
query: str
year: int
structured_model = model.with_structured_output(SearchQuery)
result = structured_model.invoke("Who won the World Cup in 2022?")
RAG with Retrieval
from langchain_community.document_loaders import WebBaseLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_openai import OpenAIEmbeddings
from langchain_core.vectorstores import InMemoryVectorStore
docs = WebBaseLoader("https://example.com").load()
chunks = RecursiveCharacterTextSplitter(chunk_size=1000).split_documents(docs)
vector_store = InMemoryVectorStore.from_documents(chunks, OpenAIEmbeddings())
retriever_tool = vector_store.as_retriever()
Multi-Agent Handoffs
from langgraph.prebuilt import create_agent
billing_agent = create_agent(model, [lookup_billing], name="billing")
tech_agent = create_agent(model, [check_status], name="tech_support")
supervisor = create_agent(
model,
[billing_agent, tech_agent],
prompt="Route to the appropriate specialist."
)
LangGraph Workflow
from langgraph.graph import StateGraph, START, END
graph = StateGraph(dict)
graph.add_node("process", process_fn)
graph.add_node("review", review_fn)
graph.add_edge(START, "process")
graph.add_edge("process", "review")
graph.add_edge("review", END)
app = graph.compile()
Streaming
for chunk in agent.stream(
{"messages": [{"role": "user", "content": "Hello"}]},
stream_mode="messages"
):
print(chunk)
Best Practices
- Use
init_chat_model()for provider-agnostic model initialization - Prefer
create_agentover building custom agent loops - Use LangGraph for complex workflows requiring state, persistence, or human-in-the-loop
- Apply middleware for cross-cutting concerns (guardrails, rate limiting, PII detection)
- Use checkpointers for conversation persistence and short-term memory
- Use the Store abstraction for long-term memory across conversations
- Choose the right multi-agent pattern: handoffs for specialization, routers for classification, subagents for parallel work
- Use
with_structured_output()for type-safe LLM responses - Prefer agentic RAG (tool-based retrieval) over chain-based RAG for flexibility
- Use
stream_mode="messages"for token-level streaming to frontends
More from krzysztofsurdy/code-virtuoso
symfony-upgrade
Symfony framework version upgrade guide using the deprecation-first approach. Use when the user asks to upgrade Symfony to a new minor or major version, fix deprecation warnings, update Symfony recipes, check bundle compatibility, migrate between LTS versions, or plan a Symfony version migration strategy. Covers PHPUnit Bridge deprecation tracking, recipe updates, bundle compatibility checks, version-specific breaking changes, and the changelog-first upgrade workflow.
90symfony-components
Comprehensive reference for all 38 Symfony framework components with PHP 8.3+ and Symfony 7.x patterns. Use when the user asks to implement, configure, or troubleshoot any Symfony component including HttpFoundation, HttpKernel, DependencyInjection, Form, Validator, Cache, Messenger, Console, EventDispatcher, Workflow, Serializer, Security, Routing, Twig, Doctrine integration, or any other Symfony component. Covers APIs, configuration, best practices, and common pitfalls.
83solid
SOLID principles for object-oriented design with multi-language examples (PHP, Java, Python, TypeScript, C++). Use when the user asks to review SOLID compliance, fix a SOLID violation, evaluate class design, reduce coupling, improve extensibility, or apply Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, or Dependency Inversion principles. Covers motivation, violation detection, refactoring fixes, and real-world trade-offs for each principle.
47agentic-rules-writer
Interactive tool to generate tailored rules and instruction files for any AI coding agent. Use when the user asks to set up agent rules, configure Claude Code instructions, create Cursor rules, write Windsurf rules, generate Copilot instructions, or establish consistent AI coding standards for a team. Supports 13+ agents (Claude Code, Cursor, Windsurf, Copilot, Gemini, Codex, Cline, OpenCode, Continue, Trae, Roo Code, Amp) with global, team-shared, and dev-specific scopes. Defers to the `using-ecosystem` meta-skill for ecosystem discovery (skills, agents, recommendations) and runs an interactive questionnaire for workflow preferences.
47refactoring
Comprehensive skill for 89 refactoring techniques and 22 code smells with practical examples. Use when the user asks to refactor code, detect code smells, improve code quality, reduce complexity, or clean up technical debt. Covers composing methods, moving features between objects, organizing data, simplifying conditionals and method calls, dealing with generalization, and detecting smells across bloaters, OO abusers, change preventers, dispensables, and couplers with before/after comparisons and step-by-step mechanics.
42design-patterns
Comprehensive skill for all 26 Gang of Four design patterns with practical implementations and real-world examples. Use when the user asks to apply a design pattern, refactor code using patterns, choose between competing patterns, or review existing pattern usage. Covers creational (Abstract Factory, Builder, Factory Method, Prototype, Singleton, Object Pool), structural (Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy, Private Class Data), and behavioral patterns (Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor, Null Object) with real-world examples, trade-offs, and anti-patterns.
41