@langchain/core 0.3.41 → 0.3.43

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.
@@ -84,11 +84,23 @@ class BaseMessage extends serializable_js_1.Serializable {
84
84
  };
85
85
  }
86
86
  /**
87
- * @deprecated
88
- * Use {@link BaseMessage.content} instead.
87
+ * Get text content of the message.
89
88
  */
90
89
  get text() {
91
- return typeof this.content === "string" ? this.content : "";
90
+ if (typeof this.content === "string") {
91
+ return this.content;
92
+ }
93
+ if (!Array.isArray(this.content))
94
+ return "";
95
+ return this.content
96
+ .map((c) => {
97
+ if (typeof c === "string")
98
+ return c;
99
+ if (c.type === "text")
100
+ return c.text;
101
+ return "";
102
+ })
103
+ .join("");
92
104
  }
93
105
  /** The type of the message. */
94
106
  getType() {
@@ -97,8 +97,7 @@ export declare abstract class BaseMessage extends Serializable implements BaseMe
97
97
  lc_serializable: boolean;
98
98
  get lc_aliases(): Record<string, string>;
99
99
  /**
100
- * @deprecated
101
- * Use {@link BaseMessage.content} instead.
100
+ * Get text content of the message.
102
101
  */
103
102
  get text(): string;
104
103
  /** The content of the message. */
@@ -79,11 +79,23 @@ export class BaseMessage extends Serializable {
79
79
  };
80
80
  }
81
81
  /**
82
- * @deprecated
83
- * Use {@link BaseMessage.content} instead.
82
+ * Get text content of the message.
84
83
  */
85
84
  get text() {
86
- return typeof this.content === "string" ? this.content : "";
85
+ if (typeof this.content === "string") {
86
+ return this.content;
87
+ }
88
+ if (!Array.isArray(this.content))
89
+ return "";
90
+ return this.content
91
+ .map((c) => {
92
+ if (typeof c === "string")
93
+ return c;
94
+ if (c.type === "text")
95
+ return c.text;
96
+ return "";
97
+ })
98
+ .join("");
87
99
  }
88
100
  /** The type of the message. */
89
101
  getType() {
@@ -96,9 +96,9 @@ export declare class ChatMessagePromptTemplate<RunInput extends InputValues = an
96
96
  constructor(prompt: BaseStringPromptTemplate<InputValues<Extract<keyof RunInput, string>>>, role: string);
97
97
  constructor(fields: ChatMessagePromptTemplateFields<InputValues<Extract<keyof RunInput, string>>>);
98
98
  format(values: RunInput): Promise<BaseMessage>;
99
- static fromTemplate(template: string, role: string, options?: {
99
+ static fromTemplate<RunInput extends InputValues = Symbol, T extends string = string>(template: T, role: string, options?: {
100
100
  templateFormat?: TemplateFormat;
101
- }): ChatMessagePromptTemplate<any>;
101
+ }): ChatMessagePromptTemplate<ExtractedFStringParams<T, RunInput>>;
102
102
  }
103
103
  interface _TextTemplateParam {
104
104
  text?: string | Record<string, any>;
@@ -51,6 +51,9 @@ class AsyncLocalStorageProvider {
51
51
  }
52
52
  if (previousValue !== undefined &&
53
53
  previousValue[globals_js_1._CONTEXT_VARIABLES_KEY] !== undefined) {
54
+ if (runTree === undefined) {
55
+ runTree = {};
56
+ }
54
57
  runTree[globals_js_1._CONTEXT_VARIABLES_KEY] =
55
58
  previousValue[globals_js_1._CONTEXT_VARIABLES_KEY];
56
59
  }
@@ -47,6 +47,9 @@ class AsyncLocalStorageProvider {
47
47
  }
48
48
  if (previousValue !== undefined &&
49
49
  previousValue[_CONTEXT_VARIABLES_KEY] !== undefined) {
50
+ if (runTree === undefined) {
51
+ runTree = {};
52
+ }
50
53
  runTree[_CONTEXT_VARIABLES_KEY] =
51
54
  previousValue[_CONTEXT_VARIABLES_KEY];
52
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/core",
3
- "version": "0.3.41",
3
+ "version": "0.3.43",
4
4
  "description": "Core LangChain.js abstractions and schemas",
5
5
  "type": "module",
6
6
  "engines": {