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