Skip to content

Commit

Permalink
Fix checking of traceable functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dqbd committed Feb 15, 2024
1 parent 4ef2c93 commit a940e23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion js/src/tests/traceable.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { v4 as uuidv4 } from "uuid";
// eslint-disable-next-line import/no-extraneous-dependencies
import { FakeStreamingLLM } from "@langchain/core/utils/testing";
import { Client } from "../client.js";
import { traceable } from "../traceable.js";
import { isTraceableFunction, traceable } from "../traceable.js";
import { RunTree } from "../run_trees.js";

async function deleteProject(langchainClient: Client, projectName: string) {
Expand Down Expand Up @@ -76,6 +76,7 @@ test.concurrent(
);

expect(await addValueTraceable("testing", 9)).toBe("testing9");
expect(isTraceableFunction(addValueTraceable)).toBe(true);

await waitUntilRunFound(langchainClient, runId, true);
const storedRun = await langchainClient.readRun(runId);
Expand Down Expand Up @@ -116,6 +117,7 @@ test.concurrent(
);

expect(await entryTraceable({ value: "testing" })).toBe("testing123");
expect(isTraceableFunction(entryTraceable)).toBe(true);

await waitUntilRunFound(langchainClient, runId2, true);
const storedRun2 = await langchainClient.readRun(runId2);
Expand All @@ -131,6 +133,7 @@ test.concurrent(
client: langchainClient,
id: runId3,
});
expect(isTraceableFunction(iterableTraceable)).toBe(true);

const chunks = [];

Expand Down Expand Up @@ -163,6 +166,7 @@ test.concurrent(

expect(await wrappedOverload("testing", 123)).toBe("testing123");
expect(await wrappedOverload({ a: "testing", b: 456 })).toBe("testing456");
expect(isTraceableFunction(wrappedOverload)).toBe(true);
},
180_000
);
2 changes: 1 addition & 1 deletion js/src/traceable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function traceable<Func extends (...args: any[]) => any>(
});
};

Object.defineProperty(wrappedFunc, "langsmith:traceable", {
Object.defineProperty(traceableFunc, "langsmith:traceable", {
value: config,
});

Expand Down

0 comments on commit a940e23

Please sign in to comment.