Skip to content

Commit

Permalink
Fix checking of traceable functions (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
dqbd authored Feb 15, 2024
2 parents 4ef2c93 + 6e84e15 commit 68b7b68
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 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.0",
"version": "0.1.1",
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
"packageManager": "yarn@1.22.19",
"files": [
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.0";
export const __version__ = "0.1.1";
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 68b7b68

Please sign in to comment.