Skip to content

Commit 625475f

Browse files
committed
Fix side effect
1 parent 4af2974 commit 625475f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

langchain/src/util/hub.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,6 @@ import { backOff } from "exponential-backoff";
22

33
import { fetchWithTimeout, extname, FileLoader, LoadValues } from "./index.js";
44

5-
const LANGCHAIN_HUB_DEFAULT_REF =
6-
(typeof process !== "undefined"
7-
? // eslint-disable-next-line no-process-env
8-
process.env.LANGCHAIN_HUB_DEFAULT_REF
9-
: undefined) ?? "master";
10-
const LANGCHAIN_HUB_URL_BASE =
11-
(typeof process !== "undefined"
12-
? // eslint-disable-next-line no-process-env
13-
process.env.LANGCHAIN_HUB_URL_BASE
14-
: undefined) ??
15-
"https://raw.githubusercontent.com/hwchase17/langchain-hub/";
16-
175
const HUB_PATH_REGEX = /lc(@[^:]+)?:\/\/(.*)/;
186

197
const URL_PATH_SEPARATOR = "/";
@@ -25,6 +13,18 @@ export const loadFromHub = async <T>(
2513
validSuffixes: Set<string>,
2614
values: LoadValues = {}
2715
): Promise<T | undefined> => {
16+
const LANGCHAIN_HUB_DEFAULT_REF =
17+
(typeof process !== "undefined"
18+
? // eslint-disable-next-line no-process-env
19+
process.env.LANGCHAIN_HUB_DEFAULT_REF
20+
: undefined) ?? "master";
21+
const LANGCHAIN_HUB_URL_BASE =
22+
(typeof process !== "undefined"
23+
? // eslint-disable-next-line no-process-env
24+
process.env.LANGCHAIN_HUB_URL_BASE
25+
: undefined) ??
26+
"https://raw.githubusercontent.com/hwchase17/langchain-hub/";
27+
2828
const match = uri.match(HUB_PATH_REGEX);
2929
if (!match) {
3030
return undefined;

0 commit comments

Comments
 (0)