Skip to content

Commit

Permalink
[JS] Add callable masking (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw authored Mar 4, 2024
1 parent 238ed5a commit 9198f4c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"files": [
Expand Down
20 changes: 16 additions & 4 deletions js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

0 comments on commit 9198f4c

Please sign in to comment.