From f67f0c8cb6dc350ebae3c5a1b7587fbfbb7fc937 Mon Sep 17 00:00:00 2001 From: Jacob Lee Date: Tue, 3 Dec 2024 10:45:58 -0800 Subject: [PATCH] fix(core): Improve interoperability between different langsmith versions (#7297) --- dependency_range_tests/docker-compose.yml | 52 +++++++++---------- .../anthropic/node/package.json | 5 +- .../anthropic/test-with-latest-deps.sh | 1 + .../anthropic/test-with-lowest-deps.sh | 1 + .../cohere/node/package.json | 5 +- .../cohere/test-with-latest-deps.sh | 1 + .../cohere/test-with-lowest-deps.sh | 1 + .../community/node/package.json | 5 +- .../community/test-with-latest-deps.sh | 1 + .../community/test-with-lowest-deps.sh | 1 + .../google-vertexai/node/package.json | 8 ++- .../google-vertexai/test-with-latest-deps.sh | 2 + .../google-vertexai/test-with-lowest-deps.sh | 1 + .../with_standard_tests/node/package.json | 5 +- .../openai/node/package.json | 5 +- .../openai/test-with-latest-deps.sh | 1 + .../openai/test-with-lowest-deps.sh | 1 + examples/package.json | 2 +- langchain-core/package.json | 2 +- langchain-core/src/singletons/tracer.ts | 4 ++ .../tracers/tests/langsmith_interop.test.ts | 17 ++++-- .../src/tracers/tracer_langchain.ts | 8 +-- langchain/package.json | 2 +- libs/langchain-community/package.json | 2 +- yarn.lock | 16 +++--- 25 files changed, 95 insertions(+), 54 deletions(-) diff --git a/dependency_range_tests/docker-compose.yml b/dependency_range_tests/docker-compose.yml index 3305a85d20a2f..579707fbe1ad2 100644 --- a/dependency_range_tests/docker-compose.yml +++ b/dependency_range_tests/docker-compose.yml @@ -2,7 +2,7 @@ version: "3" services: # LangChain langchain-latest-deps: - image: node:18 + image: node:20 environment: PUPPETEER_SKIP_DOWNLOAD: "true" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" @@ -13,7 +13,7 @@ services: - ./scripts:/scripts command: bash /scripts/langchain/test-with-latest-deps.sh langchain-lowest-deps: - image: node:18 + image: node:20 environment: PUPPETEER_SKIP_DOWNLOAD: "true" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" @@ -23,10 +23,10 @@ services: - ../langchain:/langchain - ./scripts:/scripts command: bash /scripts/langchain/test-with-lowest-deps.sh - + # Community community-latest-deps: - image: node:18 + image: node:20 environment: PUPPETEER_SKIP_DOWNLOAD: "true" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" @@ -34,13 +34,13 @@ services: working_dir: /app volumes: - ../turbo.json:/turbo.json - - ../package.json:/package.json + - ./scripts/with_standard_tests/community/node/package.json:/package.json - ../libs/langchain-standard-tests:/libs/langchain-standard-tests - ../libs/langchain-community:/libs/langchain-community - ./scripts:/scripts command: bash /scripts/with_standard_tests/community/test-with-latest-deps.sh community-lowest-deps: - image: node:18 + image: node:20 environment: PUPPETEER_SKIP_DOWNLOAD: "true" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" @@ -48,20 +48,20 @@ services: working_dir: /app volumes: - ../turbo.json:/turbo.json - - ../package.json:/package.json + - ./scripts/with_standard_tests/community/node/package.json:/package.json - ../libs/langchain-standard-tests:/libs/langchain-standard-tests - ../libs/langchain-community:/libs/langchain-community - ./scripts:/scripts command: bash /scripts/with_standard_tests/community/test-with-lowest-deps.sh community-npm-install: - image: node:18 + image: node:20 environment: PUPPETEER_SKIP_DOWNLOAD: "true" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" working_dir: /app volumes: - ../turbo.json:/turbo.json - - ../package.json:/package.json + - ./scripts/with_standard_tests/community/node/package.json:/package.json - ../libs/langchain-standard-tests:/libs/langchain-standard-tests - ../libs/langchain-community:/libs/langchain-community - ./scripts:/scripts @@ -69,7 +69,7 @@ services: # OpenAI openai-latest-deps: - image: node:18 + image: node:20 environment: PUPPETEER_SKIP_DOWNLOAD: "true" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" @@ -77,13 +77,13 @@ services: working_dir: /app volumes: - ../turbo.json:/turbo.json - - ../package.json:/package.json + - ./scripts/with_standard_tests/openai/node/package.json:/package.json - ../libs/langchain-standard-tests:/libs/langchain-standard-tests - ../libs/langchain-openai:/libs/langchain-openai - ./scripts:/scripts command: bash /scripts/with_standard_tests/openai/test-with-latest-deps.sh openai-lowest-deps: - image: node:18 + image: node:20 environment: PUPPETEER_SKIP_DOWNLOAD: "true" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" @@ -91,7 +91,7 @@ services: working_dir: /app volumes: - ../turbo.json:/turbo.json - - ../package.json:/package.json + - ./scripts/with_standard_tests/openai/node/package.json:/package.json - ../libs/langchain-standard-tests:/libs/langchain-standard-tests - ../libs/langchain-openai:/libs/langchain-openai - ./scripts:/scripts @@ -99,7 +99,7 @@ services: # Anthropic anthropic-latest-deps: - image: node:18 + image: node:20 environment: PUPPETEER_SKIP_DOWNLOAD: "true" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" @@ -107,13 +107,13 @@ services: working_dir: /app volumes: - ../turbo.json:/turbo.json - - ../package.json:/package.json + - ./scripts/with_standard_tests/anthropic/node/package.json:/package.json - ../libs/langchain-standard-tests:/libs/langchain-standard-tests - ../libs/langchain-anthropic:/libs/langchain-anthropic - ./scripts:/scripts command: bash /scripts/with_standard_tests/anthropic/test-with-latest-deps.sh anthropic-lowest-deps: - image: node:18 + image: node:20 environment: PUPPETEER_SKIP_DOWNLOAD: "true" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" @@ -121,7 +121,7 @@ services: working_dir: /app volumes: - ../turbo.json:/turbo.json - - ../package.json:/package.json + - ./scripts/with_standard_tests/anthropic/node/package.json:/package.json - ../libs/langchain-standard-tests:/libs/langchain-standard-tests - ../libs/langchain-anthropic:/libs/langchain-anthropic - ./scripts:/scripts @@ -129,7 +129,7 @@ services: # Google VertexAI google-vertexai-latest-deps: - image: node:18 + image: node:20 environment: PUPPETEER_SKIP_DOWNLOAD: "true" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" @@ -137,13 +137,13 @@ services: working_dir: /app volumes: - ../turbo.json:/turbo.json - - ../package.json:/package.json + - ./scripts/with_standard_tests/google-vertexai/node/package.json:/package.json - ../libs/langchain-standard-tests:/libs/langchain-standard-tests - ../libs/langchain-google-vertexai:/libs/langchain-google-vertexai - ./scripts:/scripts command: bash /scripts/with_standard_tests/google-vertexai/test-with-latest-deps.sh google-vertexai-lowest-deps: - image: node:18 + image: node:20 environment: PUPPETEER_SKIP_DOWNLOAD: "true" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" @@ -151,7 +151,7 @@ services: working_dir: /app volumes: - ../turbo.json:/turbo.json - - ../package.json:/package.json + - ./scripts/with_standard_tests/google-vertexai/node/package.json:/package.json - ../libs/langchain-standard-tests:/libs/langchain-standard-tests - ../libs/langchain-google-vertexai:/libs/langchain-google-vertexai - ./scripts:/scripts @@ -159,7 +159,7 @@ services: # Cohere cohere-latest-deps: - image: node:18 + image: node:20 environment: PUPPETEER_SKIP_DOWNLOAD: "true" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" @@ -167,13 +167,13 @@ services: working_dir: /app volumes: - ../turbo.json:/turbo.json - - ../package.json:/package.json + - ./scripts/with_standard_tests/cohere/node/package.json:/package.json - ../libs/langchain-standard-tests:/libs/langchain-standard-tests - ../libs/langchain-cohere:/libs/langchain-cohere - ./scripts:/scripts command: bash /scripts/with_standard_tests/cohere/test-with-latest-deps.sh cohere-lowest-deps: - image: node:18 + image: node:20 environment: PUPPETEER_SKIP_DOWNLOAD: "true" PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true" @@ -181,8 +181,8 @@ services: working_dir: /app volumes: - ../turbo.json:/turbo.json - - ../package.json:/package.json + - ./scripts/with_standard_tests/cohere/node/package.json:/package.json - ../libs/langchain-standard-tests:/libs/langchain-standard-tests - ../libs/langchain-cohere:/libs/langchain-cohere - ./scripts:/scripts - command: bash /scripts/with_standard_tests/cohere/test-with-lowest-deps.sh \ No newline at end of file + command: bash /scripts/with_standard_tests/cohere/test-with-lowest-deps.sh diff --git a/dependency_range_tests/scripts/with_standard_tests/anthropic/node/package.json b/dependency_range_tests/scripts/with_standard_tests/anthropic/node/package.json index a4622fc745976..472405f4ca222 100644 --- a/dependency_range_tests/scripts/with_standard_tests/anthropic/node/package.json +++ b/dependency_range_tests/scripts/with_standard_tests/anthropic/node/package.json @@ -2,8 +2,11 @@ "name": "dependency-range-tests", "version": "0.0.0", "private": true, + "workspaces": [ + "libs/*" + ], "description": "Tests dependency ranges for LangChain.", "dependencies": { "semver": "^7.5.4" } -} \ No newline at end of file +} diff --git a/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-latest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-latest-deps.sh index bcf32dfbaa9a1..46b76fba9993f 100644 --- a/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-latest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-latest-deps.sh @@ -27,6 +27,7 @@ node "update_resolutions_latest.js" # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" +touch yarn.lock yarn # Navigate into `@langchain/anthropic` to build and run tests diff --git a/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-lowest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-lowest-deps.sh index 11eae9e21a806..d8b109b41db3f 100644 --- a/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-lowest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/anthropic/test-with-lowest-deps.sh @@ -25,6 +25,7 @@ node "update_resolutions_lowest.js" # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" +touch yarn.lock yarn # Navigate into `@langchain/anthropic` to build and run tests diff --git a/dependency_range_tests/scripts/with_standard_tests/cohere/node/package.json b/dependency_range_tests/scripts/with_standard_tests/cohere/node/package.json index a4622fc745976..472405f4ca222 100644 --- a/dependency_range_tests/scripts/with_standard_tests/cohere/node/package.json +++ b/dependency_range_tests/scripts/with_standard_tests/cohere/node/package.json @@ -2,8 +2,11 @@ "name": "dependency-range-tests", "version": "0.0.0", "private": true, + "workspaces": [ + "libs/*" + ], "description": "Tests dependency ranges for LangChain.", "dependencies": { "semver": "^7.5.4" } -} \ No newline at end of file +} diff --git a/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-latest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-latest-deps.sh index 24c5ccc872f81..afb78b0bdcd8d 100644 --- a/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-latest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-latest-deps.sh @@ -26,6 +26,7 @@ node "update_resolutions_latest.js" # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" +touch yarn.lock yarn # Navigate into `@langchain/cohere` to build and run tests diff --git a/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-lowest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-lowest-deps.sh index 3868e0a9d6c03..7411c49e564cf 100644 --- a/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-lowest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/cohere/test-with-lowest-deps.sh @@ -26,6 +26,7 @@ node "update_resolutions_lowest.js" # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" +touch yarn.lock yarn # Navigate into `@langchain/cohere` to build and run tests diff --git a/dependency_range_tests/scripts/with_standard_tests/community/node/package.json b/dependency_range_tests/scripts/with_standard_tests/community/node/package.json index a4622fc745976..472405f4ca222 100644 --- a/dependency_range_tests/scripts/with_standard_tests/community/node/package.json +++ b/dependency_range_tests/scripts/with_standard_tests/community/node/package.json @@ -2,8 +2,11 @@ "name": "dependency-range-tests", "version": "0.0.0", "private": true, + "workspaces": [ + "libs/*" + ], "description": "Tests dependency ranges for LangChain.", "dependencies": { "semver": "^7.5.4" } -} \ No newline at end of file +} diff --git a/dependency_range_tests/scripts/with_standard_tests/community/test-with-latest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/community/test-with-latest-deps.sh index df63a38f85465..5e5d5c893316c 100644 --- a/dependency_range_tests/scripts/with_standard_tests/community/test-with-latest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/community/test-with-latest-deps.sh @@ -26,6 +26,7 @@ node "update_resolutions_latest.js" # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" +touch yarn.lock yarn # Navigate into `@langchain/community` to build and run tests diff --git a/dependency_range_tests/scripts/with_standard_tests/community/test-with-lowest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/community/test-with-lowest-deps.sh index e6d70012a8096..5575f53b0b5cd 100644 --- a/dependency_range_tests/scripts/with_standard_tests/community/test-with-lowest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/community/test-with-lowest-deps.sh @@ -26,6 +26,7 @@ node "update_resolutions_lowest.js" # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" +touch yarn.lock yarn # Navigate into `@langchain/package` to build and run tests diff --git a/dependency_range_tests/scripts/with_standard_tests/google-vertexai/node/package.json b/dependency_range_tests/scripts/with_standard_tests/google-vertexai/node/package.json index a4622fc745976..268de13087d84 100644 --- a/dependency_range_tests/scripts/with_standard_tests/google-vertexai/node/package.json +++ b/dependency_range_tests/scripts/with_standard_tests/google-vertexai/node/package.json @@ -2,8 +2,12 @@ "name": "dependency-range-tests", "version": "0.0.0", "private": true, + "workspaces": [ + "libs/*" + ], "description": "Tests dependency ranges for LangChain.", "dependencies": { "semver": "^7.5.4" - } -} \ No newline at end of file + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" +} diff --git a/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-latest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-latest-deps.sh index 567366beb19e5..00d5cb3e983b7 100644 --- a/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-latest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-latest-deps.sh @@ -26,6 +26,8 @@ node "update_resolutions_latest.js" # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" +touch yarn.lock +cat ./package.json yarn # Navigate into `@langchain/google-vertexai` to build and run tests diff --git a/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-lowest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-lowest-deps.sh index 23dcf3ba0d823..d04849a08c7f8 100644 --- a/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-lowest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/google-vertexai/test-with-lowest-deps.sh @@ -26,6 +26,7 @@ node "update_resolutions_lowest.js" # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" +touch yarn.lock yarn # Navigate into `@langchain/package` to build and run tests diff --git a/dependency_range_tests/scripts/with_standard_tests/node/package.json b/dependency_range_tests/scripts/with_standard_tests/node/package.json index ba8b482e75150..3b53ce354167f 100644 --- a/dependency_range_tests/scripts/with_standard_tests/node/package.json +++ b/dependency_range_tests/scripts/with_standard_tests/node/package.json @@ -2,6 +2,9 @@ "name": "dependency-range-tests", "version": "0.0.0", "private": true, + "workspaces": [ + "libs/*" + ], "description": "Tests dependency ranges for LangChain.", "dependencies": {} -} \ No newline at end of file +} diff --git a/dependency_range_tests/scripts/with_standard_tests/openai/node/package.json b/dependency_range_tests/scripts/with_standard_tests/openai/node/package.json index a4622fc745976..472405f4ca222 100644 --- a/dependency_range_tests/scripts/with_standard_tests/openai/node/package.json +++ b/dependency_range_tests/scripts/with_standard_tests/openai/node/package.json @@ -2,8 +2,11 @@ "name": "dependency-range-tests", "version": "0.0.0", "private": true, + "workspaces": [ + "libs/*" + ], "description": "Tests dependency ranges for LangChain.", "dependencies": { "semver": "^7.5.4" } -} \ No newline at end of file +} diff --git a/dependency_range_tests/scripts/with_standard_tests/openai/test-with-latest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/openai/test-with-latest-deps.sh index 2080ec7864679..7c399d0fb223d 100644 --- a/dependency_range_tests/scripts/with_standard_tests/openai/test-with-latest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/openai/test-with-latest-deps.sh @@ -26,6 +26,7 @@ node "update_resolutions_latest.js" # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" +touch yarn.lock yarn # Navigate into `@langchain/openai` to build and run tests diff --git a/dependency_range_tests/scripts/with_standard_tests/openai/test-with-lowest-deps.sh b/dependency_range_tests/scripts/with_standard_tests/openai/test-with-lowest-deps.sh index 6f47d13e8aa1c..a462b8d20c12d 100644 --- a/dependency_range_tests/scripts/with_standard_tests/openai/test-with-lowest-deps.sh +++ b/dependency_range_tests/scripts/with_standard_tests/openai/test-with-lowest-deps.sh @@ -26,6 +26,7 @@ node "update_resolutions_lowest.js" # Navigate back to monorepo root and install dependencies cd "$monorepo_dir" +touch yarn.lock yarn # Navigate into `@langchain/package` to build and run tests diff --git a/examples/package.json b/examples/package.json index 792c866804fb5..177aa64333177 100644 --- a/examples/package.json +++ b/examples/package.json @@ -93,7 +93,7 @@ "ioredis": "^5.3.2", "js-yaml": "^4.1.0", "langchain": "workspace:*", - "langsmith": "^0.2.0", + "langsmith": "^0.2.8", "mongodb": "^6.3.0", "pg": "^8.11.0", "pickleparser": "^0.2.1", diff --git a/langchain-core/package.json b/langchain-core/package.json index 15284c5783961..b7d0a4cae8454 100644 --- a/langchain-core/package.json +++ b/langchain-core/package.json @@ -37,7 +37,7 @@ "camelcase": "6", "decamelize": "1.2.0", "js-tiktoken": "^1.0.12", - "langsmith": "^0.2.0", + "langsmith": "^0.2.8", "mustache": "^4.2.0", "p-queue": "^6.6.2", "p-retry": "4", diff --git a/langchain-core/src/singletons/tracer.ts b/langchain-core/src/singletons/tracer.ts index 89696240705dc..1a51a43aac918 100644 --- a/langchain-core/src/singletons/tracer.ts +++ b/langchain-core/src/singletons/tracer.ts @@ -16,3 +16,7 @@ export const getDefaultLangChainClientSingleton = () => { } return client; }; + +export const setDefaultLangChainClientSingleton = (newClient: Client) => { + client = newClient; +}; diff --git a/langchain-core/src/tracers/tests/langsmith_interop.test.ts b/langchain-core/src/tracers/tests/langsmith_interop.test.ts index 11d654fca1292..48429e1d5f09b 100644 --- a/langchain-core/src/tracers/tests/langsmith_interop.test.ts +++ b/langchain-core/src/tracers/tests/langsmith_interop.test.ts @@ -11,14 +11,20 @@ import { expect, } from "@jest/globals"; import { traceable } from "langsmith/traceable"; +import { Client } from "langsmith"; import { RunnableLambda } from "../../runnables/base.js"; import { BaseMessage, HumanMessage } from "../../messages/index.js"; +import { setDefaultLangChainClientSingleton } from "../../singletons/tracer.js"; let fetchMock: any; const originalTracingEnvValue = process.env.LANGCHAIN_TRACING_V2; +const client = new Client({ + autoBatchTracing: false, +}); + beforeEach(() => { fetchMock = jest.spyOn(global, "fetch").mockImplementation(() => Promise.resolve({ @@ -29,6 +35,7 @@ beforeEach(() => { }, } as any) ); + setDefaultLangChainClientSingleton(client); process.env.LANGCHAIN_TRACING_V2 = "true"; }); @@ -50,7 +57,7 @@ test.each(["true", "false"])( await new Promise((resolve) => setTimeout(resolve, 300)); return msg.content + name; }, - { name: "aiGreet", tracingEnabled: true } + { name: "aiGreet", tracingEnabled: true, client } ); const root = RunnableLambda.from(async (messages: BaseMessage[]) => { @@ -197,7 +204,7 @@ test.each(["true", "false"])( expect(getContextVariable("foo")).toEqual("baz"); return msg.content + name; }, - { name: "aiGreet", tracingEnabled: true } + { name: "aiGreet", tracingEnabled: true, client } ); const root = RunnableLambda.from(async (messages: BaseMessage[]) => { @@ -485,7 +492,7 @@ test.each(["true", "false"])( const contents = await nested.invoke([msg]); return contents[0] + name; }, - { name: "aiGreet", tracingEnabled: true } + { name: "aiGreet", tracingEnabled: true, client } ); await aiGreet(new HumanMessage({ content: "Hello!" }), "mitochondria"); @@ -632,7 +639,7 @@ test.each(["true", "false"])( expect(getContextVariable("foo")).toEqual("bar"); return contents[0] + name; }, - { name: "aiGreet", tracingEnabled: true } + { name: "aiGreet", tracingEnabled: true, client } ); await aiGreet(new HumanMessage({ content: "Hello!" }), "mitochondria"); @@ -781,7 +788,7 @@ test.each(["true", "false"])( yield letter; } }, - { name: "aiGreet", tracingEnabled: true } + { name: "aiGreet", tracingEnabled: true, client } ); for await (const _ of aiGreet( diff --git a/langchain-core/src/tracers/tracer_langchain.ts b/langchain-core/src/tracers/tracer_langchain.ts index e5719125df510..8a58a8e8b1194 100644 --- a/langchain-core/src/tracers/tracer_langchain.ts +++ b/langchain-core/src/tracers/tracer_langchain.ts @@ -1,4 +1,4 @@ -import { Client } from "langsmith"; +import type { Client, LangSmithTracingClientInterface } from "langsmith"; import { RunTree } from "langsmith/run_trees"; import { getCurrentRunTree } from "langsmith/singletons/traceable"; @@ -36,7 +36,7 @@ export interface RunUpdate extends BaseRunUpdate { export interface LangChainTracerFields extends BaseCallbackHandlerInput { exampleId?: string; projectName?: string; - client?: Client; + client?: LangSmithTracingClientInterface; } export class LangChainTracer @@ -49,7 +49,7 @@ export class LangChainTracer exampleId?: string; - client: Client; + client: LangSmithTracingClientInterface; constructor(fields: LangChainTracerFields = {}) { super(fields); @@ -156,7 +156,7 @@ export class LangChainTracer parent_run: undefined, // inherited properties - client: this.client, + client: this.client as Client, project_name: this.projectName, reference_example_id: this.exampleId, tracingEnabled: true, diff --git a/langchain/package.json b/langchain/package.json index 24c44241b0f51..9a31b79868dfe 100644 --- a/langchain/package.json +++ b/langchain/package.json @@ -520,7 +520,7 @@ "js-tiktoken": "^1.0.12", "js-yaml": "^4.1.0", "jsonpointer": "^5.0.1", - "langsmith": "^0.2.0", + "langsmith": "^0.2.8", "openapi-types": "^12.1.3", "p-retry": "4", "uuid": "^10.0.0", diff --git a/libs/langchain-community/package.json b/libs/langchain-community/package.json index 7b826ad1e106b..e9cf7a69c8820 100644 --- a/libs/langchain-community/package.json +++ b/libs/langchain-community/package.json @@ -41,7 +41,7 @@ "flat": "^5.0.2", "js-yaml": "^4.1.0", "langchain": ">=0.2.3 <0.3.0 || >=0.3.4 <0.4.0", - "langsmith": "^0.2.0", + "langsmith": "^0.2.8", "uuid": "^10.0.0", "zod": "^3.22.3", "zod-to-json-schema": "^3.22.5" diff --git a/yarn.lock b/yarn.lock index 5e6b6ed60a57e..df4ec9cc1a6d3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11829,7 +11829,7 @@ __metadata: jsdom: ^22.1.0 jsonwebtoken: ^9.0.2 langchain: ">=0.2.3 <0.3.0 || >=0.3.4 <0.4.0" - langsmith: ^0.2.0 + langsmith: ^0.2.8 llmonitor: ^0.5.9 lodash: ^4.17.21 lunary: ^0.7.10 @@ -12263,7 +12263,7 @@ __metadata: jest: ^29.5.0 jest-environment-node: ^29.6.4 js-tiktoken: ^1.0.12 - langsmith: ^0.2.0 + langsmith: ^0.2.8 ml-matrix: ^6.10.4 mustache: ^4.2.0 p-queue: ^6.6.2 @@ -27675,7 +27675,7 @@ __metadata: ioredis: ^5.3.2 js-yaml: ^4.1.0 langchain: "workspace:*" - langsmith: ^0.2.0 + langsmith: ^0.2.8 mongodb: ^6.3.0 pg: ^8.11.0 pickleparser: ^0.2.1 @@ -33329,7 +33329,7 @@ __metadata: js-tiktoken: ^1.0.12 js-yaml: ^4.1.0 jsonpointer: ^5.0.1 - langsmith: ^0.2.0 + langsmith: ^0.2.8 openai: ^4.41.1 openapi-types: ^12.1.3 p-retry: 4 @@ -33408,9 +33408,9 @@ __metadata: languageName: unknown linkType: soft -"langsmith@npm:^0.2.0": - version: 0.2.0 - resolution: "langsmith@npm:0.2.0" +"langsmith@npm:^0.2.8": + version: 0.2.8 + resolution: "langsmith@npm:0.2.8" dependencies: "@types/uuid": ^10.0.0 commander: ^10.0.1 @@ -33423,7 +33423,7 @@ __metadata: peerDependenciesMeta: openai: optional: true - checksum: 0cd92d0e31526d309af197a3502c93a00ac8c09f6b2864161a18a5c1e8b95b0e8203bad2dfe3b4beb26055fc815a8d70730592a58c9af7e202917b13d01f695c + checksum: 8695df08a09b9885b0308c66fbf9802edbe20e286fec3db8faa75ed1893a7aafae014441e311677bb60abb33af49da7f7d8404f55fffbdad5aec61cf65215fc8 languageName: node linkType: hard