langchain-sdk-patterns

Featured

Apply production-ready LangChain SDK patterns for structured output, fallbacks, batch processing, streaming, and caching. Trigger: "langchain SDK patterns", "langchain best practices", "idiomatic langchain", "langchain architecture", "withStructuredOutput", "withFallbacks", "abatch".

AI & Automation 2,266 stars 315 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# LangChain SDK Patterns ## Overview Production-grade patterns every LangChain application should use: type-safe structured output, provider fallbacks, async batch processing, streaming, caching, and retry logic. ## Pattern 1: Structured Output with Zod ```typescript import { ChatOpenAI } from "@langchain/openai"; import { ChatPromptTemplate } from "@langchain/core/prompts"; import { z } from "zod"; const ExtractedData = z.object({ entities: z.array(z.object({ name: z.string(), type: z.enum(["person", "org", "location"]), confidence: z.number().min(0).max(1), })), language: z.string(), summary: z.string(), }); const model = new ChatOpenAI({ model: "gpt-4o-mini" }); const structuredModel = model.withStructuredOutput(ExtractedData); const prompt = ChatPromptTemplate.fromTemplate( "Extract entities from this text:\n\n{text}" ); const chain = prompt.pipe(structuredModel); const result = await chain.invoke({ text: "Satya Nadella announced Microsoft's new AI lab in Seattle.", }); // result is fully typed: { entities: [...], language: "en", summary: "..." } ``` ## Pattern 2: Provider Fallbacks ```typescript import { ChatOpenAI } from "@langchain/openai"; import { ChatAnthropic } from "@langchain/anthropic"; const primary = new ChatOpenAI({ model: "gpt-4o", maxRetries: 2, timeout: 10000, }); const fallback = new ChatAnthropic({ model: "claude-sonnet-4-20250514", }); // Automatically falls back on any error (rate limit, timeout, 500) const...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
7 months ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Featured

langchain-performance-tuning

Optimize LangChain application performance: latency, throughput, streaming, caching, batch processing, and connection pooling. Trigger: "langchain performance", "langchain optimization", "langchain latency", "langchain slow", "speed up langchain".

2,266 Updated today
jeremylongshore
AI & Automation Featured

langchain-rate-limits

Implement LangChain rate limiting, retry strategies, and backoff. Use when handling API rate limits, controlling request throughput, or implementing concurrency-safe batch processing. Trigger: "langchain rate limit", "langchain throttling", "langchain backoff", "langchain retry", "API quota", "429 error".

2,266 Updated today
jeremylongshore
AI & Automation Featured

langchain-reference-architecture

Implement LangChain reference architecture for production systems: layered design, provider abstraction, chain registry, RAG pipelines, and multi-agent orchestration. Trigger: "langchain architecture", "langchain design patterns", "langchain scalable", "langchain enterprise", "LLM architecture".

2,266 Updated today
jeremylongshore
AI & Automation Solid

langchain-chains

LangChain chain composition including SequentialChain, RouterChain, and LCEL patterns

1,034 Updated today
a5c-ai
AI & Automation Featured

langchain-prod-checklist

Production readiness checklist for LangChain applications. Use when preparing for launch, validating deployment readiness, or auditing existing production LangChain systems. Trigger: "langchain production", "langchain prod ready", "deploy langchain", "langchain launch checklist", "go-live langchain".

2,266 Updated today
jeremylongshore