@langchain/core 0.3.27 → 0.3.28

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.
@@ -46,6 +46,22 @@ class BasePromptTemplate extends base_js_1.Runnable {
46
46
  writable: true,
47
47
  value: void 0
48
48
  });
49
+ /**
50
+ * Metadata to be used for tracing.
51
+ */
52
+ Object.defineProperty(this, "metadata", {
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true,
56
+ value: void 0
57
+ });
58
+ /** Tags to be used for tracing. */
59
+ Object.defineProperty(this, "tags", {
60
+ enumerable: true,
61
+ configurable: true,
62
+ writable: true,
63
+ value: void 0
64
+ });
49
65
  const { inputVariables } = input;
50
66
  if (inputVariables.includes("stop")) {
51
67
  throw new Error("Cannot have an input variable named 'stop', as it is used internally, please rename.");
@@ -81,7 +97,12 @@ class BasePromptTemplate extends base_js_1.Runnable {
81
97
  * @returns A Promise that resolves to the output of the prompt template.
82
98
  */
83
99
  async invoke(input, options) {
84
- return this._callWithConfig((input) => this.formatPromptValue(input), input, { ...options, runType: "prompt" });
100
+ const metadata = {
101
+ ...this.metadata,
102
+ ...options?.metadata,
103
+ };
104
+ const tags = [...(this.tags ?? []), ...(options?.tags ?? [])];
105
+ return this._callWithConfig((input) => this.formatPromptValue(input), input, { ...options, tags, metadata, runType: "prompt" });
85
106
  }
86
107
  /**
87
108
  * Return a json-like object representing this prompt template.
@@ -34,6 +34,12 @@ export declare abstract class BasePromptTemplate<RunInput extends InputValues =
34
34
  inputVariables: Array<Extract<keyof RunInput, string>>;
35
35
  outputParser?: BaseOutputParser;
36
36
  partialVariables: PartialValues<PartialVariableName>;
37
+ /**
38
+ * Metadata to be used for tracing.
39
+ */
40
+ metadata?: Record<string, unknown>;
41
+ /** Tags to be used for tracing. */
42
+ tags?: string[];
37
43
  constructor(input: BasePromptTemplateInput);
38
44
  abstract partial(values: PartialValues): Promise<BasePromptTemplate<RunInput, RunOutput, PartialVariableName>>;
39
45
  /**
@@ -43,6 +43,22 @@ export class BasePromptTemplate extends Runnable {
43
43
  writable: true,
44
44
  value: void 0
45
45
  });
46
+ /**
47
+ * Metadata to be used for tracing.
48
+ */
49
+ Object.defineProperty(this, "metadata", {
50
+ enumerable: true,
51
+ configurable: true,
52
+ writable: true,
53
+ value: void 0
54
+ });
55
+ /** Tags to be used for tracing. */
56
+ Object.defineProperty(this, "tags", {
57
+ enumerable: true,
58
+ configurable: true,
59
+ writable: true,
60
+ value: void 0
61
+ });
46
62
  const { inputVariables } = input;
47
63
  if (inputVariables.includes("stop")) {
48
64
  throw new Error("Cannot have an input variable named 'stop', as it is used internally, please rename.");
@@ -78,7 +94,12 @@ export class BasePromptTemplate extends Runnable {
78
94
  * @returns A Promise that resolves to the output of the prompt template.
79
95
  */
80
96
  async invoke(input, options) {
81
- return this._callWithConfig((input) => this.formatPromptValue(input), input, { ...options, runType: "prompt" });
97
+ const metadata = {
98
+ ...this.metadata,
99
+ ...options?.metadata,
100
+ };
101
+ const tags = [...(this.tags ?? []), ...(options?.tags ?? [])];
102
+ return this._callWithConfig((input) => this.formatPromptValue(input), input, { ...options, tags, metadata, runType: "prompt" });
82
103
  }
83
104
  /**
84
105
  * Return a json-like object representing this prompt template.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/core",
3
- "version": "0.3.27",
3
+ "version": "0.3.28",
4
4
  "description": "Core LangChain.js abstractions and schemas",
5
5
  "type": "module",
6
6
  "engines": {