From 6f71cb7489f15ec5842e8f2764ab90738aef5438 Mon Sep 17 00:00:00 2001 From: Jacob Lee Date: Wed, 27 Nov 2024 11:09:23 -0800 Subject: [PATCH] feat(js): Expose light interface for tracing client (#1266) Allows for interoperability in LangChain when initializing tracer with clients if different LangSmith versions are resolved: ```ts import { Client } from "langsmith"; // `@langchain/core` may have a different internal version of `langsmith` import { LangChainTracer } from "@langchain/core/tracers"; const client = new Client(); const tracer = new LangChainTracer({ client, // Will type error if resolutions are bad }); ``` --- js/package.json | 2 +- js/src/client.ts | 8 +++++++- js/src/index.ts | 8 ++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/js/package.json b/js/package.json index 4b8881b4d..ea27664f6 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "langsmith", - "version": "0.2.7", + "version": "0.2.8", "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 6e75751bb..54f4a5e27 100644 --- a/js/src/client.ts +++ b/js/src/client.ts @@ -437,7 +437,7 @@ export const DEFAULT_BATCH_SIZE_LIMIT_BYTES = 20_971_520; const SERVER_INFO_REQUEST_TIMEOUT = 1000; -export class Client { +export class Client implements LangSmithTracingClientInterface { private apiKey?: string; private apiUrl: string; @@ -4171,3 +4171,9 @@ export class Client { ]); } } + +export interface LangSmithTracingClientInterface { + createRun: (run: CreateRunParams) => Promise; + + updateRun: (runId: string, run: RunUpdate) => Promise; +} diff --git a/js/src/index.ts b/js/src/index.ts index daf8c12a8..d648d23c5 100644 --- a/js/src/index.ts +++ b/js/src/index.ts @@ -1,4 +1,8 @@ -export { Client, type ClientConfig } from "./client.js"; +export { + Client, + type ClientConfig, + type LangSmithTracingClientInterface, +} from "./client.js"; export type { Dataset, @@ -14,4 +18,4 @@ export { RunTree, type RunTreeConfig } from "./run_trees.js"; export { overrideFetchImplementation } from "./singletons/fetch.js"; // Update using yarn bump-version -export const __version__ = "0.2.7"; +export const __version__ = "0.2.8";