Skip to content

Commit 2e45c43

Browse files
authored
fix(langchain): remove bad dynamic import for LS (#9271)
1 parent 28eceac commit 2e45c43

File tree

4 files changed

+46
-64
lines changed

4 files changed

+46
-64
lines changed

.changeset/nervous-carpets-tie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"langchain": patch
3+
---
4+
5+
fix(langchain): remove bad dynamic import for LS

libs/langchain/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
"dotenv": "^16.0.3",
5050
"dpdm": "^3.14.0",
5151
"eslint": "^9.34.0",
52-
"langsmith": "^0.3.64",
5352
"openai": "^5.1.0",
5453
"peggy": "^3.0.2",
5554
"prettier": "^2.8.3",
@@ -67,12 +66,10 @@
6766
"dependencies": {
6867
"@langchain/langgraph": "^1.0.0",
6968
"@langchain/langgraph-checkpoint": "^1.0.0",
69+
"langsmith": "~0.3.74",
7070
"uuid": "^10.0.0",
7171
"zod": "^3.25.76 || ^4"
7272
},
73-
"optionalDependencies": {
74-
"langsmith": "^0.3.64"
75-
},
7673
"publishConfig": {
7774
"access": "public"
7875
},

libs/langchain/src/hub/base.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { BaseLanguageModel } from "@langchain/core/language_models/base";
22
import type { Runnable } from "@langchain/core/runnables";
33

4-
import type { Client, ClientConfig } from "langsmith";
4+
import { Client } from "langsmith";
55
import type { PromptCommit } from "langsmith/schemas";
66

77
/**
@@ -25,7 +25,6 @@ export async function basePush(
2525
tags?: string[];
2626
}
2727
): Promise<string> {
28-
const Client = await loadLangSmith();
2928
const client = new Client(options);
3029
const payloadOptions = {
3130
object: runnable,
@@ -42,7 +41,6 @@ export async function basePull(
4241
ownerRepoCommit: string,
4342
options?: { apiKey?: string; apiUrl?: string; includeModel?: boolean }
4443
): Promise<PromptCommit> {
45-
const Client = await loadLangSmith();
4644
const client = new Client(options);
4745

4846
const promptObject = await client.pullPromptCommit(ownerRepoCommit, {
@@ -188,20 +186,3 @@ export function bindOutputSchema<T extends Runnable>(loadedSequence: T) {
188186
}
189187
return loadedSequence;
190188
}
191-
192-
/**
193-
* Dynamically load the LangSmith client.
194-
* @returns The LangSmith client.
195-
*/
196-
async function loadLangSmith(): Promise<new (config?: ClientConfig) => Client> {
197-
try {
198-
const { Client } = await import("langsmith");
199-
return Client;
200-
} catch (error) {
201-
// eslint-disable-next-line no-instanceof/no-instanceof
202-
const errorMessage = error instanceof Error ? error.message : String(error);
203-
throw new Error(
204-
`Error loading "langsmith" package, install it via \`npm install langsmith\` before you use this function.\nError: ${errorMessage}`
205-
);
206-
}
207-
}

pnpm-lock.yaml

Lines changed: 39 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)