langchain-streaming
Stream outputs from LangChain agents and models - includes stream modes, token streaming, progress updates, and real-time feedback
npx skills add majiayu000/claude-skill-registry --skill langchain-streaming --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# langchain-streaming (JavaScript/TypeScript) ## 概述 流式传输让您能够在 LangChain 代理和模型运行时实时显示更新。您可以逐步显示输出,而不是等待完整的响应,从而改善用户体验,特别是对于长时间运行的操作。 **核心概念:** - **流式模式(Stream Modes)**:不同类型的数据流(values、updates、messages、custom) - **Token 流式传输**:生成时的 LLM token - **代理进度**:每个代理步骤后的状态更新 - **自定义更新**:用户定义的进度信号 ## 何时使用流式传输 | 场景 | 流式传输? | 原因 | |----------|---------|-----| | 长模型响应 | ✅ 是 | 在生成时显示 token | | 多步骤代理任务 | ✅ 是 | 通过步骤显示进度 | | 长时间运行的工具 | ✅ 是 | 提供进度更新 | | 简单快速请求 | ⚠️ 可能 | 开销可能不值得 | | 后端批处理 | ❌ 否 | 没有用户等待更新 | ## 决策表 ### 流式模式选择 | 模式 | 何时使用 | 返回 | |------|----------|---------| | `"values"` | 需要每步后的完整状态 | 完整状态对象 | | `"updates"` | 仅需要变化的内容 | 状态增量 | | `"messages"` | 需要 LLM token 流 | [token, metadata] 元组 | | `"custom"` | 需要自定义进度信号 | 用户定义的数据 | | 多个模式 | 需要组合数据 | 模式数组 | ## 代码示例 ### 基本模型 Token 流式传输 ```typescript import { ChatOpenAI } from "@langchain/openai"; const model = new ChatOpenAI({ model: "gpt-4.1" }); // 在 token 到达时流式传输 const stream = await model.stream("用简单的术语解释量子计算"); for await (const chunk of stream) { process.stdout.write(chunk.content); } // 输出渐进出现:"量子" "计算" "是" ... ``` ### 代理进度流式传输 ```typescript import { createAgent } from "langchain"; const agent = createAgent({ model: "gpt-4.1", tools: [searchTool,
- 概述
- 何时使用流式传输
- 决策表
- 流式模式选择
- 代码示例
- 基本模型 Token 流式传输
- 代理进度流式传输
- 组合流式传输(消息 + 更新)
- 使用 Values 模式流式传输
- 来自工具的自定义进度更新
- 在 Web 应用程序中流式传输
- 流式传输中的错误处理
- 带超时的流式传输
- 缓冲 Token 以供显示
What does the langchain-streaming skill do?
Stream outputs from LangChain agents and models - includes stream modes, token streaming, progress updates, and real-time feedback
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill langchain-streaming --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
