From 6f4f33ac84e152e7e948595f43692e30586b2a51 Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Fri, 21 Jun 2024 23:41:10 +0100 Subject: [PATCH 1/4] fix(anonymizer): make deep cloning the default --- js/src/anonymizer/index.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/js/src/anonymizer/index.ts b/js/src/anonymizer/index.ts index 60becaf9..28e3d088 100644 --- a/js/src/anonymizer/index.ts +++ b/js/src/anonymizer/index.ts @@ -60,19 +60,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, { maxDepth: options?.maxDepth, }); - // by default we opt-in to mutate the value directly - // to improve performance - let mutateValue = options?.deepClone ? deepClone(data) : data; + let mutateValue = deepClone(data); const processor: StringNodeProcessor = Array.isArray(replacer) ? (() => { From f579c9fbf8195e0e5002fdc563f388215e7a3b70 Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Wed, 26 Jun 2024 12:29:18 +0100 Subject: [PATCH 2/4] Fix tests, rely on JSON payload instead --- js/src/anonymizer/index.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/js/src/anonymizer/index.ts b/js/src/anonymizer/index.ts index 28e3d088..cf599606 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)); } @@ -63,12 +59,11 @@ export function createAnonymizer( options?: { maxDepth?: number } ) { return (data: T): T => { - const nodes = extractStringNodes(data, { + let mutateValue = deepClone(data); + const nodes = extractStringNodes(mutateValue, { maxDepth: options?.maxDepth, }); - let mutateValue = deepClone(data); - const processor: StringNodeProcessor = Array.isArray(replacer) ? (() => { const replacers: [regex: RegExp, replace: string][] = replacer.map( From 488ceb71c9e2ad72eccb90e91590eb3a47a750d8 Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Wed, 26 Jun 2024 12:30:22 +0100 Subject: [PATCH 3/4] Bump to 0.1.34 --- js/package.json | 2 +- js/src/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/package.json b/js/package.json index ebbba5a7..b1f3dbb9 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": [ diff --git a/js/src/index.ts b/js/src/index.ts index 1ecd0341..2c38b294 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"; From d37b3f6556378b077ee3a2e811df743a2d465125 Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Wed, 26 Jun 2024 12:30:33 +0100 Subject: [PATCH 4/4] Format JS file --- js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/package.json b/js/package.json index b1f3dbb9..ae1e4592 100644 --- a/js/package.json +++ b/js/package.json @@ -263,4 +263,4 @@ }, "./package.json": "./package.json" } -} \ No newline at end of file +}