diff --git a/js/package.json b/js/package.json index ebbba5a72..ae1e45929 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "langsmith", - "version": "0.1.33", + "version": "0.1.34", "description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.", "packageManager": "yarn@1.22.19", "files": [ @@ -263,4 +263,4 @@ }, "./package.json": "./package.json" } -} \ No newline at end of file +} diff --git a/js/src/anonymizer/index.ts b/js/src/anonymizer/index.ts index 60becaf9c..cf5996066 100644 --- a/js/src/anonymizer/index.ts +++ b/js/src/anonymizer/index.ts @@ -36,10 +36,6 @@ function extractStringNodes(data: unknown, options: { maxDepth?: number }) { } function deepClone(data: T): T { - if ("structuredClone" in globalThis) { - return globalThis.structuredClone(data); - } - return JSON.parse(JSON.stringify(data)); } @@ -60,20 +56,14 @@ export type ReplacerType = export function createAnonymizer( replacer: ReplacerType, - options?: { - maxDepth?: number; - deepClone?: boolean; - } + options?: { maxDepth?: number } ) { return (data: T): T => { - const nodes = extractStringNodes(data, { + let mutateValue = deepClone(data); + const nodes = extractStringNodes(mutateValue, { maxDepth: options?.maxDepth, }); - // by default we opt-in to mutate the value directly - // to improve performance - let mutateValue = options?.deepClone ? deepClone(data) : data; - const processor: StringNodeProcessor = Array.isArray(replacer) ? (() => { const replacers: [regex: RegExp, replace: string][] = replacer.map( diff --git a/js/src/index.ts b/js/src/index.ts index 1ecd0341b..2c38b2949 100644 --- a/js/src/index.ts +++ b/js/src/index.ts @@ -12,4 +12,4 @@ export type { export { RunTree, type RunTreeConfig } from "./run_trees.js"; // Update using yarn bump-version -export const __version__ = "0.1.33"; +export const __version__ = "0.1.34";