@langchain/core 0.3.33 → 0.3.34

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.
@@ -176,6 +176,7 @@ class BaseChatModel extends base_js_1.BaseLanguageModel {
176
176
  // Bail out if _streamResponseChunks not overridden
177
177
  const hasStreamingHandler = !!runManagers?.[0].handlers.find(base_js_3.callbackHandlerPrefersStreaming);
178
178
  if (hasStreamingHandler &&
179
+ !this.disableStreaming &&
179
180
  baseMessages.length === 1 &&
180
181
  this._streamResponseChunks !==
181
182
  BaseChatModel.prototype._streamResponseChunks) {
@@ -172,6 +172,7 @@ export class BaseChatModel extends BaseLanguageModel {
172
172
  // Bail out if _streamResponseChunks not overridden
173
173
  const hasStreamingHandler = !!runManagers?.[0].handlers.find(callbackHandlerPrefersStreaming);
174
174
  if (hasStreamingHandler &&
175
+ !this.disableStreaming &&
175
176
  baseMessages.length === 1 &&
176
177
  this._streamResponseChunks !==
177
178
  BaseChatModel.prototype._streamResponseChunks) {
@@ -503,13 +503,20 @@ function _coerceMessagePromptTemplateLike(messagePromptTemplateLike, extra) {
503
503
  if (Array.isArray(messagePromptTemplateLike) &&
504
504
  messagePromptTemplateLike[0] === "placeholder") {
505
505
  const messageContent = messagePromptTemplateLike[1];
506
- if (typeof messageContent !== "string" ||
507
- messageContent[0] !== "{" ||
508
- messageContent[messageContent.length - 1] !== "}") {
509
- throw new Error(`Invalid placeholder template: "${messagePromptTemplateLike[1]}". Expected a variable name surrounded by curly braces.`);
506
+ if (extra?.templateFormat === "mustache" &&
507
+ typeof messageContent === "string" &&
508
+ messageContent.slice(0, 2) === "{{" &&
509
+ messageContent.slice(-2) === "}}") {
510
+ const variableName = messageContent.slice(2, -2);
511
+ return new MessagesPlaceholder({ variableName, optional: true });
510
512
  }
511
- const variableName = messageContent.slice(1, -1);
512
- return new MessagesPlaceholder({ variableName, optional: true });
513
+ else if (typeof messageContent === "string" &&
514
+ messageContent[0] === "{" &&
515
+ messageContent[messageContent.length - 1] === "}") {
516
+ const variableName = messageContent.slice(1, -1);
517
+ return new MessagesPlaceholder({ variableName, optional: true });
518
+ }
519
+ throw new Error(`Invalid placeholder template for format ${extra?.templateFormat ?? `"f-string"`}: "${messagePromptTemplateLike[1]}". Expected a variable name surrounded by ${extra?.templateFormat === "mustache" ? "double" : "single"} curly braces.`);
513
520
  }
514
521
  const message = (0, index_js_1.coerceMessageLikeToMessage)(messagePromptTemplateLike);
515
522
  let templateData;
@@ -492,13 +492,20 @@ function _coerceMessagePromptTemplateLike(messagePromptTemplateLike, extra) {
492
492
  if (Array.isArray(messagePromptTemplateLike) &&
493
493
  messagePromptTemplateLike[0] === "placeholder") {
494
494
  const messageContent = messagePromptTemplateLike[1];
495
- if (typeof messageContent !== "string" ||
496
- messageContent[0] !== "{" ||
497
- messageContent[messageContent.length - 1] !== "}") {
498
- throw new Error(`Invalid placeholder template: "${messagePromptTemplateLike[1]}". Expected a variable name surrounded by curly braces.`);
495
+ if (extra?.templateFormat === "mustache" &&
496
+ typeof messageContent === "string" &&
497
+ messageContent.slice(0, 2) === "{{" &&
498
+ messageContent.slice(-2) === "}}") {
499
+ const variableName = messageContent.slice(2, -2);
500
+ return new MessagesPlaceholder({ variableName, optional: true });
499
501
  }
500
- const variableName = messageContent.slice(1, -1);
501
- return new MessagesPlaceholder({ variableName, optional: true });
502
+ else if (typeof messageContent === "string" &&
503
+ messageContent[0] === "{" &&
504
+ messageContent[messageContent.length - 1] === "}") {
505
+ const variableName = messageContent.slice(1, -1);
506
+ return new MessagesPlaceholder({ variableName, optional: true });
507
+ }
508
+ throw new Error(`Invalid placeholder template for format ${extra?.templateFormat ?? `"f-string"`}: "${messagePromptTemplateLike[1]}". Expected a variable name surrounded by ${extra?.templateFormat === "mustache" ? "double" : "single"} curly braces.`);
502
509
  }
503
510
  const message = coerceMessageLikeToMessage(messagePromptTemplateLike);
504
511
  let templateData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/core",
3
- "version": "0.3.33",
3
+ "version": "0.3.34",
4
4
  "description": "Core LangChain.js abstractions and schemas",
5
5
  "type": "module",
6
6
  "engines": {