@posthog/ai 6.6.0 → 7.1.0

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.
@@ -1,7 +1,7 @@
1
1
  import 'buffer';
2
2
  import * as uuid from 'uuid';
3
3
 
4
- var version = "6.6.0";
4
+ var version = "7.1.0";
5
5
 
6
6
  // Type guards for safer type checking
7
7
 
@@ -42,7 +42,7 @@ const getModelParams = params => {
42
42
  return {};
43
43
  }
44
44
  const modelParams = {};
45
- const paramKeys = ['temperature', 'max_tokens', 'max_completion_tokens', 'top_p', 'frequency_penalty', 'presence_penalty', 'n', 'stop', 'stream', 'streaming'];
45
+ const paramKeys = ['temperature', 'max_tokens', 'max_completion_tokens', 'top_p', 'frequency_penalty', 'presence_penalty', 'n', 'stop', 'stream', 'streaming', 'language', 'response_format', 'timestamp_granularities'];
46
46
  for (const key of paramKeys) {
47
47
  if (key in params && params[key] !== undefined) {
48
48
  modelParams[key] = params[key];
@@ -54,6 +54,15 @@ const withPrivacyMode = (client, privacyMode, input) => {
54
54
  return client.privacy_mode || privacyMode ? null : input;
55
55
  };
56
56
 
57
+ //#region rolldown:runtime
58
+ var __defProp = Object.defineProperty;
59
+ var __export = (target, all) => {
60
+ for (var name in all) __defProp(target, name, {
61
+ get: all[name],
62
+ enumerable: true
63
+ });
64
+ };
65
+
57
66
  function getDefaultExportFromCjs (x) {
58
67
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
59
68
  }
@@ -206,370 +215,304 @@ function requireCamelcase () {
206
215
 
207
216
  requireCamelcase();
208
217
 
218
+ //#region src/load/map_keys.ts
209
219
  function keyToJson(key, map) {
210
- return map?.[key] || snakeCase(key);
220
+ return map?.[key] || snakeCase(key);
211
221
  }
212
222
  function mapKeys(fields, mapper, map) {
213
- const mapped = {};
214
- for (const key in fields) {
215
- if (Object.hasOwn(fields, key)) {
216
- mapped[mapper(key, map)] = fields[key];
217
- }
218
- }
219
- return mapped;
223
+ const mapped = {};
224
+ for (const key in fields) if (Object.hasOwn(fields, key)) mapped[mapper(key, map)] = fields[key];
225
+ return mapped;
220
226
  }
221
227
 
228
+ //#region src/load/serializable.ts
229
+ var serializable_exports = {};
230
+ __export(serializable_exports, {
231
+ Serializable: () => Serializable,
232
+ get_lc_unique_name: () => get_lc_unique_name
233
+ });
222
234
  function shallowCopy(obj) {
223
- return Array.isArray(obj) ? [...obj] : { ...obj };
235
+ return Array.isArray(obj) ? [...obj] : { ...obj };
224
236
  }
225
237
  function replaceSecrets(root, secretsMap) {
226
- const result = shallowCopy(root);
227
- for (const [path, secretId] of Object.entries(secretsMap)) {
228
- const [last, ...partsReverse] = path.split(".").reverse();
229
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
230
- let current = result;
231
- for (const part of partsReverse.reverse()) {
232
- if (current[part] === undefined) {
233
- break;
234
- }
235
- current[part] = shallowCopy(current[part]);
236
- current = current[part];
237
- }
238
- if (current[last] !== undefined) {
239
- current[last] = {
240
- lc: 1,
241
- type: "secret",
242
- id: [secretId],
243
- };
244
- }
245
- }
246
- return result;
238
+ const result = shallowCopy(root);
239
+ for (const [path, secretId] of Object.entries(secretsMap)) {
240
+ const [last, ...partsReverse] = path.split(".").reverse();
241
+ let current = result;
242
+ for (const part of partsReverse.reverse()) {
243
+ if (current[part] === void 0) break;
244
+ current[part] = shallowCopy(current[part]);
245
+ current = current[part];
246
+ }
247
+ if (current[last] !== void 0) current[last] = {
248
+ lc: 1,
249
+ type: "secret",
250
+ id: [secretId]
251
+ };
252
+ }
253
+ return result;
247
254
  }
248
255
  /**
249
- * Get a unique name for the module, rather than parent class implementations.
250
- * Should not be subclassed, subclass lc_name above instead.
251
- */
252
- function get_lc_unique_name(
253
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
254
- serializableClass) {
255
- // "super" here would refer to the parent class of Serializable,
256
- // when we want the parent class of the module actually calling this method.
257
- const parentClass = Object.getPrototypeOf(serializableClass);
258
- const lcNameIsSubclassed = typeof serializableClass.lc_name === "function" &&
259
- (typeof parentClass.lc_name !== "function" ||
260
- serializableClass.lc_name() !== parentClass.lc_name());
261
- if (lcNameIsSubclassed) {
262
- return serializableClass.lc_name();
263
- }
264
- else {
265
- return serializableClass.name;
266
- }
267
- }
268
- class Serializable {
269
- /**
270
- * The name of the serializable. Override to provide an alias or
271
- * to preserve the serialized module name in minified environments.
272
- *
273
- * Implemented as a static method to support loading logic.
274
- */
275
- static lc_name() {
276
- return this.name;
277
- }
278
- /**
279
- * The final serialized identifier for the module.
280
- */
281
- get lc_id() {
282
- return [
283
- ...this.lc_namespace,
284
- get_lc_unique_name(this.constructor),
285
- ];
286
- }
287
- /**
288
- * A map of secrets, which will be omitted from serialization.
289
- * Keys are paths to the secret in constructor args, e.g. "foo.bar.baz".
290
- * Values are the secret ids, which will be used when deserializing.
291
- */
292
- get lc_secrets() {
293
- return undefined;
294
- }
295
- /**
296
- * A map of additional attributes to merge with constructor args.
297
- * Keys are the attribute names, e.g. "foo".
298
- * Values are the attribute values, which will be serialized.
299
- * These attributes need to be accepted by the constructor as arguments.
300
- */
301
- get lc_attributes() {
302
- return undefined;
303
- }
304
- /**
305
- * A map of aliases for constructor args.
306
- * Keys are the attribute names, e.g. "foo".
307
- * Values are the alias that will replace the key in serialization.
308
- * This is used to eg. make argument names match Python.
309
- */
310
- get lc_aliases() {
311
- return undefined;
312
- }
313
- /**
314
- * A manual list of keys that should be serialized.
315
- * If not overridden, all fields passed into the constructor will be serialized.
316
- */
317
- get lc_serializable_keys() {
318
- return undefined;
319
- }
320
- constructor(kwargs, ..._args) {
321
- Object.defineProperty(this, "lc_serializable", {
322
- enumerable: true,
323
- configurable: true,
324
- writable: true,
325
- value: false
326
- });
327
- Object.defineProperty(this, "lc_kwargs", {
328
- enumerable: true,
329
- configurable: true,
330
- writable: true,
331
- value: void 0
332
- });
333
- if (this.lc_serializable_keys !== undefined) {
334
- this.lc_kwargs = Object.fromEntries(Object.entries(kwargs || {}).filter(([key]) => this.lc_serializable_keys?.includes(key)));
335
- }
336
- else {
337
- this.lc_kwargs = kwargs ?? {};
338
- }
339
- }
340
- toJSON() {
341
- if (!this.lc_serializable) {
342
- return this.toJSONNotImplemented();
343
- }
344
- if (
345
- // eslint-disable-next-line no-instanceof/no-instanceof
346
- this.lc_kwargs instanceof Serializable ||
347
- typeof this.lc_kwargs !== "object" ||
348
- Array.isArray(this.lc_kwargs)) {
349
- // We do not support serialization of classes with arg not a POJO
350
- // I'm aware the check above isn't as strict as it could be
351
- return this.toJSONNotImplemented();
352
- }
353
- const aliases = {};
354
- const secrets = {};
355
- const kwargs = Object.keys(this.lc_kwargs).reduce((acc, key) => {
356
- acc[key] = key in this ? this[key] : this.lc_kwargs[key];
357
- return acc;
358
- }, {});
359
- // get secrets, attributes and aliases from all superclasses
360
- for (
361
- // eslint-disable-next-line @typescript-eslint/no-this-alias
362
- let current = Object.getPrototypeOf(this); current; current = Object.getPrototypeOf(current)) {
363
- Object.assign(aliases, Reflect.get(current, "lc_aliases", this));
364
- Object.assign(secrets, Reflect.get(current, "lc_secrets", this));
365
- Object.assign(kwargs, Reflect.get(current, "lc_attributes", this));
366
- }
367
- // include all secrets used, even if not in kwargs,
368
- // will be replaced with sentinel value in replaceSecrets
369
- Object.keys(secrets).forEach((keyPath) => {
370
- // eslint-disable-next-line @typescript-eslint/no-this-alias, @typescript-eslint/no-explicit-any
371
- let read = this;
372
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
373
- let write = kwargs;
374
- const [last, ...partsReverse] = keyPath.split(".").reverse();
375
- for (const key of partsReverse.reverse()) {
376
- if (!(key in read) || read[key] === undefined)
377
- return;
378
- if (!(key in write) || write[key] === undefined) {
379
- if (typeof read[key] === "object" && read[key] != null) {
380
- write[key] = {};
381
- }
382
- else if (Array.isArray(read[key])) {
383
- write[key] = [];
384
- }
385
- }
386
- read = read[key];
387
- write = write[key];
388
- }
389
- if (last in read && read[last] !== undefined) {
390
- write[last] = write[last] || read[last];
391
- }
392
- });
393
- return {
394
- lc: 1,
395
- type: "constructor",
396
- id: this.lc_id,
397
- kwargs: mapKeys(Object.keys(secrets).length ? replaceSecrets(kwargs, secrets) : kwargs, keyToJson, aliases),
398
- };
399
- }
400
- toJSONNotImplemented() {
401
- return {
402
- lc: 1,
403
- type: "not_implemented",
404
- id: this.lc_id,
405
- };
406
- }
256
+ * Get a unique name for the module, rather than parent class implementations.
257
+ * Should not be subclassed, subclass lc_name above instead.
258
+ */
259
+ function get_lc_unique_name(serializableClass) {
260
+ const parentClass = Object.getPrototypeOf(serializableClass);
261
+ const lcNameIsSubclassed = typeof serializableClass.lc_name === "function" && (typeof parentClass.lc_name !== "function" || serializableClass.lc_name() !== parentClass.lc_name());
262
+ if (lcNameIsSubclassed) return serializableClass.lc_name();
263
+ else return serializableClass.name;
407
264
  }
265
+ var Serializable = class Serializable {
266
+ lc_serializable = false;
267
+ lc_kwargs;
268
+ /**
269
+ * The name of the serializable. Override to provide an alias or
270
+ * to preserve the serialized module name in minified environments.
271
+ *
272
+ * Implemented as a static method to support loading logic.
273
+ */
274
+ static lc_name() {
275
+ return this.name;
276
+ }
277
+ /**
278
+ * The final serialized identifier for the module.
279
+ */
280
+ get lc_id() {
281
+ return [...this.lc_namespace, get_lc_unique_name(this.constructor)];
282
+ }
283
+ /**
284
+ * A map of secrets, which will be omitted from serialization.
285
+ * Keys are paths to the secret in constructor args, e.g. "foo.bar.baz".
286
+ * Values are the secret ids, which will be used when deserializing.
287
+ */
288
+ get lc_secrets() {
289
+ return void 0;
290
+ }
291
+ /**
292
+ * A map of additional attributes to merge with constructor args.
293
+ * Keys are the attribute names, e.g. "foo".
294
+ * Values are the attribute values, which will be serialized.
295
+ * These attributes need to be accepted by the constructor as arguments.
296
+ */
297
+ get lc_attributes() {
298
+ return void 0;
299
+ }
300
+ /**
301
+ * A map of aliases for constructor args.
302
+ * Keys are the attribute names, e.g. "foo".
303
+ * Values are the alias that will replace the key in serialization.
304
+ * This is used to eg. make argument names match Python.
305
+ */
306
+ get lc_aliases() {
307
+ return void 0;
308
+ }
309
+ /**
310
+ * A manual list of keys that should be serialized.
311
+ * If not overridden, all fields passed into the constructor will be serialized.
312
+ */
313
+ get lc_serializable_keys() {
314
+ return void 0;
315
+ }
316
+ constructor(kwargs, ..._args) {
317
+ if (this.lc_serializable_keys !== void 0) this.lc_kwargs = Object.fromEntries(Object.entries(kwargs || {}).filter(([key]) => this.lc_serializable_keys?.includes(key)));
318
+ else this.lc_kwargs = kwargs ?? {};
319
+ }
320
+ toJSON() {
321
+ if (!this.lc_serializable) return this.toJSONNotImplemented();
322
+ if (this.lc_kwargs instanceof Serializable || typeof this.lc_kwargs !== "object" || Array.isArray(this.lc_kwargs)) return this.toJSONNotImplemented();
323
+ const aliases = {};
324
+ const secrets = {};
325
+ const kwargs = Object.keys(this.lc_kwargs).reduce((acc, key) => {
326
+ acc[key] = key in this ? this[key] : this.lc_kwargs[key];
327
+ return acc;
328
+ }, {});
329
+ for (let current = Object.getPrototypeOf(this); current; current = Object.getPrototypeOf(current)) {
330
+ Object.assign(aliases, Reflect.get(current, "lc_aliases", this));
331
+ Object.assign(secrets, Reflect.get(current, "lc_secrets", this));
332
+ Object.assign(kwargs, Reflect.get(current, "lc_attributes", this));
333
+ }
334
+ Object.keys(secrets).forEach((keyPath) => {
335
+ let read = this;
336
+ let write = kwargs;
337
+ const [last, ...partsReverse] = keyPath.split(".").reverse();
338
+ for (const key of partsReverse.reverse()) {
339
+ if (!(key in read) || read[key] === void 0) return;
340
+ if (!(key in write) || write[key] === void 0) {
341
+ if (typeof read[key] === "object" && read[key] != null) write[key] = {};
342
+ else if (Array.isArray(read[key])) write[key] = [];
343
+ }
344
+ read = read[key];
345
+ write = write[key];
346
+ }
347
+ if (last in read && read[last] !== void 0) write[last] = write[last] || read[last];
348
+ });
349
+ return {
350
+ lc: 1,
351
+ type: "constructor",
352
+ id: this.lc_id,
353
+ kwargs: mapKeys(Object.keys(secrets).length ? replaceSecrets(kwargs, secrets) : kwargs, keyToJson, aliases)
354
+ };
355
+ }
356
+ toJSONNotImplemented() {
357
+ return {
358
+ lc: 1,
359
+ type: "not_implemented",
360
+ id: this.lc_id
361
+ };
362
+ }
363
+ };
408
364
 
409
- // Supabase Edge Function provides a `Deno` global object
410
- // without `version` property
365
+ //#region src/utils/env.ts
366
+ var env_exports = {};
367
+ __export(env_exports, {
368
+ getEnv: () => getEnv,
369
+ getEnvironmentVariable: () => getEnvironmentVariable,
370
+ getRuntimeEnvironment: () => getRuntimeEnvironment,
371
+ isBrowser: () => isBrowser,
372
+ isDeno: () => isDeno,
373
+ isJsDom: () => isJsDom,
374
+ isNode: () => isNode,
375
+ isWebWorker: () => isWebWorker
376
+ });
377
+ const isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
378
+ const isWebWorker = () => typeof globalThis === "object" && globalThis.constructor && globalThis.constructor.name === "DedicatedWorkerGlobalScope";
379
+ const isJsDom = () => typeof window !== "undefined" && window.name === "nodejs" || typeof navigator !== "undefined" && navigator.userAgent.includes("jsdom");
411
380
  const isDeno = () => typeof Deno !== "undefined";
381
+ const isNode = () => typeof process !== "undefined" && typeof process.versions !== "undefined" && typeof process.versions.node !== "undefined" && !isDeno();
382
+ const getEnv = () => {
383
+ let env;
384
+ if (isBrowser()) env = "browser";
385
+ else if (isNode()) env = "node";
386
+ else if (isWebWorker()) env = "webworker";
387
+ else if (isJsDom()) env = "jsdom";
388
+ else if (isDeno()) env = "deno";
389
+ else env = "other";
390
+ return env;
391
+ };
392
+ let runtimeEnvironment;
393
+ function getRuntimeEnvironment() {
394
+ if (runtimeEnvironment === void 0) {
395
+ const env = getEnv();
396
+ runtimeEnvironment = {
397
+ library: "langchain-js",
398
+ runtime: env
399
+ };
400
+ }
401
+ return runtimeEnvironment;
402
+ }
412
403
  function getEnvironmentVariable(name) {
413
- // Certain Deno setups will throw an error if you try to access environment variables
414
- // https://github.com/langchain-ai/langchainjs/issues/1412
415
- try {
416
- if (typeof process !== "undefined") {
417
- // eslint-disable-next-line no-process-env
418
- return process.env?.[name];
419
- }
420
- else if (isDeno()) {
421
- return Deno?.env.get(name);
422
- }
423
- else {
424
- return undefined;
425
- }
426
- }
427
- catch (e) {
428
- return undefined;
429
- }
404
+ try {
405
+ if (typeof process !== "undefined") return process.env?.[name];
406
+ else if (isDeno()) return Deno?.env.get(name);
407
+ else return void 0;
408
+ } catch {
409
+ return void 0;
410
+ }
430
411
  }
431
412
 
413
+ //#region src/callbacks/base.ts
414
+ var base_exports = {};
415
+ __export(base_exports, {
416
+ BaseCallbackHandler: () => BaseCallbackHandler,
417
+ callbackHandlerPrefersStreaming: () => callbackHandlerPrefersStreaming,
418
+ isBaseCallbackHandler: () => isBaseCallbackHandler
419
+ });
432
420
  /**
433
- * Abstract class that provides a set of optional methods that can be
434
- * overridden in derived classes to handle various events during the
435
- * execution of a LangChain application.
436
- */
437
- class BaseCallbackHandlerMethodsClass {
421
+ * Abstract class that provides a set of optional methods that can be
422
+ * overridden in derived classes to handle various events during the
423
+ * execution of a LangChain application.
424
+ */
425
+ var BaseCallbackHandlerMethodsClass = class {};
426
+ function callbackHandlerPrefersStreaming(x) {
427
+ return "lc_prefer_streaming" in x && x.lc_prefer_streaming;
438
428
  }
439
429
  /**
440
- * Abstract base class for creating callback handlers in the LangChain
441
- * framework. It provides a set of optional methods that can be overridden
442
- * in derived classes to handle various events during the execution of a
443
- * LangChain application.
444
- */
445
- class BaseCallbackHandler extends BaseCallbackHandlerMethodsClass {
446
- get lc_namespace() {
447
- return ["langchain_core", "callbacks", this.name];
448
- }
449
- get lc_secrets() {
450
- return undefined;
451
- }
452
- get lc_attributes() {
453
- return undefined;
454
- }
455
- get lc_aliases() {
456
- return undefined;
457
- }
458
- get lc_serializable_keys() {
459
- return undefined;
460
- }
461
- /**
462
- * The name of the serializable. Override to provide an alias or
463
- * to preserve the serialized module name in minified environments.
464
- *
465
- * Implemented as a static method to support loading logic.
466
- */
467
- static lc_name() {
468
- return this.name;
469
- }
470
- /**
471
- * The final serialized identifier for the module.
472
- */
473
- get lc_id() {
474
- return [
475
- ...this.lc_namespace,
476
- get_lc_unique_name(this.constructor),
477
- ];
478
- }
479
- constructor(input) {
480
- super();
481
- Object.defineProperty(this, "lc_serializable", {
482
- enumerable: true,
483
- configurable: true,
484
- writable: true,
485
- value: false
486
- });
487
- Object.defineProperty(this, "lc_kwargs", {
488
- enumerable: true,
489
- configurable: true,
490
- writable: true,
491
- value: void 0
492
- });
493
- Object.defineProperty(this, "ignoreLLM", {
494
- enumerable: true,
495
- configurable: true,
496
- writable: true,
497
- value: false
498
- });
499
- Object.defineProperty(this, "ignoreChain", {
500
- enumerable: true,
501
- configurable: true,
502
- writable: true,
503
- value: false
504
- });
505
- Object.defineProperty(this, "ignoreAgent", {
506
- enumerable: true,
507
- configurable: true,
508
- writable: true,
509
- value: false
510
- });
511
- Object.defineProperty(this, "ignoreRetriever", {
512
- enumerable: true,
513
- configurable: true,
514
- writable: true,
515
- value: false
516
- });
517
- Object.defineProperty(this, "ignoreCustomEvent", {
518
- enumerable: true,
519
- configurable: true,
520
- writable: true,
521
- value: false
522
- });
523
- Object.defineProperty(this, "raiseError", {
524
- enumerable: true,
525
- configurable: true,
526
- writable: true,
527
- value: false
528
- });
529
- Object.defineProperty(this, "awaitHandlers", {
530
- enumerable: true,
531
- configurable: true,
532
- writable: true,
533
- value: getEnvironmentVariable("LANGCHAIN_CALLBACKS_BACKGROUND") === "false"
534
- });
535
- this.lc_kwargs = input || {};
536
- if (input) {
537
- this.ignoreLLM = input.ignoreLLM ?? this.ignoreLLM;
538
- this.ignoreChain = input.ignoreChain ?? this.ignoreChain;
539
- this.ignoreAgent = input.ignoreAgent ?? this.ignoreAgent;
540
- this.ignoreRetriever = input.ignoreRetriever ?? this.ignoreRetriever;
541
- this.ignoreCustomEvent =
542
- input.ignoreCustomEvent ?? this.ignoreCustomEvent;
543
- this.raiseError = input.raiseError ?? this.raiseError;
544
- this.awaitHandlers =
545
- this.raiseError || (input._awaitHandler ?? this.awaitHandlers);
546
- }
547
- }
548
- copy() {
549
- return new this.constructor(this);
550
- }
551
- toJSON() {
552
- return Serializable.prototype.toJSON.call(this);
553
- }
554
- toJSONNotImplemented() {
555
- return Serializable.prototype.toJSONNotImplemented.call(this);
556
- }
557
- static fromMethods(methods) {
558
- class Handler extends BaseCallbackHandler {
559
- constructor() {
560
- super();
561
- Object.defineProperty(this, "name", {
562
- enumerable: true,
563
- configurable: true,
564
- writable: true,
565
- value: uuid.v4()
566
- });
567
- Object.assign(this, methods);
568
- }
569
- }
570
- return new Handler();
571
- }
572
- }
430
+ * Abstract base class for creating callback handlers in the LangChain
431
+ * framework. It provides a set of optional methods that can be overridden
432
+ * in derived classes to handle various events during the execution of a
433
+ * LangChain application.
434
+ */
435
+ var BaseCallbackHandler = class extends BaseCallbackHandlerMethodsClass {
436
+ lc_serializable = false;
437
+ get lc_namespace() {
438
+ return [
439
+ "langchain_core",
440
+ "callbacks",
441
+ this.name
442
+ ];
443
+ }
444
+ get lc_secrets() {
445
+ return void 0;
446
+ }
447
+ get lc_attributes() {
448
+ return void 0;
449
+ }
450
+ get lc_aliases() {
451
+ return void 0;
452
+ }
453
+ get lc_serializable_keys() {
454
+ return void 0;
455
+ }
456
+ /**
457
+ * The name of the serializable. Override to provide an alias or
458
+ * to preserve the serialized module name in minified environments.
459
+ *
460
+ * Implemented as a static method to support loading logic.
461
+ */
462
+ static lc_name() {
463
+ return this.name;
464
+ }
465
+ /**
466
+ * The final serialized identifier for the module.
467
+ */
468
+ get lc_id() {
469
+ return [...this.lc_namespace, get_lc_unique_name(this.constructor)];
470
+ }
471
+ lc_kwargs;
472
+ ignoreLLM = false;
473
+ ignoreChain = false;
474
+ ignoreAgent = false;
475
+ ignoreRetriever = false;
476
+ ignoreCustomEvent = false;
477
+ raiseError = false;
478
+ awaitHandlers = getEnvironmentVariable("LANGCHAIN_CALLBACKS_BACKGROUND") === "false";
479
+ constructor(input) {
480
+ super();
481
+ this.lc_kwargs = input || {};
482
+ if (input) {
483
+ this.ignoreLLM = input.ignoreLLM ?? this.ignoreLLM;
484
+ this.ignoreChain = input.ignoreChain ?? this.ignoreChain;
485
+ this.ignoreAgent = input.ignoreAgent ?? this.ignoreAgent;
486
+ this.ignoreRetriever = input.ignoreRetriever ?? this.ignoreRetriever;
487
+ this.ignoreCustomEvent = input.ignoreCustomEvent ?? this.ignoreCustomEvent;
488
+ this.raiseError = input.raiseError ?? this.raiseError;
489
+ this.awaitHandlers = this.raiseError || (input._awaitHandler ?? this.awaitHandlers);
490
+ }
491
+ }
492
+ copy() {
493
+ return new this.constructor(this);
494
+ }
495
+ toJSON() {
496
+ return Serializable.prototype.toJSON.call(this);
497
+ }
498
+ toJSONNotImplemented() {
499
+ return Serializable.prototype.toJSONNotImplemented.call(this);
500
+ }
501
+ static fromMethods(methods) {
502
+ class Handler extends BaseCallbackHandler {
503
+ name = uuid.v4();
504
+ constructor() {
505
+ super();
506
+ Object.assign(this, methods);
507
+ }
508
+ }
509
+ return new Handler();
510
+ }
511
+ };
512
+ const isBaseCallbackHandler = (x) => {
513
+ const callbackHandler = x;
514
+ return callbackHandler !== void 0 && typeof callbackHandler.copy === "function" && typeof callbackHandler.name === "string" && typeof callbackHandler.awaitHandlers === "boolean";
515
+ };
573
516
 
574
517
  const REDACTED_IMAGE_PLACEHOLDER = '[base64 image redacted]';
575
518