langchain-performance-tuning

Featured

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".

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 Performance Tuning ## Overview Optimize LangChain apps for production: measure baseline latency, implement caching, batch with concurrency control, stream for perceived speed, optimize prompts for fewer tokens, and select the right model for each task. ## Step 1: Benchmark Baseline ```typescript async function benchmark( chain: { invoke: (input: any) => Promise<any> }, input: any, iterations = 5, ) { const times: number[] = []; for (let i = 0; i < iterations; i++) { const start = performance.now(); await chain.invoke(input); times.push(performance.now() - start); } times.sort((a, b) => a - b); return { mean: (times.reduce((a, b) => a + b, 0) / times.length).toFixed(0) + "ms", median: times[Math.floor(times.length / 2)].toFixed(0) + "ms", p95: times[Math.floor(times.length * 0.95)].toFixed(0) + "ms", min: times[0].toFixed(0) + "ms", max: times[times.length - 1].toFixed(0) + "ms", }; } // Usage const results = await benchmark(chain, { input: "test" }, 10); console.table(results); ``` ## Step 2: Streaming (Perceived Performance) ```typescript import { ChatOpenAI } from "@langchain/openai"; import { ChatPromptTemplate } from "@langchain/core/prompts"; import { StringOutputParser } from "@langchain/core/output_parsers"; const chain = ChatPromptTemplate.fromTemplate("{input}") .pipe(new ChatOpenAI({ model: "gpt-4o-mini", streaming: true })) .pipe(new StringOutputParser()); // Non-streaming: user waits 2-3s...

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-cost-tuning

Optimize LangChain API costs with token tracking, model tiering, caching, prompt compression, and budget enforcement. Trigger: "langchain cost", "langchain tokens", "reduce langchain cost", "langchain billing", "langchain budget", "token optimization".

2,266 Updated today
jeremylongshore
AI & Automation Featured

langchain-observability

Set up comprehensive observability for LangChain applications with LangSmith tracing, OpenTelemetry, Prometheus metrics, and alerts. Trigger: "langchain monitoring", "langchain metrics", "langchain observability", "langchain tracing", "LangSmith", "langchain alerts".

2,266 Updated today
jeremylongshore
AI & Automation Featured

langchain-sdk-patterns

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".

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-deploy-integration

Deploy LangChain applications to production with LangServe, Docker, and cloud platforms (Cloud Run, AWS Lambda). Trigger: "deploy langchain", "langchain production deploy", "langchain docker", "langchain cloud run", "LangServe".

2,266 Updated today
jeremylongshore