Skip to content

Commit

Permalink
Relax required arguments on core load method (#4385)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 authored Feb 13, 2024
1 parent e051d96 commit ae11d0a
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions langchain-core/src/load/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ function combineAliasesAndInvert(constructor: typeof Serializable) {

async function reviver(
this: {
optionalImportsMap: OptionalImportMap;
optionalImportEntrypoints: string[];
secretsMap: SecretMap;
importMap: Record<string, unknown>;
optionalImportsMap?: OptionalImportMap;
optionalImportEntrypoints?: string[];
secretsMap?: SecretMap;
importMap?: Record<string, unknown>;
path?: string[];
},
value: unknown
): Promise<unknown> {
const {
optionalImportsMap,
optionalImportEntrypoints,
importMap,
secretsMap,
optionalImportsMap = {},
optionalImportEntrypoints = [],
importMap = {},
secretsMap = {},
path = ["$"],
} = this;
const pathStr = path.join(".");
Expand Down Expand Up @@ -234,21 +234,13 @@ async function reviver(

export async function load<T>(
text: string,
{
secretsMap,
importMap,
optionalImportsMap,
optionalImportEntrypoints,
}: {
secretsMap: SecretMap;
optionalImportsMap: OptionalImportMap;
optionalImportEntrypoints: string[];
importMap: Record<string, unknown>;
mappings?: {
secretsMap?: SecretMap;
optionalImportsMap?: OptionalImportMap;
optionalImportEntrypoints?: string[];
importMap?: Record<string, unknown>;
}
): Promise<T> {
const json = JSON.parse(text);
return reviver.call(
{ secretsMap, optionalImportsMap, optionalImportEntrypoints, importMap },
json
) as Promise<T>;
return reviver.call({ ...mappings }, json) as Promise<T>;
}

0 comments on commit ae11d0a

Please sign in to comment.