[PR #575] [MERGED] fix code cell for streaming #826

Closed
opened 2026-02-17 17:21:12 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/docs/pull/575
Author: @ccurme
Created: 9/18/2025
Status: Merged
Merged: 9/19/2025
Merged by: @lnhsingh

Base: mainHead: cc/fix_streaming


📝 Commits (2)

📊 Changes

1 file changed (+16 additions, -35 deletions)

View changed files

📝 src/oss/langchain/messages.mdx (+16 -35)

📄 Description

Currently we split the streaming loop and combination into separate code blocks.

There are a few problems with the code block for combining chunks:

  1. It doesn't work (we sum an AIMessage, which results in a ChatPromptTemplate):
from langchain_core.messages import AIMessage, AIMessageChunk

chunks = [AIMessageChunk("foo"), AIMessageChunk(" bar")]

final_message = sum(chunks, AIMessage(""))  # ChatPromptTemplate
  1. More nitpicky, but I think aggregating chunks is important and also concise enough that we can display it in the first cell with just two additional lines.

Here we demonstrate aggregation in the first cell (and also remove an import).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/docs/pull/575 **Author:** [@ccurme](https://github.com/ccurme) **Created:** 9/18/2025 **Status:** ✅ Merged **Merged:** 9/19/2025 **Merged by:** [@lnhsingh](https://github.com/lnhsingh) **Base:** `main` ← **Head:** `cc/fix_streaming` --- ### 📝 Commits (2) - [`4b08d52`](https://github.com/langchain-ai/docs/commit/4b08d5248d166dd5590701d28ebbe90ab380a834) fix code cell - [`beea89c`](https://github.com/langchain-ai/docs/commit/beea89cff9e0826b6d1cd6ea0f05cca451ea9c79) adapt js code block ### 📊 Changes **1 file changed** (+16 additions, -35 deletions) <details> <summary>View changed files</summary> 📝 `src/oss/langchain/messages.mdx` (+16 -35) </details> ### 📄 Description Currently we split the streaming loop and combination into separate code blocks. There are a few problems with the code block for combining chunks: 1. It doesn't work (we sum an AIMessage, which results in a ChatPromptTemplate): ```python from langchain_core.messages import AIMessage, AIMessageChunk chunks = [AIMessageChunk("foo"), AIMessageChunk(" bar")] final_message = sum(chunks, AIMessage("")) # ChatPromptTemplate ``` 2. More nitpicky, but I think aggregating chunks is important and also concise enough that we can display it in the first cell with just two additional lines. Here we demonstrate aggregation in the first cell (and also remove an import). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-17 17:21:12 -05:00
yindo closed this issue 2026-02-17 17:21:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#826