@langchain/core 0.3.77 → 0.3.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -131,7 +131,8 @@ class AIMessageChunk extends base_js_1.BaseMessageChunk {
131
131
  tool_call_chunks: [],
132
132
  };
133
133
  }
134
- else if (fields.tool_call_chunks === undefined) {
134
+ else if (fields.tool_call_chunks === undefined ||
135
+ fields.tool_call_chunks.length === 0) {
135
136
  initParams = {
136
137
  ...fields,
137
138
  tool_calls: fields.tool_calls ?? [],
@@ -143,7 +144,8 @@ class AIMessageChunk extends base_js_1.BaseMessageChunk {
143
144
  };
144
145
  }
145
146
  else {
146
- const groupedToolCallChunks = fields.tool_call_chunks.reduce((acc, chunk) => {
147
+ const toolCallChunks = fields.tool_call_chunks ?? [];
148
+ const groupedToolCallChunks = toolCallChunks.reduce((acc, chunk) => {
147
149
  const matchedChunkIndex = acc.findIndex(([match]) => {
148
150
  // If chunk has an id and index, match if both are present
149
151
  if ("id" in chunk &&
@@ -125,7 +125,8 @@ export class AIMessageChunk extends BaseMessageChunk {
125
125
  tool_call_chunks: [],
126
126
  };
127
127
  }
128
- else if (fields.tool_call_chunks === undefined) {
128
+ else if (fields.tool_call_chunks === undefined ||
129
+ fields.tool_call_chunks.length === 0) {
129
130
  initParams = {
130
131
  ...fields,
131
132
  tool_calls: fields.tool_calls ?? [],
@@ -137,7 +138,8 @@ export class AIMessageChunk extends BaseMessageChunk {
137
138
  };
138
139
  }
139
140
  else {
140
- const groupedToolCallChunks = fields.tool_call_chunks.reduce((acc, chunk) => {
141
+ const toolCallChunks = fields.tool_call_chunks ?? [];
142
+ const groupedToolCallChunks = toolCallChunks.reduce((acc, chunk) => {
141
143
  const matchedChunkIndex = acc.findIndex(([match]) => {
142
144
  // If chunk has an id and index, match if both are present
143
145
  if ("id" in chunk &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/core",
3
- "version": "0.3.77",
3
+ "version": "0.3.79",
4
4
  "description": "Core LangChain.js abstractions and schemas",
5
5
  "type": "module",
6
6
  "engines": {