@langchain/core 0.3.67 → 0.3.68
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.
package/dist/messages/tool.cjs
CHANGED
|
@@ -51,6 +51,12 @@ class ToolMessage extends base_js_1.BaseMessage {
|
|
|
51
51
|
writable: true,
|
|
52
52
|
value: void 0
|
|
53
53
|
});
|
|
54
|
+
Object.defineProperty(this, "metadata", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
configurable: true,
|
|
57
|
+
writable: true,
|
|
58
|
+
value: void 0
|
|
59
|
+
});
|
|
54
60
|
/**
|
|
55
61
|
* Artifact of the Tool execution which is not meant to be sent to the model.
|
|
56
62
|
*
|
|
@@ -68,6 +74,7 @@ class ToolMessage extends base_js_1.BaseMessage {
|
|
|
68
74
|
this.tool_call_id = fields.tool_call_id;
|
|
69
75
|
this.artifact = fields.artifact;
|
|
70
76
|
this.status = fields.status;
|
|
77
|
+
this.metadata = fields.metadata;
|
|
71
78
|
}
|
|
72
79
|
_getType() {
|
|
73
80
|
return "tool";
|
package/dist/messages/tool.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface ToolMessageFieldsWithToolCallId extends ToolMessageFields {
|
|
|
18
18
|
* @version 0.2.19
|
|
19
19
|
*/
|
|
20
20
|
status?: "success" | "error";
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* Marker parameter for objects that tools can return directly.
|
|
@@ -44,6 +45,7 @@ export declare class ToolMessage extends BaseMessage implements DirectToolOutput
|
|
|
44
45
|
*/
|
|
45
46
|
status?: "success" | "error";
|
|
46
47
|
tool_call_id: string;
|
|
48
|
+
metadata?: Record<string, unknown>;
|
|
47
49
|
/**
|
|
48
50
|
* Artifact of the Tool execution which is not meant to be sent to the model.
|
|
49
51
|
*
|
package/dist/messages/tool.js
CHANGED
|
@@ -44,6 +44,12 @@ export class ToolMessage extends BaseMessage {
|
|
|
44
44
|
writable: true,
|
|
45
45
|
value: void 0
|
|
46
46
|
});
|
|
47
|
+
Object.defineProperty(this, "metadata", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true,
|
|
51
|
+
value: void 0
|
|
52
|
+
});
|
|
47
53
|
/**
|
|
48
54
|
* Artifact of the Tool execution which is not meant to be sent to the model.
|
|
49
55
|
*
|
|
@@ -61,6 +67,7 @@ export class ToolMessage extends BaseMessage {
|
|
|
61
67
|
this.tool_call_id = fields.tool_call_id;
|
|
62
68
|
this.artifact = fields.artifact;
|
|
63
69
|
this.status = fields.status;
|
|
70
|
+
this.metadata = fields.metadata;
|
|
64
71
|
}
|
|
65
72
|
_getType() {
|
|
66
73
|
return "tool";
|
package/dist/tools/index.cjs
CHANGED
|
@@ -73,6 +73,7 @@ class StructuredTool extends base_js_1.BaseLangChain {
|
|
|
73
73
|
fields?.verboseParsingErrors ?? this.verboseParsingErrors;
|
|
74
74
|
this.responseFormat = fields?.responseFormat ?? this.responseFormat;
|
|
75
75
|
this.defaultConfig = fields?.defaultConfig ?? this.defaultConfig;
|
|
76
|
+
this.metadata = fields?.metadata ?? this.metadata;
|
|
76
77
|
}
|
|
77
78
|
/**
|
|
78
79
|
* Invokes the tool with the provided input and configuration.
|
|
@@ -185,6 +186,7 @@ class StructuredTool extends base_js_1.BaseLangChain {
|
|
|
185
186
|
artifact,
|
|
186
187
|
toolCallId,
|
|
187
188
|
name: this.name,
|
|
189
|
+
metadata: this.metadata,
|
|
188
190
|
});
|
|
189
191
|
await runManager?.handleToolEnd(formattedOutput);
|
|
190
192
|
return formattedOutput;
|
|
@@ -360,7 +362,7 @@ function tool(func, fields) {
|
|
|
360
362
|
return new DynamicTool({
|
|
361
363
|
...fields,
|
|
362
364
|
description: fields.description ??
|
|
363
|
-
fields.schema
|
|
365
|
+
(fields.schema && (0, zod_js_1.getSchemaDescription)(fields.schema)) ??
|
|
364
366
|
`${fields.name} tool`,
|
|
365
367
|
func: async (input, runManager, config) => {
|
|
366
368
|
return new Promise((resolve, reject) => {
|
|
@@ -407,7 +409,7 @@ function tool(func, fields) {
|
|
|
407
409
|
});
|
|
408
410
|
}
|
|
409
411
|
function _formatToolOutput(params) {
|
|
410
|
-
const { content, artifact, toolCallId } = params;
|
|
412
|
+
const { content, artifact, toolCallId, metadata } = params;
|
|
411
413
|
if (toolCallId && !(0, tool_js_1.isDirectToolOutput)(content)) {
|
|
412
414
|
if (typeof content === "string" ||
|
|
413
415
|
(Array.isArray(content) &&
|
|
@@ -417,6 +419,7 @@ function _formatToolOutput(params) {
|
|
|
417
419
|
artifact,
|
|
418
420
|
tool_call_id: toolCallId,
|
|
419
421
|
name: params.name,
|
|
422
|
+
metadata,
|
|
420
423
|
});
|
|
421
424
|
}
|
|
422
425
|
else {
|
|
@@ -425,6 +428,7 @@ function _formatToolOutput(params) {
|
|
|
425
428
|
artifact,
|
|
426
429
|
tool_call_id: toolCallId,
|
|
427
430
|
name: params.name,
|
|
431
|
+
metadata,
|
|
428
432
|
});
|
|
429
433
|
}
|
|
430
434
|
}
|
package/dist/tools/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { mergeConfigs, ensureConfig, patchConfig, pickRunnableConfigKeys, } from
|
|
|
6
6
|
import { isDirectToolOutput, ToolMessage } from "../messages/tool.js";
|
|
7
7
|
import { AsyncLocalStorageProviderSingleton } from "../singletons/index.js";
|
|
8
8
|
import { _configHasToolCallId, _isToolCall, ToolInputParsingException, } from "./utils.js";
|
|
9
|
-
import { interopParseAsync, isSimpleStringZodSchema, isInteropZodSchema, } from "../utils/types/zod.js";
|
|
9
|
+
import { interopParseAsync, isSimpleStringZodSchema, isInteropZodSchema, getSchemaDescription, } from "../utils/types/zod.js";
|
|
10
10
|
import { validatesOnlyStrings } from "../utils/json_schema.js";
|
|
11
11
|
export { isLangChainTool, isRunnableToolLike, isStructuredTool, isStructuredToolParams, } from "./types.js";
|
|
12
12
|
export { ToolInputParsingException };
|
|
@@ -65,6 +65,7 @@ export class StructuredTool extends BaseLangChain {
|
|
|
65
65
|
fields?.verboseParsingErrors ?? this.verboseParsingErrors;
|
|
66
66
|
this.responseFormat = fields?.responseFormat ?? this.responseFormat;
|
|
67
67
|
this.defaultConfig = fields?.defaultConfig ?? this.defaultConfig;
|
|
68
|
+
this.metadata = fields?.metadata ?? this.metadata;
|
|
68
69
|
}
|
|
69
70
|
/**
|
|
70
71
|
* Invokes the tool with the provided input and configuration.
|
|
@@ -177,6 +178,7 @@ export class StructuredTool extends BaseLangChain {
|
|
|
177
178
|
artifact,
|
|
178
179
|
toolCallId,
|
|
179
180
|
name: this.name,
|
|
181
|
+
metadata: this.metadata,
|
|
180
182
|
});
|
|
181
183
|
await runManager?.handleToolEnd(formattedOutput);
|
|
182
184
|
return formattedOutput;
|
|
@@ -347,7 +349,7 @@ export function tool(func, fields) {
|
|
|
347
349
|
return new DynamicTool({
|
|
348
350
|
...fields,
|
|
349
351
|
description: fields.description ??
|
|
350
|
-
fields.schema
|
|
352
|
+
(fields.schema && getSchemaDescription(fields.schema)) ??
|
|
351
353
|
`${fields.name} tool`,
|
|
352
354
|
func: async (input, runManager, config) => {
|
|
353
355
|
return new Promise((resolve, reject) => {
|
|
@@ -394,7 +396,7 @@ export function tool(func, fields) {
|
|
|
394
396
|
});
|
|
395
397
|
}
|
|
396
398
|
function _formatToolOutput(params) {
|
|
397
|
-
const { content, artifact, toolCallId } = params;
|
|
399
|
+
const { content, artifact, toolCallId, metadata } = params;
|
|
398
400
|
if (toolCallId && !isDirectToolOutput(content)) {
|
|
399
401
|
if (typeof content === "string" ||
|
|
400
402
|
(Array.isArray(content) &&
|
|
@@ -404,6 +406,7 @@ function _formatToolOutput(params) {
|
|
|
404
406
|
artifact,
|
|
405
407
|
tool_call_id: toolCallId,
|
|
406
408
|
name: params.name,
|
|
409
|
+
metadata,
|
|
407
410
|
});
|
|
408
411
|
}
|
|
409
412
|
else {
|
|
@@ -412,6 +415,7 @@ function _formatToolOutput(params) {
|
|
|
412
415
|
artifact,
|
|
413
416
|
tool_call_id: toolCallId,
|
|
414
417
|
name: params.name,
|
|
418
|
+
metadata,
|
|
415
419
|
});
|
|
416
420
|
}
|
|
417
421
|
}
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -58,6 +58,10 @@ export interface ToolParams extends BaseLangChainParams {
|
|
|
58
58
|
* @default false
|
|
59
59
|
*/
|
|
60
60
|
verboseParsingErrors?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Metadata for the tool.
|
|
63
|
+
*/
|
|
64
|
+
metadata?: Record<string, unknown>;
|
|
61
65
|
}
|
|
62
66
|
export type ToolRunnableConfig<ConfigurableFieldType extends Record<string, any> = Record<string, any>> = RunnableConfig<ConfigurableFieldType> & {
|
|
63
67
|
toolCall?: ToolCall;
|