From 9198f4c9a01e0a459a78f09896811eb13bfcff3d Mon Sep 17 00:00:00 2001 From: William FH <13333726+hinthornw@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:50:48 -0800 Subject: [PATCH] [JS] Add callable masking (#493) --- js/package.json | 2 +- js/src/client.ts | 20 ++++++++++++++++---- js/src/index.ts | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/js/package.json b/js/package.json index d028e54e8..e2f5c11ec 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "langsmith", - "version": "0.1.9", + "version": "0.1.10", "description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.", "packageManager": "yarn@1.22.19", "files": [ diff --git a/js/src/client.ts b/js/src/client.ts index d06f51800..1500583c1 100644 --- a/js/src/client.ts +++ b/js/src/client.ts @@ -363,9 +363,9 @@ export class Client { private _tenantId: string | null = null; - private hideInputs?: boolean; + private hideInputs?: boolean | ((inputs: KVMap) => KVMap); - private hideOutputs?: boolean; + private hideOutputs?: boolean | ((outputs: KVMap) => KVMap); private tracingSampleRate?: number; @@ -463,16 +463,28 @@ export class Client { } private processInputs(inputs: KVMap): KVMap { - if (this.hideInputs) { + if (this.hideInputs === false) { + return inputs; + } + if (this.hideInputs === true) { return {}; } + if (typeof this.hideInputs === "function") { + return this.hideInputs(inputs); + } return inputs; } private processOutputs(outputs: KVMap): KVMap { - if (this.hideOutputs) { + if (this.hideOutputs === false) { + return outputs; + } + if (this.hideOutputs === true) { return {}; } + if (typeof this.hideOutputs === "function") { + return this.hideOutputs(outputs); + } return outputs; } diff --git a/js/src/index.ts b/js/src/index.ts index 766275ca2..950cd1c80 100644 --- a/js/src/index.ts +++ b/js/src/index.ts @@ -11,4 +11,4 @@ export type { export { RunTree, type RunTreeConfig } from "./run_trees.js"; // Update using yarn bump-version -export const __version__ = "0.1.9"; +export const __version__ = "0.1.10";