@langchain/core 0.1.60 → 0.1.62

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.
@@ -220,7 +220,9 @@ class BaseLanguageModel extends BaseLangChain {
220
220
  * @param callOptions Call options for the model
221
221
  * @returns A unique cache key.
222
222
  */
223
- _getSerializedCacheKeyParametersForCall(callOptions) {
223
+ _getSerializedCacheKeyParametersForCall(
224
+ // TODO: Fix when we remove the RunnableLambda backwards compatibility shim.
225
+ { config, ...callOptions }) {
224
226
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
225
227
  const params = {
226
228
  ...this._identifyingParams(),
@@ -180,7 +180,9 @@ export declare abstract class BaseLanguageModel<RunOutput = any, CallOptions ext
180
180
  * @param callOptions Call options for the model
181
181
  * @returns A unique cache key.
182
182
  */
183
- protected _getSerializedCacheKeyParametersForCall(callOptions: CallOptions): string;
183
+ protected _getSerializedCacheKeyParametersForCall({ config, ...callOptions }: CallOptions & {
184
+ config?: RunnableConfig;
185
+ }): string;
184
186
  /**
185
187
  * @deprecated
186
188
  * Return a json-like object representing this LLM.
@@ -212,7 +212,9 @@ export class BaseLanguageModel extends BaseLangChain {
212
212
  * @param callOptions Call options for the model
213
213
  * @returns A unique cache key.
214
214
  */
215
- _getSerializedCacheKeyParametersForCall(callOptions) {
215
+ _getSerializedCacheKeyParametersForCall(
216
+ // TODO: Fix when we remove the RunnableLambda backwards compatibility shim.
217
+ { config, ...callOptions }) {
216
218
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
217
219
  const params = {
218
220
  ...this._identifyingParams(),
@@ -53,6 +53,8 @@ class BaseRetriever extends base_js_1.Runnable {
53
53
  return this.getRelevantDocuments(input, (0, config_js_1.ensureConfig)(options));
54
54
  }
55
55
  /**
56
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
57
+ *
56
58
  * Main method used to retrieve relevant documents. It takes a query
57
59
  * string and an optional configuration object, and returns a promise that
58
60
  * resolves to an array of `Document` objects. This method handles the
@@ -33,6 +33,8 @@ export declare abstract class BaseRetriever<Metadata extends Record<string, any>
33
33
  _getRelevantDocuments(_query: string, _callbacks?: CallbackManagerForRetrieverRun): Promise<DocumentInterface<Metadata>[]>;
34
34
  invoke(input: string, options?: RunnableConfig): Promise<DocumentInterface<Metadata>[]>;
35
35
  /**
36
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
37
+ *
36
38
  * Main method used to retrieve relevant documents. It takes a query
37
39
  * string and an optional configuration object, and returns a promise that
38
40
  * resolves to an array of `Document` objects. This method handles the
@@ -50,6 +50,8 @@ export class BaseRetriever extends Runnable {
50
50
  return this.getRelevantDocuments(input, ensureConfig(options));
51
51
  }
52
52
  /**
53
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
54
+ *
53
55
  * Main method used to retrieve relevant documents. It takes a query
54
56
  * string and an optional configuration object, and returns a promise that
55
57
  * resolves to an array of `Document` objects. This method handles the
@@ -16,6 +16,7 @@ const root_listener_js_1 = require("../tracers/root_listener.cjs");
16
16
  const utils_js_1 = require("./utils.cjs");
17
17
  const index_js_1 = require("../singletons/index.cjs");
18
18
  const graph_js_1 = require("./graph.cjs");
19
+ const wrappers_js_1 = require("./wrappers.cjs");
19
20
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
21
  function _coerceToDict(value, defaultKey) {
21
22
  return value &&
@@ -448,46 +449,16 @@ class Runnable extends serializable_js_1.Serializable {
448
449
  await runnableStreamConsumePromise;
449
450
  }
450
451
  }
451
- /**
452
- * Generate a stream of events emitted by the internal steps of the runnable.
453
- *
454
- * Use to create an iterator over StreamEvents that provide real-time information
455
- * about the progress of the runnable, including StreamEvents from intermediate
456
- * results.
457
- *
458
- * A StreamEvent is a dictionary with the following schema:
459
- *
460
- * - `event`: string - Event names are of the format: on_[runnable_type]_(start|stream|end).
461
- * - `name`: string - The name of the runnable that generated the event.
462
- * - `run_id`: string - Randomly generated ID associated with the given execution of
463
- * the runnable that emitted the event. A child runnable that gets invoked as part of the execution of a
464
- * parent runnable is assigned its own unique ID.
465
- * - `tags`: string[] - The tags of the runnable that generated the event.
466
- * - `metadata`: Record<string, any> - The metadata of the runnable that generated the event.
467
- * - `data`: Record<string, any>
468
- *
469
- * Below is a table that illustrates some events that might be emitted by various
470
- * chains. Metadata fields have been omitted from the table for brevity.
471
- * Chain definitions have been included after the table.
472
- *
473
- * | event | name | chunk | input | output |
474
- * |----------------------|------------------|------------------------------------|-----------------------------------------------|-------------------------------------------------|
475
- * | on_llm_start | [model name] | | {'input': 'hello'} | |
476
- * | on_llm_stream | [model name] | 'Hello' OR AIMessageChunk("hello") | | |
477
- * | on_llm_end | [model name] | | 'Hello human!' |
478
- * | on_chain_start | format_docs | | | |
479
- * | on_chain_stream | format_docs | "hello world!, goodbye world!" | | |
480
- * | on_chain_end | format_docs | | [Document(...)] | "hello world!, goodbye world!" |
481
- * | on_tool_start | some_tool | | {"x": 1, "y": "2"} | |
482
- * | on_tool_stream | some_tool | {"x": 1, "y": "2"} | | |
483
- * | on_tool_end | some_tool | | | {"x": 1, "y": "2"} |
484
- * | on_retriever_start | [retriever name] | | {"query": "hello"} | |
485
- * | on_retriever_chunk | [retriever name] | {documents: [...]} | | |
486
- * | on_retriever_end | [retriever name] | | {"query": "hello"} | {documents: [...]} |
487
- * | on_prompt_start | [template_name] | | {"question": "hello"} | |
488
- * | on_prompt_end | [template_name] | | {"question": "hello"} | ChatPromptValue(messages: [SystemMessage, ...]) |
489
- */
490
452
  async *streamEvents(input, options, streamOptions) {
453
+ if (options.encoding === "text/event-stream") {
454
+ const stream = await this._streamEvents(input, options, streamOptions);
455
+ yield* (0, wrappers_js_1.convertToHttpEventStream)(stream);
456
+ }
457
+ else {
458
+ yield* this._streamEvents(input, options, streamOptions);
459
+ }
460
+ }
461
+ async *_streamEvents(input, options, streamOptions) {
491
462
  if (options.version !== "v1") {
492
463
  throw new Error(`Only version "v1" of the events schema is currently supported.`);
493
464
  }
@@ -199,6 +199,13 @@ export declare abstract class Runnable<RunInput = any, RunOutput = any, CallOpti
199
199
  streamEvents(input: RunInput, options: Partial<CallOptions> & {
200
200
  version: "v1";
201
201
  }, streamOptions?: Omit<LogStreamCallbackHandlerInput, "autoClose">): AsyncGenerator<StreamEvent>;
202
+ streamEvents(input: RunInput, options: Partial<CallOptions> & {
203
+ version: "v1";
204
+ encoding: "text/event-stream";
205
+ }, streamOptions?: Omit<LogStreamCallbackHandlerInput, "autoClose">): AsyncGenerator<Uint8Array>;
206
+ _streamEvents(input: RunInput, options: Partial<CallOptions> & {
207
+ version: "v1";
208
+ }, streamOptions?: Omit<LogStreamCallbackHandlerInput, "autoClose">): AsyncGenerator<StreamEvent>;
202
209
  static isRunnable(thing: any): thing is Runnable;
203
210
  /**
204
211
  * Bind lifecycle listeners to a Runnable, returning a new Runnable.
@@ -257,6 +264,10 @@ export declare class RunnableBinding<RunInput, RunOutput, CallOptions extends Ru
257
264
  streamEvents(input: RunInput, options: Partial<CallOptions> & {
258
265
  version: "v1";
259
266
  }, streamOptions?: Omit<LogStreamCallbackHandlerInput, "autoClose">): AsyncGenerator<StreamEvent>;
267
+ streamEvents(input: RunInput, options: Partial<CallOptions> & {
268
+ version: "v1";
269
+ encoding: "text/event-stream";
270
+ }, streamOptions?: Omit<LogStreamCallbackHandlerInput, "autoClose">): AsyncGenerator<Uint8Array>;
260
271
  static isRunnableBinding(thing: any): thing is RunnableBinding<any, any, any>;
261
272
  /**
262
273
  * Bind lifecycle listeners to a Runnable, returning a new Runnable.
@@ -10,6 +10,7 @@ import { RootListenersTracer } from "../tracers/root_listener.js";
10
10
  import { _RootEventFilter, isRunnableInterface } from "./utils.js";
11
11
  import { AsyncLocalStorageProviderSingleton } from "../singletons/index.js";
12
12
  import { Graph } from "./graph.js";
13
+ import { convertToHttpEventStream } from "./wrappers.js";
13
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
15
  export function _coerceToDict(value, defaultKey) {
15
16
  return value &&
@@ -441,46 +442,16 @@ export class Runnable extends Serializable {
441
442
  await runnableStreamConsumePromise;
442
443
  }
443
444
  }
444
- /**
445
- * Generate a stream of events emitted by the internal steps of the runnable.
446
- *
447
- * Use to create an iterator over StreamEvents that provide real-time information
448
- * about the progress of the runnable, including StreamEvents from intermediate
449
- * results.
450
- *
451
- * A StreamEvent is a dictionary with the following schema:
452
- *
453
- * - `event`: string - Event names are of the format: on_[runnable_type]_(start|stream|end).
454
- * - `name`: string - The name of the runnable that generated the event.
455
- * - `run_id`: string - Randomly generated ID associated with the given execution of
456
- * the runnable that emitted the event. A child runnable that gets invoked as part of the execution of a
457
- * parent runnable is assigned its own unique ID.
458
- * - `tags`: string[] - The tags of the runnable that generated the event.
459
- * - `metadata`: Record<string, any> - The metadata of the runnable that generated the event.
460
- * - `data`: Record<string, any>
461
- *
462
- * Below is a table that illustrates some events that might be emitted by various
463
- * chains. Metadata fields have been omitted from the table for brevity.
464
- * Chain definitions have been included after the table.
465
- *
466
- * | event | name | chunk | input | output |
467
- * |----------------------|------------------|------------------------------------|-----------------------------------------------|-------------------------------------------------|
468
- * | on_llm_start | [model name] | | {'input': 'hello'} | |
469
- * | on_llm_stream | [model name] | 'Hello' OR AIMessageChunk("hello") | | |
470
- * | on_llm_end | [model name] | | 'Hello human!' |
471
- * | on_chain_start | format_docs | | | |
472
- * | on_chain_stream | format_docs | "hello world!, goodbye world!" | | |
473
- * | on_chain_end | format_docs | | [Document(...)] | "hello world!, goodbye world!" |
474
- * | on_tool_start | some_tool | | {"x": 1, "y": "2"} | |
475
- * | on_tool_stream | some_tool | {"x": 1, "y": "2"} | | |
476
- * | on_tool_end | some_tool | | | {"x": 1, "y": "2"} |
477
- * | on_retriever_start | [retriever name] | | {"query": "hello"} | |
478
- * | on_retriever_chunk | [retriever name] | {documents: [...]} | | |
479
- * | on_retriever_end | [retriever name] | | {"query": "hello"} | {documents: [...]} |
480
- * | on_prompt_start | [template_name] | | {"question": "hello"} | |
481
- * | on_prompt_end | [template_name] | | {"question": "hello"} | ChatPromptValue(messages: [SystemMessage, ...]) |
482
- */
483
445
  async *streamEvents(input, options, streamOptions) {
446
+ if (options.encoding === "text/event-stream") {
447
+ const stream = await this._streamEvents(input, options, streamOptions);
448
+ yield* convertToHttpEventStream(stream);
449
+ }
450
+ else {
451
+ yield* this._streamEvents(input, options, streamOptions);
452
+ }
453
+ }
454
+ async *_streamEvents(input, options, streamOptions) {
484
455
  if (options.version !== "v1") {
485
456
  throw new Error(`Only version "v1" of the events schema is currently supported.`);
486
457
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RunnableWithMessageHistory = exports.RunnableBranch = exports.RouterRunnable = exports.RunnablePassthrough = exports.ensureConfig = exports.patchConfig = exports.getCallbackManagerForConfig = exports._coerceToRunnable = exports.RunnablePick = exports.RunnableAssign = exports.RunnableWithFallbacks = exports.RunnableLambda = exports.RunnableParallel = exports.RunnableMap = exports.RunnableSequence = exports.RunnableRetry = exports.RunnableEach = exports.RunnableBinding = exports.Runnable = void 0;
3
+ exports.RunnableWithMessageHistory = exports.RunnableBranch = exports.RouterRunnable = exports.RunnablePassthrough = exports.mergeConfigs = exports.ensureConfig = exports.patchConfig = exports.getCallbackManagerForConfig = exports._coerceToRunnable = exports.RunnablePick = exports.RunnableAssign = exports.RunnableWithFallbacks = exports.RunnableLambda = exports.RunnableParallel = exports.RunnableMap = exports.RunnableSequence = exports.RunnableRetry = exports.RunnableEach = exports.RunnableBinding = exports.Runnable = void 0;
4
4
  var base_js_1 = require("./base.cjs");
5
5
  Object.defineProperty(exports, "Runnable", { enumerable: true, get: function () { return base_js_1.Runnable; } });
6
6
  Object.defineProperty(exports, "RunnableBinding", { enumerable: true, get: function () { return base_js_1.RunnableBinding; } });
@@ -18,6 +18,7 @@ var config_js_1 = require("./config.cjs");
18
18
  Object.defineProperty(exports, "getCallbackManagerForConfig", { enumerable: true, get: function () { return config_js_1.getCallbackManagerForConfig; } });
19
19
  Object.defineProperty(exports, "patchConfig", { enumerable: true, get: function () { return config_js_1.patchConfig; } });
20
20
  Object.defineProperty(exports, "ensureConfig", { enumerable: true, get: function () { return config_js_1.ensureConfig; } });
21
+ Object.defineProperty(exports, "mergeConfigs", { enumerable: true, get: function () { return config_js_1.mergeConfigs; } });
21
22
  var passthrough_js_1 = require("./passthrough.cjs");
22
23
  Object.defineProperty(exports, "RunnablePassthrough", { enumerable: true, get: function () { return passthrough_js_1.RunnablePassthrough; } });
23
24
  var router_js_1 = require("./router.cjs");
@@ -1,6 +1,6 @@
1
1
  export { type RunnableFunc, type RunnableLike, type RunnableRetryFailedAttemptHandler, Runnable, type RunnableBindingArgs, RunnableBinding, RunnableEach, RunnableRetry, RunnableSequence, RunnableMap, RunnableParallel, RunnableLambda, RunnableWithFallbacks, RunnableAssign, RunnablePick, _coerceToRunnable, } from "./base.js";
2
2
  export { type RunnableBatchOptions, type RunnableInterface, type RunnableIOSchema, } from "./types.js";
3
- export { type RunnableConfig, getCallbackManagerForConfig, patchConfig, ensureConfig, } from "./config.js";
3
+ export { type RunnableConfig, getCallbackManagerForConfig, patchConfig, ensureConfig, mergeConfigs, } from "./config.js";
4
4
  export { RunnablePassthrough } from "./passthrough.js";
5
5
  export { type RouterInput, RouterRunnable } from "./router.js";
6
6
  export { RunnableBranch, type Branch, type BranchLike } from "./branch.js";
@@ -1,5 +1,5 @@
1
1
  export { Runnable, RunnableBinding, RunnableEach, RunnableRetry, RunnableSequence, RunnableMap, RunnableParallel, RunnableLambda, RunnableWithFallbacks, RunnableAssign, RunnablePick, _coerceToRunnable, } from "./base.js";
2
- export { getCallbackManagerForConfig, patchConfig, ensureConfig, } from "./config.js";
2
+ export { getCallbackManagerForConfig, patchConfig, ensureConfig, mergeConfigs, } from "./config.js";
3
3
  export { RunnablePassthrough } from "./passthrough.js";
4
4
  export { RouterRunnable } from "./router.js";
5
5
  export { RunnableBranch } from "./branch.js";
@@ -30,5 +30,9 @@ export declare class RemoteRunnable<RunInput, RunOutput, CallOptions extends Run
30
30
  streamEvents(input: RunInput, options: Partial<CallOptions> & {
31
31
  version: "v1";
32
32
  }, streamOptions?: Omit<LogStreamCallbackHandlerInput, "autoClose">): AsyncGenerator<StreamEvent>;
33
+ streamEvents(input: RunInput, options: Partial<CallOptions> & {
34
+ version: "v1";
35
+ encoding: "text/event-stream";
36
+ }, streamOptions?: Omit<LogStreamCallbackHandlerInput, "autoClose">): AsyncGenerator<Uint8Array>;
33
37
  }
34
38
  export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertToHttpEventStream = void 0;
4
+ const stream_js_1 = require("../utils/stream.cjs");
5
+ function convertToHttpEventStream(stream) {
6
+ const encoder = new TextEncoder();
7
+ const finalStream = new ReadableStream({
8
+ async start(controller) {
9
+ for await (const chunk of stream) {
10
+ controller.enqueue(encoder.encode(`event: data\ndata: ${JSON.stringify(chunk)}\n\n`));
11
+ }
12
+ controller.enqueue(encoder.encode("event: end\n\n"));
13
+ controller.close();
14
+ },
15
+ });
16
+ return stream_js_1.IterableReadableStream.fromReadableStream(finalStream);
17
+ }
18
+ exports.convertToHttpEventStream = convertToHttpEventStream;
@@ -0,0 +1,2 @@
1
+ import { IterableReadableStream } from "../utils/stream.js";
2
+ export declare function convertToHttpEventStream(stream: AsyncGenerator): IterableReadableStream<Uint8Array>;
@@ -0,0 +1,14 @@
1
+ import { IterableReadableStream } from "../utils/stream.js";
2
+ export function convertToHttpEventStream(stream) {
3
+ const encoder = new TextEncoder();
4
+ const finalStream = new ReadableStream({
5
+ async start(controller) {
6
+ for await (const chunk of stream) {
7
+ controller.enqueue(encoder.encode(`event: data\ndata: ${JSON.stringify(chunk)}\n\n`));
8
+ }
9
+ controller.enqueue(encoder.encode("event: end\n\n"));
10
+ controller.close();
11
+ },
12
+ });
13
+ return IterableReadableStream.fromReadableStream(finalStream);
14
+ }
package/dist/tools.cjs CHANGED
@@ -49,6 +49,8 @@ class StructuredTool extends base_js_1.BaseLangChain {
49
49
  return this.call(input, (0, config_js_1.ensureConfig)(config));
50
50
  }
51
51
  /**
52
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
53
+ *
52
54
  * Calls the tool with the provided argument, configuration, and tags. It
53
55
  * parses the input according to the schema, handles any errors, and
54
56
  * manages callbacks.
@@ -100,6 +102,8 @@ class Tool extends StructuredTool {
100
102
  });
101
103
  }
102
104
  /**
105
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
106
+ *
103
107
  * Calls the tool with the provided argument and callbacks. It handles
104
108
  * string inputs specifically.
105
109
  * @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.
@@ -143,6 +147,9 @@ class DynamicTool extends Tool {
143
147
  this.func = fields.func;
144
148
  this.returnDirect = fields.returnDirect ?? this.returnDirect;
145
149
  }
150
+ /**
151
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
152
+ */
146
153
  async call(arg, configArg) {
147
154
  const config = (0, manager_js_1.parseCallbackConfigArg)(configArg);
148
155
  if (config.runName === undefined) {
@@ -198,6 +205,9 @@ class DynamicStructuredTool extends StructuredTool {
198
205
  this.returnDirect = fields.returnDirect ?? this.returnDirect;
199
206
  this.schema = fields.schema;
200
207
  }
208
+ /**
209
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
210
+ */
201
211
  async call(arg, configArg,
202
212
  /** @deprecated */
203
213
  tags) {
package/dist/tools.d.ts CHANGED
@@ -21,6 +21,8 @@ export interface StructuredToolInterface<T extends z.ZodObject<any, any, any, an
21
21
  lc_namespace: string[];
22
22
  schema: T | z.ZodEffects<T>;
23
23
  /**
24
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
25
+ *
24
26
  * Calls the tool with the provided argument, configuration, and tags. It
25
27
  * parses the input according to the schema, handles any errors, and
26
28
  * manages callbacks.
@@ -52,6 +54,8 @@ export declare abstract class StructuredTool<T extends z.ZodObject<any, any, any
52
54
  */
53
55
  invoke(input: (z.output<T> extends string ? string : never) | z.input<T>, config?: RunnableConfig): Promise<string>;
54
56
  /**
57
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
58
+ *
55
59
  * Calls the tool with the provided argument, configuration, and tags. It
56
60
  * parses the input according to the schema, handles any errors, and
57
61
  * manages callbacks.
@@ -69,6 +73,8 @@ export declare abstract class StructuredTool<T extends z.ZodObject<any, any, any
69
73
  }
70
74
  export interface ToolInterface extends StructuredToolInterface {
71
75
  /**
76
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
77
+ *
72
78
  * Calls the tool with the provided argument and callbacks. It handles
73
79
  * string inputs specifically.
74
80
  * @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.
@@ -92,6 +98,8 @@ export declare abstract class Tool extends StructuredTool {
92
98
  }>;
93
99
  constructor(fields?: ToolParams);
94
100
  /**
101
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
102
+ *
95
103
  * Calls the tool with the provided argument and callbacks. It handles
96
104
  * string inputs specifically.
97
105
  * @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.
@@ -127,6 +135,9 @@ export declare class DynamicTool extends Tool {
127
135
  description: string;
128
136
  func: DynamicToolInput["func"];
129
137
  constructor(fields: DynamicToolInput);
138
+ /**
139
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
140
+ */
130
141
  call(arg: string | undefined | z.input<this["schema"]>, configArg?: RunnableConfig | Callbacks): Promise<string>;
131
142
  /** @ignore */
132
143
  _call(input: string, runManager?: CallbackManagerForToolRun, config?: RunnableConfig): Promise<string>;
@@ -144,6 +155,9 @@ export declare class DynamicStructuredTool<T extends z.ZodObject<any, any, any,
144
155
  func: DynamicStructuredToolInput["func"];
145
156
  schema: T;
146
157
  constructor(fields: DynamicStructuredToolInput<T>);
158
+ /**
159
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
160
+ */
147
161
  call(arg: z.output<T>, configArg?: RunnableConfig | Callbacks,
148
162
  /** @deprecated */
149
163
  tags?: string[]): Promise<string>;
package/dist/tools.js CHANGED
@@ -45,6 +45,8 @@ export class StructuredTool extends BaseLangChain {
45
45
  return this.call(input, ensureConfig(config));
46
46
  }
47
47
  /**
48
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
49
+ *
48
50
  * Calls the tool with the provided argument, configuration, and tags. It
49
51
  * parses the input according to the schema, handles any errors, and
50
52
  * manages callbacks.
@@ -95,6 +97,8 @@ export class Tool extends StructuredTool {
95
97
  });
96
98
  }
97
99
  /**
100
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
101
+ *
98
102
  * Calls the tool with the provided argument and callbacks. It handles
99
103
  * string inputs specifically.
100
104
  * @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.
@@ -137,6 +141,9 @@ export class DynamicTool extends Tool {
137
141
  this.func = fields.func;
138
142
  this.returnDirect = fields.returnDirect ?? this.returnDirect;
139
143
  }
144
+ /**
145
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
146
+ */
140
147
  async call(arg, configArg) {
141
148
  const config = parseCallbackConfigArg(configArg);
142
149
  if (config.runName === undefined) {
@@ -191,6 +198,9 @@ export class DynamicStructuredTool extends StructuredTool {
191
198
  this.returnDirect = fields.returnDirect ?? this.returnDirect;
192
199
  this.schema = fields.schema;
193
200
  }
201
+ /**
202
+ * @deprecated Use .invoke() instead. Will be removed in 0.3.0.
203
+ */
194
204
  async call(arg, configArg,
195
205
  /** @deprecated */
196
206
  tags) {
@@ -11,9 +11,9 @@ function _coerceToDict(value, defaultKey) {
11
11
  function stripNonAlphanumeric(input) {
12
12
  return input.replace(/[-:.]/g, "");
13
13
  }
14
- function convertToDottedOrderFormat(epoch, runId) {
15
- return (stripNonAlphanumeric(`${new Date(epoch).toISOString().slice(0, -1)}000Z`) +
16
- runId);
14
+ function convertToDottedOrderFormat(epoch, runId, executionOrder) {
15
+ const paddedOrder = executionOrder.toFixed(0).slice(0, 3).padStart(3, "0");
16
+ return (stripNonAlphanumeric(`${new Date(epoch).toISOString().slice(0, -1)}${paddedOrder}Z`) + runId);
17
17
  }
18
18
  class BaseTracer extends base_js_1.BaseCallbackHandler {
19
19
  constructor(_fields) {
@@ -42,7 +42,7 @@ class BaseTracer extends base_js_1.BaseCallbackHandler {
42
42
  parentRun.child_runs.push(childRun);
43
43
  }
44
44
  async _startTrace(run) {
45
- const currentDottedOrder = convertToDottedOrderFormat(run.start_time, run.id);
45
+ const currentDottedOrder = convertToDottedOrderFormat(run.start_time, run.id, run.execution_order);
46
46
  const storedRun = { ...run };
47
47
  if (storedRun.parent_run_id !== undefined) {
48
48
  const parentRun = this.runMap.get(storedRun.parent_run_id);
@@ -8,9 +8,9 @@ function _coerceToDict(value, defaultKey) {
8
8
  function stripNonAlphanumeric(input) {
9
9
  return input.replace(/[-:.]/g, "");
10
10
  }
11
- function convertToDottedOrderFormat(epoch, runId) {
12
- return (stripNonAlphanumeric(`${new Date(epoch).toISOString().slice(0, -1)}000Z`) +
13
- runId);
11
+ function convertToDottedOrderFormat(epoch, runId, executionOrder) {
12
+ const paddedOrder = executionOrder.toFixed(0).slice(0, 3).padStart(3, "0");
13
+ return (stripNonAlphanumeric(`${new Date(epoch).toISOString().slice(0, -1)}${paddedOrder}Z`) + runId);
14
14
  }
15
15
  export class BaseTracer extends BaseCallbackHandler {
16
16
  constructor(_fields) {
@@ -39,7 +39,7 @@ export class BaseTracer extends BaseCallbackHandler {
39
39
  parentRun.child_runs.push(childRun);
40
40
  }
41
41
  async _startTrace(run) {
42
- const currentDottedOrder = convertToDottedOrderFormat(run.start_time, run.id);
42
+ const currentDottedOrder = convertToDottedOrderFormat(run.start_time, run.id, run.execution_order);
43
43
  const storedRun = { ...run };
44
44
  if (storedRun.parent_run_id !== undefined) {
45
45
  const parentRun = this.runMap.get(storedRun.parent_run_id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/core",
3
- "version": "0.1.60",
3
+ "version": "0.1.62",
4
4
  "description": "Core LangChain.js abstractions and schemas",
5
5
  "type": "module",
6
6
  "engines": {