@posthog/ai 7.9.1 → 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 +3 -3
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { uuidv7 } from '@posthog/core';
|
|
|
5
5
|
import AnthropicOriginal from '@anthropic-ai/sdk';
|
|
6
6
|
import { GoogleGenAI } from '@google/genai';
|
|
7
7
|
|
|
8
|
-
var version = "7.9.
|
|
8
|
+
var version = "7.9.2";
|
|
9
9
|
|
|
10
10
|
// Type guards for safer type checking
|
|
11
11
|
const isString = value => {
|
|
@@ -4083,15 +4083,6 @@ function calculateGoogleWebSearchCount(response) {
|
|
|
4083
4083
|
return hasGrounding ? 1 : 0;
|
|
4084
4084
|
}
|
|
4085
4085
|
|
|
4086
|
-
//#region rolldown:runtime
|
|
4087
|
-
var __defProp = Object.defineProperty;
|
|
4088
|
-
var __export = (target, all) => {
|
|
4089
|
-
for (var name in all) __defProp(target, name, {
|
|
4090
|
-
get: all[name],
|
|
4091
|
-
enumerable: true
|
|
4092
|
-
});
|
|
4093
|
-
};
|
|
4094
|
-
|
|
4095
4086
|
function getDefaultExportFromCjs (x) {
|
|
4096
4087
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
4097
4088
|
}
|
|
@@ -4335,12 +4326,6 @@ function escapeIfNeeded(value, pathSet = /* @__PURE__ */ new WeakSet()) {
|
|
|
4335
4326
|
return value;
|
|
4336
4327
|
}
|
|
4337
4328
|
|
|
4338
|
-
//#region src/load/serializable.ts
|
|
4339
|
-
var serializable_exports = {};
|
|
4340
|
-
__export(serializable_exports, {
|
|
4341
|
-
Serializable: () => Serializable,
|
|
4342
|
-
get_lc_unique_name: () => get_lc_unique_name
|
|
4343
|
-
});
|
|
4344
4329
|
function shallowCopy(obj) {
|
|
4345
4330
|
return Array.isArray(obj) ? [...obj] : { ...obj };
|
|
4346
4331
|
}
|
|
@@ -4368,8 +4353,7 @@ function replaceSecrets(root, secretsMap) {
|
|
|
4368
4353
|
*/
|
|
4369
4354
|
function get_lc_unique_name(serializableClass) {
|
|
4370
4355
|
const parentClass = Object.getPrototypeOf(serializableClass);
|
|
4371
|
-
|
|
4372
|
-
if (lcNameIsSubclassed) return serializableClass.lc_name();
|
|
4356
|
+
if (typeof serializableClass.lc_name === "function" && (typeof parentClass.lc_name !== "function" || serializableClass.lc_name() !== parentClass.lc_name())) return serializableClass.lc_name();
|
|
4373
4357
|
else return serializableClass.name;
|
|
4374
4358
|
}
|
|
4375
4359
|
var Serializable = class Serializable {
|
|
@@ -4395,34 +4379,26 @@ var Serializable = class Serializable {
|
|
|
4395
4379
|
* Keys are paths to the secret in constructor args, e.g. "foo.bar.baz".
|
|
4396
4380
|
* Values are the secret ids, which will be used when deserializing.
|
|
4397
4381
|
*/
|
|
4398
|
-
get lc_secrets() {
|
|
4399
|
-
return void 0;
|
|
4400
|
-
}
|
|
4382
|
+
get lc_secrets() {}
|
|
4401
4383
|
/**
|
|
4402
4384
|
* A map of additional attributes to merge with constructor args.
|
|
4403
4385
|
* Keys are the attribute names, e.g. "foo".
|
|
4404
4386
|
* Values are the attribute values, which will be serialized.
|
|
4405
4387
|
* These attributes need to be accepted by the constructor as arguments.
|
|
4406
4388
|
*/
|
|
4407
|
-
get lc_attributes() {
|
|
4408
|
-
return void 0;
|
|
4409
|
-
}
|
|
4389
|
+
get lc_attributes() {}
|
|
4410
4390
|
/**
|
|
4411
4391
|
* A map of aliases for constructor args.
|
|
4412
4392
|
* Keys are the attribute names, e.g. "foo".
|
|
4413
4393
|
* Values are the alias that will replace the key in serialization.
|
|
4414
4394
|
* This is used to eg. make argument names match Python.
|
|
4415
4395
|
*/
|
|
4416
|
-
get lc_aliases() {
|
|
4417
|
-
return void 0;
|
|
4418
|
-
}
|
|
4396
|
+
get lc_aliases() {}
|
|
4419
4397
|
/**
|
|
4420
4398
|
* A manual list of keys that should be serialized.
|
|
4421
4399
|
* If not overridden, all fields passed into the constructor will be serialized.
|
|
4422
4400
|
*/
|
|
4423
|
-
get lc_serializable_keys() {
|
|
4424
|
-
return void 0;
|
|
4425
|
-
}
|
|
4401
|
+
get lc_serializable_keys() {}
|
|
4426
4402
|
constructor(kwargs, ..._args) {
|
|
4427
4403
|
if (this.lc_serializable_keys !== void 0) this.lc_kwargs = Object.fromEntries(Object.entries(kwargs || {}).filter(([key]) => this.lc_serializable_keys?.includes(key)));
|
|
4428
4404
|
else this.lc_kwargs = kwargs ?? {};
|
|
@@ -4460,8 +4436,7 @@ var Serializable = class Serializable {
|
|
|
4460
4436
|
const pathSet = /* @__PURE__ */ new WeakSet();
|
|
4461
4437
|
pathSet.add(this);
|
|
4462
4438
|
for (const [key, value] of Object.entries(kwargs)) escapedKwargs[key] = escapeIfNeeded(value, pathSet);
|
|
4463
|
-
const
|
|
4464
|
-
const processedKwargs = mapKeys(kwargsWithSecrets, keyToJson, aliases);
|
|
4439
|
+
const processedKwargs = mapKeys(Object.keys(secrets).length ? replaceSecrets(escapedKwargs, secrets) : escapedKwargs, keyToJson, aliases);
|
|
4465
4440
|
return {
|
|
4466
4441
|
lc: 1,
|
|
4467
4442
|
type: "constructor",
|
|
@@ -4478,70 +4453,23 @@ var Serializable = class Serializable {
|
|
|
4478
4453
|
}
|
|
4479
4454
|
};
|
|
4480
4455
|
|
|
4481
|
-
//#region src/utils/env.ts
|
|
4482
|
-
var env_exports = {};
|
|
4483
|
-
__export(env_exports, {
|
|
4484
|
-
getEnv: () => getEnv,
|
|
4485
|
-
getEnvironmentVariable: () => getEnvironmentVariable,
|
|
4486
|
-
getRuntimeEnvironment: () => getRuntimeEnvironment,
|
|
4487
|
-
isBrowser: () => isBrowser,
|
|
4488
|
-
isDeno: () => isDeno,
|
|
4489
|
-
isJsDom: () => isJsDom,
|
|
4490
|
-
isNode: () => isNode,
|
|
4491
|
-
isWebWorker: () => isWebWorker
|
|
4492
|
-
});
|
|
4493
|
-
const isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
4494
|
-
const isWebWorker = () => typeof globalThis === "object" && globalThis.constructor && globalThis.constructor.name === "DedicatedWorkerGlobalScope";
|
|
4495
|
-
const isJsDom = () => typeof window !== "undefined" && window.name === "nodejs" || typeof navigator !== "undefined" && navigator.userAgent.includes("jsdom");
|
|
4496
4456
|
const isDeno = () => typeof Deno !== "undefined";
|
|
4497
|
-
const isNode = () => typeof process !== "undefined" && typeof process.versions !== "undefined" && typeof process.versions.node !== "undefined" && !isDeno();
|
|
4498
|
-
const getEnv = () => {
|
|
4499
|
-
let env;
|
|
4500
|
-
if (isBrowser()) env = "browser";
|
|
4501
|
-
else if (isNode()) env = "node";
|
|
4502
|
-
else if (isWebWorker()) env = "webworker";
|
|
4503
|
-
else if (isJsDom()) env = "jsdom";
|
|
4504
|
-
else if (isDeno()) env = "deno";
|
|
4505
|
-
else env = "other";
|
|
4506
|
-
return env;
|
|
4507
|
-
};
|
|
4508
|
-
let runtimeEnvironment;
|
|
4509
|
-
function getRuntimeEnvironment() {
|
|
4510
|
-
if (runtimeEnvironment === void 0) {
|
|
4511
|
-
const env = getEnv();
|
|
4512
|
-
runtimeEnvironment = {
|
|
4513
|
-
library: "langchain-js",
|
|
4514
|
-
runtime: env
|
|
4515
|
-
};
|
|
4516
|
-
}
|
|
4517
|
-
return runtimeEnvironment;
|
|
4518
|
-
}
|
|
4519
4457
|
function getEnvironmentVariable(name) {
|
|
4520
4458
|
try {
|
|
4521
4459
|
if (typeof process !== "undefined") return process.env?.[name];
|
|
4522
4460
|
else if (isDeno()) return Deno?.env.get(name);
|
|
4523
|
-
else return
|
|
4461
|
+
else return;
|
|
4524
4462
|
} catch {
|
|
4525
|
-
return
|
|
4463
|
+
return;
|
|
4526
4464
|
}
|
|
4527
4465
|
}
|
|
4528
4466
|
|
|
4529
|
-
//#region src/callbacks/base.ts
|
|
4530
|
-
var base_exports = {};
|
|
4531
|
-
__export(base_exports, {
|
|
4532
|
-
BaseCallbackHandler: () => BaseCallbackHandler,
|
|
4533
|
-
callbackHandlerPrefersStreaming: () => callbackHandlerPrefersStreaming,
|
|
4534
|
-
isBaseCallbackHandler: () => isBaseCallbackHandler
|
|
4535
|
-
});
|
|
4536
4467
|
/**
|
|
4537
4468
|
* Abstract class that provides a set of optional methods that can be
|
|
4538
4469
|
* overridden in derived classes to handle various events during the
|
|
4539
4470
|
* execution of a LangChain application.
|
|
4540
4471
|
*/
|
|
4541
4472
|
var BaseCallbackHandlerMethodsClass = class {};
|
|
4542
|
-
function callbackHandlerPrefersStreaming(x) {
|
|
4543
|
-
return "lc_prefer_streaming" in x && x.lc_prefer_streaming;
|
|
4544
|
-
}
|
|
4545
4473
|
/**
|
|
4546
4474
|
* Abstract base class for creating callback handlers in the LangChain
|
|
4547
4475
|
* framework. It provides a set of optional methods that can be overridden
|
|
@@ -4557,18 +4485,10 @@ var BaseCallbackHandler = class extends BaseCallbackHandlerMethodsClass {
|
|
|
4557
4485
|
this.name
|
|
4558
4486
|
];
|
|
4559
4487
|
}
|
|
4560
|
-
get lc_secrets() {
|
|
4561
|
-
|
|
4562
|
-
}
|
|
4563
|
-
get
|
|
4564
|
-
return void 0;
|
|
4565
|
-
}
|
|
4566
|
-
get lc_aliases() {
|
|
4567
|
-
return void 0;
|
|
4568
|
-
}
|
|
4569
|
-
get lc_serializable_keys() {
|
|
4570
|
-
return void 0;
|
|
4571
|
-
}
|
|
4488
|
+
get lc_secrets() {}
|
|
4489
|
+
get lc_attributes() {}
|
|
4490
|
+
get lc_aliases() {}
|
|
4491
|
+
get lc_serializable_keys() {}
|
|
4572
4492
|
/**
|
|
4573
4493
|
* The name of the serializable. Override to provide an alias or
|
|
4574
4494
|
* to preserve the serialized module name in minified environments.
|
|
@@ -4625,10 +4545,6 @@ var BaseCallbackHandler = class extends BaseCallbackHandlerMethodsClass {
|
|
|
4625
4545
|
return new Handler();
|
|
4626
4546
|
}
|
|
4627
4547
|
};
|
|
4628
|
-
const isBaseCallbackHandler = (x) => {
|
|
4629
|
-
const callbackHandler = x;
|
|
4630
|
-
return callbackHandler !== void 0 && typeof callbackHandler.copy === "function" && typeof callbackHandler.name === "string" && typeof callbackHandler.awaitHandlers === "boolean";
|
|
4631
|
-
};
|
|
4632
4548
|
|
|
4633
4549
|
class LangChainCallbackHandler extends BaseCallbackHandler {
|
|
4634
4550
|
constructor(options) {
|