@posthog/ai 7.9.0 → 7.9.2
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/anthropic/index.cjs +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/gemini/index.cjs +1 -1
- package/dist/gemini/index.mjs +1 -1
- package/dist/index.cjs +13 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +13 -97
- package/dist/index.mjs.map +1 -1
- package/dist/langchain/index.cjs +13 -97
- package/dist/langchain/index.cjs.map +1 -1
- package/dist/langchain/index.mjs +13 -97
- package/dist/langchain/index.mjs.map +1 -1
- package/dist/openai/index.cjs +1 -1
- package/dist/openai/index.mjs +1 -1
- package/dist/otel/index.cjs +1 -1
- package/dist/otel/index.mjs +1 -1
- package/dist/vercel/index.cjs +1 -1
- package/dist/vercel/index.mjs +1 -1
- package/package.json +7 -7
package/dist/langchain/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as uuid from 'uuid';
|
|
2
2
|
import '@posthog/core';
|
|
3
3
|
|
|
4
|
-
var version = "7.9.
|
|
4
|
+
var version = "7.9.2";
|
|
5
5
|
|
|
6
6
|
// Type guards for safer type checking
|
|
7
7
|
|
|
@@ -184,15 +184,6 @@ const withPrivacyMode = (client, privacyMode, input) => {
|
|
|
184
184
|
return client.privacy_mode || privacyMode ? null : input;
|
|
185
185
|
};
|
|
186
186
|
|
|
187
|
-
//#region rolldown:runtime
|
|
188
|
-
var __defProp = Object.defineProperty;
|
|
189
|
-
var __export = (target, all) => {
|
|
190
|
-
for (var name in all) __defProp(target, name, {
|
|
191
|
-
get: all[name],
|
|
192
|
-
enumerable: true
|
|
193
|
-
});
|
|
194
|
-
};
|
|
195
|
-
|
|
196
187
|
function getDefaultExportFromCjs (x) {
|
|
197
188
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
198
189
|
}
|
|
@@ -436,12 +427,6 @@ function escapeIfNeeded(value, pathSet = /* @__PURE__ */ new WeakSet()) {
|
|
|
436
427
|
return value;
|
|
437
428
|
}
|
|
438
429
|
|
|
439
|
-
//#region src/load/serializable.ts
|
|
440
|
-
var serializable_exports = {};
|
|
441
|
-
__export(serializable_exports, {
|
|
442
|
-
Serializable: () => Serializable,
|
|
443
|
-
get_lc_unique_name: () => get_lc_unique_name
|
|
444
|
-
});
|
|
445
430
|
function shallowCopy(obj) {
|
|
446
431
|
return Array.isArray(obj) ? [...obj] : { ...obj };
|
|
447
432
|
}
|
|
@@ -469,8 +454,7 @@ function replaceSecrets(root, secretsMap) {
|
|
|
469
454
|
*/
|
|
470
455
|
function get_lc_unique_name(serializableClass) {
|
|
471
456
|
const parentClass = Object.getPrototypeOf(serializableClass);
|
|
472
|
-
|
|
473
|
-
if (lcNameIsSubclassed) return serializableClass.lc_name();
|
|
457
|
+
if (typeof serializableClass.lc_name === "function" && (typeof parentClass.lc_name !== "function" || serializableClass.lc_name() !== parentClass.lc_name())) return serializableClass.lc_name();
|
|
474
458
|
else return serializableClass.name;
|
|
475
459
|
}
|
|
476
460
|
var Serializable = class Serializable {
|
|
@@ -496,34 +480,26 @@ var Serializable = class Serializable {
|
|
|
496
480
|
* Keys are paths to the secret in constructor args, e.g. "foo.bar.baz".
|
|
497
481
|
* Values are the secret ids, which will be used when deserializing.
|
|
498
482
|
*/
|
|
499
|
-
get lc_secrets() {
|
|
500
|
-
return void 0;
|
|
501
|
-
}
|
|
483
|
+
get lc_secrets() {}
|
|
502
484
|
/**
|
|
503
485
|
* A map of additional attributes to merge with constructor args.
|
|
504
486
|
* Keys are the attribute names, e.g. "foo".
|
|
505
487
|
* Values are the attribute values, which will be serialized.
|
|
506
488
|
* These attributes need to be accepted by the constructor as arguments.
|
|
507
489
|
*/
|
|
508
|
-
get lc_attributes() {
|
|
509
|
-
return void 0;
|
|
510
|
-
}
|
|
490
|
+
get lc_attributes() {}
|
|
511
491
|
/**
|
|
512
492
|
* A map of aliases for constructor args.
|
|
513
493
|
* Keys are the attribute names, e.g. "foo".
|
|
514
494
|
* Values are the alias that will replace the key in serialization.
|
|
515
495
|
* This is used to eg. make argument names match Python.
|
|
516
496
|
*/
|
|
517
|
-
get lc_aliases() {
|
|
518
|
-
return void 0;
|
|
519
|
-
}
|
|
497
|
+
get lc_aliases() {}
|
|
520
498
|
/**
|
|
521
499
|
* A manual list of keys that should be serialized.
|
|
522
500
|
* If not overridden, all fields passed into the constructor will be serialized.
|
|
523
501
|
*/
|
|
524
|
-
get lc_serializable_keys() {
|
|
525
|
-
return void 0;
|
|
526
|
-
}
|
|
502
|
+
get lc_serializable_keys() {}
|
|
527
503
|
constructor(kwargs, ..._args) {
|
|
528
504
|
if (this.lc_serializable_keys !== void 0) this.lc_kwargs = Object.fromEntries(Object.entries(kwargs || {}).filter(([key]) => this.lc_serializable_keys?.includes(key)));
|
|
529
505
|
else this.lc_kwargs = kwargs ?? {};
|
|
@@ -561,8 +537,7 @@ var Serializable = class Serializable {
|
|
|
561
537
|
const pathSet = /* @__PURE__ */ new WeakSet();
|
|
562
538
|
pathSet.add(this);
|
|
563
539
|
for (const [key, value] of Object.entries(kwargs)) escapedKwargs[key] = escapeIfNeeded(value, pathSet);
|
|
564
|
-
const
|
|
565
|
-
const processedKwargs = mapKeys(kwargsWithSecrets, keyToJson, aliases);
|
|
540
|
+
const processedKwargs = mapKeys(Object.keys(secrets).length ? replaceSecrets(escapedKwargs, secrets) : escapedKwargs, keyToJson, aliases);
|
|
566
541
|
return {
|
|
567
542
|
lc: 1,
|
|
568
543
|
type: "constructor",
|
|
@@ -579,70 +554,23 @@ var Serializable = class Serializable {
|
|
|
579
554
|
}
|
|
580
555
|
};
|
|
581
556
|
|
|
582
|
-
//#region src/utils/env.ts
|
|
583
|
-
var env_exports = {};
|
|
584
|
-
__export(env_exports, {
|
|
585
|
-
getEnv: () => getEnv,
|
|
586
|
-
getEnvironmentVariable: () => getEnvironmentVariable,
|
|
587
|
-
getRuntimeEnvironment: () => getRuntimeEnvironment,
|
|
588
|
-
isBrowser: () => isBrowser,
|
|
589
|
-
isDeno: () => isDeno,
|
|
590
|
-
isJsDom: () => isJsDom,
|
|
591
|
-
isNode: () => isNode,
|
|
592
|
-
isWebWorker: () => isWebWorker
|
|
593
|
-
});
|
|
594
|
-
const isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
595
|
-
const isWebWorker = () => typeof globalThis === "object" && globalThis.constructor && globalThis.constructor.name === "DedicatedWorkerGlobalScope";
|
|
596
|
-
const isJsDom = () => typeof window !== "undefined" && window.name === "nodejs" || typeof navigator !== "undefined" && navigator.userAgent.includes("jsdom");
|
|
597
557
|
const isDeno = () => typeof Deno !== "undefined";
|
|
598
|
-
const isNode = () => typeof process !== "undefined" && typeof process.versions !== "undefined" && typeof process.versions.node !== "undefined" && !isDeno();
|
|
599
|
-
const getEnv = () => {
|
|
600
|
-
let env;
|
|
601
|
-
if (isBrowser()) env = "browser";
|
|
602
|
-
else if (isNode()) env = "node";
|
|
603
|
-
else if (isWebWorker()) env = "webworker";
|
|
604
|
-
else if (isJsDom()) env = "jsdom";
|
|
605
|
-
else if (isDeno()) env = "deno";
|
|
606
|
-
else env = "other";
|
|
607
|
-
return env;
|
|
608
|
-
};
|
|
609
|
-
let runtimeEnvironment;
|
|
610
|
-
function getRuntimeEnvironment() {
|
|
611
|
-
if (runtimeEnvironment === void 0) {
|
|
612
|
-
const env = getEnv();
|
|
613
|
-
runtimeEnvironment = {
|
|
614
|
-
library: "langchain-js",
|
|
615
|
-
runtime: env
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
return runtimeEnvironment;
|
|
619
|
-
}
|
|
620
558
|
function getEnvironmentVariable(name) {
|
|
621
559
|
try {
|
|
622
560
|
if (typeof process !== "undefined") return process.env?.[name];
|
|
623
561
|
else if (isDeno()) return Deno?.env.get(name);
|
|
624
|
-
else return
|
|
562
|
+
else return;
|
|
625
563
|
} catch {
|
|
626
|
-
return
|
|
564
|
+
return;
|
|
627
565
|
}
|
|
628
566
|
}
|
|
629
567
|
|
|
630
|
-
//#region src/callbacks/base.ts
|
|
631
|
-
var base_exports = {};
|
|
632
|
-
__export(base_exports, {
|
|
633
|
-
BaseCallbackHandler: () => BaseCallbackHandler,
|
|
634
|
-
callbackHandlerPrefersStreaming: () => callbackHandlerPrefersStreaming,
|
|
635
|
-
isBaseCallbackHandler: () => isBaseCallbackHandler
|
|
636
|
-
});
|
|
637
568
|
/**
|
|
638
569
|
* Abstract class that provides a set of optional methods that can be
|
|
639
570
|
* overridden in derived classes to handle various events during the
|
|
640
571
|
* execution of a LangChain application.
|
|
641
572
|
*/
|
|
642
573
|
var BaseCallbackHandlerMethodsClass = class {};
|
|
643
|
-
function callbackHandlerPrefersStreaming(x) {
|
|
644
|
-
return "lc_prefer_streaming" in x && x.lc_prefer_streaming;
|
|
645
|
-
}
|
|
646
574
|
/**
|
|
647
575
|
* Abstract base class for creating callback handlers in the LangChain
|
|
648
576
|
* framework. It provides a set of optional methods that can be overridden
|
|
@@ -658,18 +586,10 @@ var BaseCallbackHandler = class extends BaseCallbackHandlerMethodsClass {
|
|
|
658
586
|
this.name
|
|
659
587
|
];
|
|
660
588
|
}
|
|
661
|
-
get lc_secrets() {
|
|
662
|
-
|
|
663
|
-
}
|
|
664
|
-
get
|
|
665
|
-
return void 0;
|
|
666
|
-
}
|
|
667
|
-
get lc_aliases() {
|
|
668
|
-
return void 0;
|
|
669
|
-
}
|
|
670
|
-
get lc_serializable_keys() {
|
|
671
|
-
return void 0;
|
|
672
|
-
}
|
|
589
|
+
get lc_secrets() {}
|
|
590
|
+
get lc_attributes() {}
|
|
591
|
+
get lc_aliases() {}
|
|
592
|
+
get lc_serializable_keys() {}
|
|
673
593
|
/**
|
|
674
594
|
* The name of the serializable. Override to provide an alias or
|
|
675
595
|
* to preserve the serialized module name in minified environments.
|
|
@@ -726,10 +646,6 @@ var BaseCallbackHandler = class extends BaseCallbackHandlerMethodsClass {
|
|
|
726
646
|
return new Handler();
|
|
727
647
|
}
|
|
728
648
|
};
|
|
729
|
-
const isBaseCallbackHandler = (x) => {
|
|
730
|
-
const callbackHandler = x;
|
|
731
|
-
return callbackHandler !== void 0 && typeof callbackHandler.copy === "function" && typeof callbackHandler.name === "string" && typeof callbackHandler.awaitHandlers === "boolean";
|
|
732
|
-
};
|
|
733
649
|
|
|
734
650
|
/** A run may either be a Span or a Generation */
|
|
735
651
|
|