-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
index.ts
28 lines (27 loc) · 987 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { load as coreLoad } from "@langchain/core/load";
import { optionalImportEntrypoints } from "./import_constants.js";
import * as importMap from "./import_map.js";
import { OptionalImportMap } from "./import_type.js";
/**
* Load a LangChain module from a serialized text representation.
* NOTE: This functionality is currently in beta.
* Loaded classes may change independently of semver.
* @param text Serialized text representation of the module.
* @param secretsMap
* @param optionalImportsMap
* @returns A loaded instance of a LangChain module.
*/
export async function load<T>(
text: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
secretsMap: Record<string, any> = {},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
optionalImportsMap: OptionalImportMap & Record<string, any> = {}
): Promise<T> {
return coreLoad(text, {
secretsMap,
optionalImportsMap,
optionalImportEntrypoints,
importMap,
});
}