langchain 0.0.194 → 0.0.196
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.ts +1 -1
- package/dist/base_language/count_tokens.cjs +5 -70
- package/dist/base_language/count_tokens.d.ts +1 -10
- package/dist/base_language/count_tokens.js +1 -65
- package/dist/base_language/index.cjs +6 -196
- package/dist/base_language/index.d.ts +1 -111
- package/dist/base_language/index.js +1 -191
- package/dist/cache/base.cjs +15 -37
- package/dist/cache/base.d.ts +1 -20
- package/dist/cache/base.js +1 -33
- package/dist/cache/index.cjs +2 -46
- package/dist/cache/index.d.ts +1 -29
- package/dist/cache/index.js +1 -45
- package/dist/callbacks/base.cjs +3 -139
- package/dist/callbacks/base.d.ts +1 -266
- package/dist/callbacks/base.js +1 -126
- package/dist/callbacks/handlers/console.cjs +14 -221
- package/dist/callbacks/handlers/console.d.ts +1 -117
- package/dist/callbacks/handlers/console.js +1 -217
- package/dist/callbacks/handlers/initialize.cjs +15 -30
- package/dist/callbacks/handlers/initialize.d.ts +1 -16
- package/dist/callbacks/handlers/initialize.js +1 -27
- package/dist/callbacks/handlers/log_stream.cjs +15 -293
- package/dist/callbacks/handlers/log_stream.d.ts +1 -100
- package/dist/callbacks/handlers/log_stream.js +1 -289
- package/dist/callbacks/handlers/run_collector.cjs +15 -48
- package/dist/callbacks/handlers/run_collector.d.ts +1 -26
- package/dist/callbacks/handlers/run_collector.js +1 -46
- package/dist/callbacks/handlers/tracer.cjs +15 -375
- package/dist/callbacks/handlers/tracer.d.ts +1 -70
- package/dist/callbacks/handlers/tracer.js +1 -373
- package/dist/callbacks/handlers/tracer_langchain.cjs +15 -104
- package/dist/callbacks/handlers/tracer_langchain.d.ts +1 -41
- package/dist/callbacks/handlers/tracer_langchain.js +1 -102
- package/dist/callbacks/handlers/tracer_langchain_v1.cjs +15 -197
- package/dist/callbacks/handlers/tracer_langchain_v1.d.ts +1 -57
- package/dist/callbacks/handlers/tracer_langchain_v1.js +1 -195
- package/dist/callbacks/manager.cjs +15 -676
- package/dist/callbacks/manager.d.ts +1 -180
- package/dist/callbacks/manager.js +1 -666
- package/dist/callbacks/promises.cjs +14 -42
- package/dist/callbacks/promises.d.ts +1 -11
- package/dist/callbacks/promises.js +1 -37
- package/dist/chains/graph_qa/prompts.d.ts +1 -1
- package/dist/chains/openai_functions/structured_output.cjs +2 -2
- package/dist/chains/openai_functions/structured_output.d.ts +1 -1
- package/dist/chains/openai_functions/structured_output.js +1 -1
- package/dist/chat_models/baiduwenxin.d.ts +1 -1
- package/dist/chat_models/base.cjs +15 -296
- package/dist/chat_models/base.d.ts +1 -122
- package/dist/chat_models/base.js +1 -292
- package/dist/chat_models/bedrock/web.d.ts +1 -1
- package/dist/chat_models/fireworks.d.ts +1 -1
- package/dist/document.cjs +2 -24
- package/dist/document.d.ts +1 -12
- package/dist/document.js +1 -23
- package/dist/document_loaders/web/azure_blob_storage_file.d.ts +1 -1
- package/dist/document_loaders/web/s3.d.ts +1 -1
- package/dist/embeddings/base.cjs +15 -22
- package/dist/embeddings/base.d.ts +1 -33
- package/dist/embeddings/base.js +1 -20
- package/dist/embeddings/cache_backed.cjs +2 -2
- package/dist/embeddings/cache_backed.js +1 -1
- package/dist/embeddings/hf.cjs +1 -2
- package/dist/embeddings/hf.js +1 -2
- package/dist/evaluation/agents/trajectory.d.ts +1 -1
- package/dist/evaluation/criteria/prompt.d.ts +2 -2
- package/dist/evaluation/qa/prompt.d.ts +2 -2
- package/dist/experimental/hubs/makersuite/googlemakersuitehub.d.ts +1 -1
- package/dist/experimental/openai_assistant/index.cjs +2 -1
- package/dist/experimental/openai_assistant/index.d.ts +2 -1
- package/dist/experimental/openai_assistant/index.js +2 -1
- package/dist/experimental/openai_files/index.cjs +88 -0
- package/dist/experimental/openai_files/index.d.ts +79 -0
- package/dist/experimental/openai_files/index.js +84 -0
- package/dist/experimental/plan_and_execute/prompt.d.ts +1 -1
- package/dist/llms/base.cjs +15 -278
- package/dist/llms/base.d.ts +1 -115
- package/dist/llms/base.js +1 -275
- package/dist/llms/bedrock/web.d.ts +1 -1
- package/dist/llms/fireworks.d.ts +1 -1
- package/dist/load/import_constants.cjs +1 -0
- package/dist/load/import_constants.js +1 -0
- package/dist/load/import_map.cjs +4 -2
- package/dist/load/import_map.d.ts +2 -0
- package/dist/load/import_map.js +2 -0
- package/dist/load/index.cjs +7 -148
- package/dist/load/index.js +7 -148
- package/dist/load/map_keys.cjs +0 -24
- package/dist/load/map_keys.d.ts +0 -6
- package/dist/load/map_keys.js +1 -17
- package/dist/load/serializable.cjs +15 -178
- package/dist/load/serializable.d.ts +1 -66
- package/dist/load/serializable.js +1 -175
- package/dist/memory/base.cjs +17 -92
- package/dist/memory/base.d.ts +2 -68
- package/dist/memory/base.js +2 -87
- package/dist/output_parsers/openai_functions.cjs +2 -2
- package/dist/output_parsers/openai_functions.d.ts +1 -1
- package/dist/output_parsers/openai_functions.js +1 -1
- package/dist/output_parsers/regex.d.ts +1 -1
- package/dist/output_parsers/structured.d.ts +1 -1
- package/dist/prompts/base.cjs +8 -183
- package/dist/prompts/base.d.ts +3 -132
- package/dist/prompts/base.js +3 -178
- package/dist/prompts/chat.cjs +15 -477
- package/dist/prompts/chat.d.ts +1 -219
- package/dist/prompts/chat.js +1 -466
- package/dist/prompts/few_shot.cjs +15 -353
- package/dist/prompts/few_shot.d.ts +1 -192
- package/dist/prompts/few_shot.js +1 -350
- package/dist/prompts/index.cjs +3 -2
- package/dist/prompts/index.d.ts +2 -1
- package/dist/prompts/index.js +2 -1
- package/dist/prompts/pipeline.cjs +15 -142
- package/dist/prompts/pipeline.d.ts +1 -98
- package/dist/prompts/pipeline.js +1 -140
- package/dist/prompts/prompt.cjs +15 -146
- package/dist/prompts/prompt.d.ts +1 -92
- package/dist/prompts/prompt.js +1 -144
- package/dist/prompts/selectors/LengthBasedExampleSelector.cjs +15 -148
- package/dist/prompts/selectors/LengthBasedExampleSelector.d.ts +1 -89
- package/dist/prompts/selectors/LengthBasedExampleSelector.js +1 -146
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.cjs +15 -137
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.d.ts +1 -91
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.js +1 -135
- package/dist/prompts/selectors/conditional.cjs +15 -74
- package/dist/prompts/selectors/conditional.d.ts +1 -63
- package/dist/prompts/selectors/conditional.js +1 -69
- package/dist/prompts/serde.cjs +15 -0
- package/dist/prompts/serde.d.ts +1 -43
- package/dist/prompts/serde.js +1 -1
- package/dist/prompts/template.cjs +14 -88
- package/dist/prompts/template.d.ts +1 -36
- package/dist/prompts/template.js +1 -83
- package/dist/retrievers/chaindesk.cjs +9 -1
- package/dist/retrievers/chaindesk.d.ts +3 -1
- package/dist/retrievers/chaindesk.js +9 -1
- package/dist/retrievers/self_query/vectara.cjs +138 -0
- package/dist/retrievers/self_query/vectara.d.ts +41 -0
- package/dist/retrievers/self_query/vectara.js +134 -0
- package/dist/{util/@cfworker/json-schema → runnables}/index.cjs +1 -1
- package/dist/runnables/index.d.ts +1 -0
- package/dist/runnables/index.js +1 -0
- package/dist/schema/document.cjs +3 -34
- package/dist/schema/document.d.ts +2 -29
- package/dist/schema/document.js +2 -32
- package/dist/schema/index.cjs +37 -612
- package/dist/schema/index.d.ts +11 -311
- package/dist/schema/index.js +8 -583
- package/dist/schema/output_parser.cjs +15 -309
- package/dist/schema/output_parser.d.ts +1 -173
- package/dist/schema/output_parser.js +1 -301
- package/dist/schema/retriever.cjs +15 -77
- package/dist/schema/retriever.d.ts +1 -43
- package/dist/schema/retriever.js +1 -75
- package/dist/schema/runnable/base.cjs +10 -1072
- package/dist/schema/runnable/base.d.ts +1 -356
- package/dist/schema/runnable/base.js +1 -1060
- package/dist/schema/runnable/branch.cjs +2 -131
- package/dist/schema/runnable/branch.d.ts +1 -94
- package/dist/schema/runnable/branch.js +1 -130
- package/dist/schema/runnable/config.cjs +0 -6
- package/dist/schema/runnable/config.d.ts +1 -3
- package/dist/schema/runnable/config.js +1 -4
- package/dist/schema/runnable/index.cjs +15 -16
- package/dist/schema/runnable/index.d.ts +1 -5
- package/dist/schema/runnable/index.js +1 -4
- package/dist/schema/runnable/passthrough.cjs +3 -113
- package/dist/schema/runnable/passthrough.d.ts +1 -72
- package/dist/schema/runnable/passthrough.js +1 -111
- package/dist/schema/runnable/router.cjs +2 -71
- package/dist/schema/runnable/router.d.ts +1 -29
- package/dist/schema/runnable/router.js +1 -70
- package/dist/schema/storage.cjs +15 -8
- package/dist/schema/storage.d.ts +1 -57
- package/dist/schema/storage.js +1 -6
- package/dist/tools/bingserpapi.d.ts +1 -1
- package/dist/tools/searchapi.d.ts +1 -1
- package/dist/tools/serpapi.d.ts +1 -1
- package/dist/tools/serper.d.ts +1 -1
- package/dist/util/async_caller.cjs +14 -128
- package/dist/util/async_caller.d.ts +1 -45
- package/dist/util/async_caller.js +1 -124
- package/dist/vectorstores/vectara.cjs +77 -7
- package/dist/vectorstores/vectara.d.ts +9 -3
- package/dist/vectorstores/vectara.js +54 -7
- package/experimental/openai_files.cjs +1 -0
- package/experimental/openai_files.d.ts +1 -0
- package/experimental/openai_files.js +1 -0
- package/package.json +27 -5
- package/retrievers/self_query/vectara.cjs +1 -0
- package/retrievers/self_query/vectara.d.ts +1 -0
- package/retrievers/self_query/vectara.js +1 -0
- package/runnables.cjs +1 -0
- package/runnables.d.ts +1 -0
- package/runnables.js +1 -0
- package/dist/util/@cfworker/json-schema/index.d.ts +0 -1
- package/dist/util/@cfworker/json-schema/index.js +0 -1
- package/dist/util/@cfworker/json-schema/src/deep-compare-strict.cjs +0 -43
- package/dist/util/@cfworker/json-schema/src/deep-compare-strict.d.ts +0 -1
- package/dist/util/@cfworker/json-schema/src/deep-compare-strict.js +0 -39
- package/dist/util/@cfworker/json-schema/src/dereference.cjs +0 -169
- package/dist/util/@cfworker/json-schema/src/dereference.d.ts +0 -12
- package/dist/util/@cfworker/json-schema/src/dereference.js +0 -165
- package/dist/util/@cfworker/json-schema/src/format.cjs +0 -139
- package/dist/util/@cfworker/json-schema/src/format.d.ts +0 -2
- package/dist/util/@cfworker/json-schema/src/format.js +0 -136
- package/dist/util/@cfworker/json-schema/src/index.cjs +0 -24
- package/dist/util/@cfworker/json-schema/src/index.d.ts +0 -8
- package/dist/util/@cfworker/json-schema/src/index.js +0 -8
- package/dist/util/@cfworker/json-schema/src/pointer.cjs +0 -11
- package/dist/util/@cfworker/json-schema/src/pointer.d.ts +0 -2
- package/dist/util/@cfworker/json-schema/src/pointer.js +0 -6
- package/dist/util/@cfworker/json-schema/src/types.cjs +0 -2
- package/dist/util/@cfworker/json-schema/src/types.d.ts +0 -72
- package/dist/util/@cfworker/json-schema/src/types.js +0 -1
- package/dist/util/@cfworker/json-schema/src/ucs2-length.cjs +0 -28
- package/dist/util/@cfworker/json-schema/src/ucs2-length.d.ts +0 -6
- package/dist/util/@cfworker/json-schema/src/ucs2-length.js +0 -24
- package/dist/util/@cfworker/json-schema/src/validate.cjs +0 -808
- package/dist/util/@cfworker/json-schema/src/validate.d.ts +0 -3
- package/dist/util/@cfworker/json-schema/src/validate.js +0 -804
- package/dist/util/@cfworker/json-schema/src/validator.cjs +0 -44
- package/dist/util/@cfworker/json-schema/src/validator.d.ts +0 -10
- package/dist/util/@cfworker/json-schema/src/validator.js +0 -40
- package/dist/util/fast-json-patch/index.cjs +0 -49
- package/dist/util/fast-json-patch/index.d.ts +0 -22
- package/dist/util/fast-json-patch/index.js +0 -16
- package/dist/util/fast-json-patch/src/core.cjs +0 -469
- package/dist/util/fast-json-patch/src/core.d.ts +0 -111
- package/dist/util/fast-json-patch/src/core.js +0 -459
- package/dist/util/fast-json-patch/src/duplex.cjs +0 -237
- package/dist/util/fast-json-patch/src/duplex.d.ts +0 -23
- package/dist/util/fast-json-patch/src/duplex.js +0 -230
- package/dist/util/fast-json-patch/src/helpers.cjs +0 -194
- package/dist/util/fast-json-patch/src/helpers.d.ts +0 -36
- package/dist/util/fast-json-patch/src/helpers.js +0 -181
- package/dist/util/js-sha1/hash.cjs +0 -358
- package/dist/util/js-sha1/hash.d.ts +0 -1
- package/dist/util/js-sha1/hash.js +0 -355
package/dist/load/index.js
CHANGED
|
@@ -1,152 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { load as coreLoad } from "langchain-core/load";
|
|
2
2
|
import { optionalImportEntrypoints } from "./import_constants.js";
|
|
3
3
|
import * as importMap from "./import_map.js";
|
|
4
|
-
import { keyFromJson, mapKeys } from "./map_keys.js";
|
|
5
|
-
import { getEnvironmentVariable } from "../util/env.js";
|
|
6
|
-
function combineAliasesAndInvert(constructor) {
|
|
7
|
-
const aliases = {};
|
|
8
|
-
for (
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
10
|
-
let current = constructor; current && current.prototype; current = Object.getPrototypeOf(current)) {
|
|
11
|
-
Object.assign(aliases, Reflect.get(current.prototype, "lc_aliases"));
|
|
12
|
-
}
|
|
13
|
-
return Object.entries(aliases).reduce((acc, [key, value]) => {
|
|
14
|
-
acc[value] = key;
|
|
15
|
-
return acc;
|
|
16
|
-
}, {});
|
|
17
|
-
}
|
|
18
|
-
async function reviver(value) {
|
|
19
|
-
const { optionalImportsMap, secretsMap, path = ["$"] } = this;
|
|
20
|
-
const pathStr = path.join(".");
|
|
21
|
-
if (typeof value === "object" &&
|
|
22
|
-
value !== null &&
|
|
23
|
-
!Array.isArray(value) &&
|
|
24
|
-
"lc" in value &&
|
|
25
|
-
"type" in value &&
|
|
26
|
-
"id" in value &&
|
|
27
|
-
value.lc === 1 &&
|
|
28
|
-
value.type === "secret") {
|
|
29
|
-
const serialized = value;
|
|
30
|
-
const [key] = serialized.id;
|
|
31
|
-
if (key in secretsMap) {
|
|
32
|
-
return secretsMap[key];
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
const secretValueInEnv = getEnvironmentVariable(key);
|
|
36
|
-
if (secretValueInEnv) {
|
|
37
|
-
return secretValueInEnv;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
throw new Error(`Missing key "${key}" for ${pathStr} in load(secretsMap={})`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else if (typeof value === "object" &&
|
|
45
|
-
value !== null &&
|
|
46
|
-
!Array.isArray(value) &&
|
|
47
|
-
"lc" in value &&
|
|
48
|
-
"type" in value &&
|
|
49
|
-
"id" in value &&
|
|
50
|
-
value.lc === 1 &&
|
|
51
|
-
value.type === "not_implemented") {
|
|
52
|
-
const serialized = value;
|
|
53
|
-
const str = JSON.stringify(serialized);
|
|
54
|
-
throw new Error(`Trying to load an object that doesn't implement serialization: ${pathStr} -> ${str}`);
|
|
55
|
-
}
|
|
56
|
-
else if (typeof value === "object" &&
|
|
57
|
-
value !== null &&
|
|
58
|
-
!Array.isArray(value) &&
|
|
59
|
-
"lc" in value &&
|
|
60
|
-
"type" in value &&
|
|
61
|
-
"id" in value &&
|
|
62
|
-
"kwargs" in value &&
|
|
63
|
-
value.lc === 1) {
|
|
64
|
-
const serialized = value;
|
|
65
|
-
const str = JSON.stringify(serialized);
|
|
66
|
-
const [name, ...namespaceReverse] = serialized.id.slice().reverse();
|
|
67
|
-
const namespace = namespaceReverse.reverse();
|
|
68
|
-
let module;
|
|
69
|
-
if (optionalImportEntrypoints.includes(namespace.join("/")) ||
|
|
70
|
-
namespace.join("/") in optionalImportsMap) {
|
|
71
|
-
if (namespace.join("/") in optionalImportsMap) {
|
|
72
|
-
module = await optionalImportsMap[namespace.join("/")];
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
throw new Error(`Missing key "${namespace.join("/")}" for ${pathStr} in load(optionalImportsMap={})`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
// Currently, we only support langchain imports.
|
|
80
|
-
if (namespace[0] === "langchain") {
|
|
81
|
-
namespace.shift();
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);
|
|
85
|
-
}
|
|
86
|
-
// The root namespace "langchain" is not a valid import.
|
|
87
|
-
if (namespace.length === 0) {
|
|
88
|
-
throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);
|
|
89
|
-
}
|
|
90
|
-
// Find the longest matching namespace.
|
|
91
|
-
let importMapKey;
|
|
92
|
-
do {
|
|
93
|
-
importMapKey = namespace.join("__");
|
|
94
|
-
if (importMapKey in importMap) {
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
namespace.pop();
|
|
99
|
-
}
|
|
100
|
-
} while (namespace.length > 0);
|
|
101
|
-
// If no matching namespace is found, throw an error.
|
|
102
|
-
if (importMapKey in importMap) {
|
|
103
|
-
module = importMap[importMapKey];
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (typeof module !== "object" || module === null) {
|
|
107
|
-
throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);
|
|
108
|
-
}
|
|
109
|
-
// Extract the builder from the import map.
|
|
110
|
-
const builder =
|
|
111
|
-
// look for a named export with the same name as the class
|
|
112
|
-
module[name] ??
|
|
113
|
-
// look for an export with a lc_name property matching the class name
|
|
114
|
-
// this is necessary for classes that are minified
|
|
115
|
-
Object.values(module).find((v) => typeof v === "function" &&
|
|
116
|
-
get_lc_unique_name(v) === name);
|
|
117
|
-
if (typeof builder !== "function") {
|
|
118
|
-
throw new Error(`Invalid identifer: ${pathStr} -> ${str}`);
|
|
119
|
-
}
|
|
120
|
-
// Recurse on the arguments, which may be serialized objects themselves
|
|
121
|
-
const kwargs = await reviver.call({ ...this, path: [...path, "kwargs"] }, serialized.kwargs);
|
|
122
|
-
// Construct the object
|
|
123
|
-
if (serialized.type === "constructor") {
|
|
124
|
-
// eslint-disable-next-line new-cap, @typescript-eslint/no-explicit-any
|
|
125
|
-
const instance = new builder(mapKeys(kwargs, keyFromJson, combineAliasesAndInvert(builder)));
|
|
126
|
-
// Minification in severless/edge runtimes will mange the
|
|
127
|
-
// name of classes presented in traces. As the names in import map
|
|
128
|
-
// are present as-is even with minification, use these names instead
|
|
129
|
-
Object.defineProperty(instance.constructor, "name", { value: name });
|
|
130
|
-
return instance;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
throw new Error(`Invalid type: ${pathStr} -> ${str}`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else if (typeof value === "object" && value !== null) {
|
|
137
|
-
if (Array.isArray(value)) {
|
|
138
|
-
return Promise.all(value.map((v, i) => reviver.call({ ...this, path: [...path, `${i}`] }, v)));
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
return Object.fromEntries(await Promise.all(Object.entries(value).map(async ([key, value]) => [
|
|
142
|
-
key,
|
|
143
|
-
await reviver.call({ ...this, path: [...path, key] }, value),
|
|
144
|
-
])));
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return value;
|
|
148
|
-
}
|
|
149
4
|
export async function load(text, secretsMap = {}, optionalImportsMap = {}) {
|
|
150
|
-
|
|
151
|
-
|
|
5
|
+
return coreLoad(text, {
|
|
6
|
+
secretsMap,
|
|
7
|
+
optionalImportsMap,
|
|
8
|
+
optionalImportEntrypoints,
|
|
9
|
+
importMap,
|
|
10
|
+
});
|
|
152
11
|
}
|
package/dist/load/map_keys.cjs
CHANGED
|
@@ -1,26 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.mapKeys = exports.keyFromJson = exports.keyToJson = void 0;
|
|
7
|
-
const decamelize_1 = __importDefault(require("decamelize"));
|
|
8
|
-
const camelcase_1 = __importDefault(require("camelcase"));
|
|
9
|
-
function keyToJson(key, map) {
|
|
10
|
-
return map?.[key] || (0, decamelize_1.default)(key);
|
|
11
|
-
}
|
|
12
|
-
exports.keyToJson = keyToJson;
|
|
13
|
-
function keyFromJson(key, map) {
|
|
14
|
-
return map?.[key] || (0, camelcase_1.default)(key);
|
|
15
|
-
}
|
|
16
|
-
exports.keyFromJson = keyFromJson;
|
|
17
|
-
function mapKeys(fields, mapper, map) {
|
|
18
|
-
const mapped = {};
|
|
19
|
-
for (const key in fields) {
|
|
20
|
-
if (Object.hasOwn(fields, key)) {
|
|
21
|
-
mapped[mapper(key, map)] = fields[key];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return mapped;
|
|
25
|
-
}
|
|
26
|
-
exports.mapKeys = mapKeys;
|
package/dist/load/map_keys.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
export interface SerializedFields {
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
}
|
|
4
|
-
export interface SerializedKeyAlias {
|
|
5
|
-
[key: string]: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function keyToJson(key: string, map?: SerializedKeyAlias): string;
|
|
8
|
-
export declare function keyFromJson(key: string, map?: SerializedKeyAlias): string;
|
|
9
|
-
export declare function mapKeys(fields: SerializedFields, mapper: typeof keyToJson, map?: SerializedKeyAlias): SerializedFields;
|
package/dist/load/map_keys.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import camelCase from "camelcase";
|
|
3
|
-
export function keyToJson(key, map) {
|
|
4
|
-
return map?.[key] || snakeCase(key);
|
|
5
|
-
}
|
|
6
|
-
export function keyFromJson(key, map) {
|
|
7
|
-
return map?.[key] || camelCase(key);
|
|
8
|
-
}
|
|
9
|
-
export function mapKeys(fields, mapper, map) {
|
|
10
|
-
const mapped = {};
|
|
11
|
-
for (const key in fields) {
|
|
12
|
-
if (Object.hasOwn(fields, key)) {
|
|
13
|
-
mapped[mapper(key, map)] = fields[key];
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return mapped;
|
|
17
|
-
}
|
|
1
|
+
export {};
|
|
@@ -1,180 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const map_keys_js_1 = require("./map_keys.cjs");
|
|
5
|
-
function shallowCopy(obj) {
|
|
6
|
-
return Array.isArray(obj) ? [...obj] : { ...obj };
|
|
7
|
-
}
|
|
8
|
-
function replaceSecrets(root, secretsMap) {
|
|
9
|
-
const result = shallowCopy(root);
|
|
10
|
-
for (const [path, secretId] of Object.entries(secretsMap)) {
|
|
11
|
-
const [last, ...partsReverse] = path.split(".").reverse();
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
let current = result;
|
|
14
|
-
for (const part of partsReverse.reverse()) {
|
|
15
|
-
if (current[part] === undefined) {
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
current[part] = shallowCopy(current[part]);
|
|
19
|
-
current = current[part];
|
|
20
|
-
}
|
|
21
|
-
if (current[last] !== undefined) {
|
|
22
|
-
current[last] = {
|
|
23
|
-
lc: 1,
|
|
24
|
-
type: "secret",
|
|
25
|
-
id: [secretId],
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Get a unique name for the module, rather than parent class implementations.
|
|
33
|
-
* Should not be subclassed, subclass lc_name above instead.
|
|
34
|
-
*/
|
|
35
|
-
function get_lc_unique_name(
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
37
|
-
serializableClass) {
|
|
38
|
-
// "super" here would refer to the parent class of Serializable,
|
|
39
|
-
// when we want the parent class of the module actually calling this method.
|
|
40
|
-
const parentClass = Object.getPrototypeOf(serializableClass);
|
|
41
|
-
const lcNameIsSubclassed = typeof serializableClass.lc_name === "function" &&
|
|
42
|
-
(typeof parentClass.lc_name !== "function" ||
|
|
43
|
-
serializableClass.lc_name() !== parentClass.lc_name());
|
|
44
|
-
if (lcNameIsSubclassed) {
|
|
45
|
-
return serializableClass.lc_name();
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
return serializableClass.name;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.get_lc_unique_name = get_lc_unique_name;
|
|
52
|
-
class Serializable {
|
|
53
|
-
/**
|
|
54
|
-
* The name of the serializable. Override to provide an alias or
|
|
55
|
-
* to preserve the serialized module name in minified environments.
|
|
56
|
-
*
|
|
57
|
-
* Implemented as a static method to support loading logic.
|
|
58
|
-
*/
|
|
59
|
-
static lc_name() {
|
|
60
|
-
return this.name;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* The final serialized identifier for the module.
|
|
64
|
-
*/
|
|
65
|
-
get lc_id() {
|
|
66
|
-
return [
|
|
67
|
-
...this.lc_namespace,
|
|
68
|
-
get_lc_unique_name(this.constructor),
|
|
69
|
-
];
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* A map of secrets, which will be omitted from serialization.
|
|
73
|
-
* Keys are paths to the secret in constructor args, e.g. "foo.bar.baz".
|
|
74
|
-
* Values are the secret ids, which will be used when deserializing.
|
|
75
|
-
*/
|
|
76
|
-
get lc_secrets() {
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* A map of additional attributes to merge with constructor args.
|
|
81
|
-
* Keys are the attribute names, e.g. "foo".
|
|
82
|
-
* Values are the attribute values, which will be serialized.
|
|
83
|
-
* These attributes need to be accepted by the constructor as arguments.
|
|
84
|
-
*/
|
|
85
|
-
get lc_attributes() {
|
|
86
|
-
return undefined;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* A map of aliases for constructor args.
|
|
90
|
-
* Keys are the attribute names, e.g. "foo".
|
|
91
|
-
* Values are the alias that will replace the key in serialization.
|
|
92
|
-
* This is used to eg. make argument names match Python.
|
|
93
|
-
*/
|
|
94
|
-
get lc_aliases() {
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
97
|
-
constructor(kwargs, ..._args) {
|
|
98
|
-
Object.defineProperty(this, "lc_serializable", {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
configurable: true,
|
|
101
|
-
writable: true,
|
|
102
|
-
value: false
|
|
103
|
-
});
|
|
104
|
-
Object.defineProperty(this, "lc_kwargs", {
|
|
105
|
-
enumerable: true,
|
|
106
|
-
configurable: true,
|
|
107
|
-
writable: true,
|
|
108
|
-
value: void 0
|
|
109
|
-
});
|
|
110
|
-
this.lc_kwargs = kwargs || {};
|
|
111
|
-
}
|
|
112
|
-
toJSON() {
|
|
113
|
-
if (!this.lc_serializable) {
|
|
114
|
-
return this.toJSONNotImplemented();
|
|
115
|
-
}
|
|
116
|
-
if (
|
|
117
|
-
// eslint-disable-next-line no-instanceof/no-instanceof
|
|
118
|
-
this.lc_kwargs instanceof Serializable ||
|
|
119
|
-
typeof this.lc_kwargs !== "object" ||
|
|
120
|
-
Array.isArray(this.lc_kwargs)) {
|
|
121
|
-
// We do not support serialization of classes with arg not a POJO
|
|
122
|
-
// I'm aware the check above isn't as strict as it could be
|
|
123
|
-
return this.toJSONNotImplemented();
|
|
124
|
-
}
|
|
125
|
-
const aliases = {};
|
|
126
|
-
const secrets = {};
|
|
127
|
-
const kwargs = Object.keys(this.lc_kwargs).reduce((acc, key) => {
|
|
128
|
-
acc[key] = key in this ? this[key] : this.lc_kwargs[key];
|
|
129
|
-
return acc;
|
|
130
|
-
}, {});
|
|
131
|
-
// get secrets, attributes and aliases from all superclasses
|
|
132
|
-
for (
|
|
133
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
134
|
-
let current = Object.getPrototypeOf(this); current; current = Object.getPrototypeOf(current)) {
|
|
135
|
-
Object.assign(aliases, Reflect.get(current, "lc_aliases", this));
|
|
136
|
-
Object.assign(secrets, Reflect.get(current, "lc_secrets", this));
|
|
137
|
-
Object.assign(kwargs, Reflect.get(current, "lc_attributes", this));
|
|
138
|
-
}
|
|
139
|
-
// include all secrets used, even if not in kwargs,
|
|
140
|
-
// will be replaced with sentinel value in replaceSecrets
|
|
141
|
-
Object.keys(secrets).forEach((keyPath) => {
|
|
142
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias, @typescript-eslint/no-explicit-any
|
|
143
|
-
let read = this;
|
|
144
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
145
|
-
let write = kwargs;
|
|
146
|
-
const [last, ...partsReverse] = keyPath.split(".").reverse();
|
|
147
|
-
for (const key of partsReverse.reverse()) {
|
|
148
|
-
if (!(key in read) || read[key] === undefined)
|
|
149
|
-
return;
|
|
150
|
-
if (!(key in write) || write[key] === undefined) {
|
|
151
|
-
if (typeof read[key] === "object" && read[key] != null) {
|
|
152
|
-
write[key] = {};
|
|
153
|
-
}
|
|
154
|
-
else if (Array.isArray(read[key])) {
|
|
155
|
-
write[key] = [];
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
read = read[key];
|
|
159
|
-
write = write[key];
|
|
160
|
-
}
|
|
161
|
-
if (last in read && read[last] !== undefined) {
|
|
162
|
-
write[last] = write[last] || read[last];
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
return {
|
|
166
|
-
lc: 1,
|
|
167
|
-
type: "constructor",
|
|
168
|
-
id: this.lc_id,
|
|
169
|
-
kwargs: (0, map_keys_js_1.mapKeys)(Object.keys(secrets).length ? replaceSecrets(kwargs, secrets) : kwargs, map_keys_js_1.keyToJson, aliases),
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
toJSONNotImplemented() {
|
|
173
|
-
return {
|
|
174
|
-
lc: 1,
|
|
175
|
-
type: "not_implemented",
|
|
176
|
-
id: this.lc_id,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
exports.Serializable = Serializable;
|
|
17
|
+
__exportStar(require("langchain-core/load/serializable"), exports);
|
|
@@ -1,66 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export interface BaseSerialized<T extends string> {
|
|
3
|
-
lc: number;
|
|
4
|
-
type: T;
|
|
5
|
-
id: string[];
|
|
6
|
-
}
|
|
7
|
-
export interface SerializedConstructor extends BaseSerialized<"constructor"> {
|
|
8
|
-
kwargs: SerializedFields;
|
|
9
|
-
}
|
|
10
|
-
export interface SerializedSecret extends BaseSerialized<"secret"> {
|
|
11
|
-
}
|
|
12
|
-
export interface SerializedNotImplemented extends BaseSerialized<"not_implemented"> {
|
|
13
|
-
}
|
|
14
|
-
export type Serialized = SerializedConstructor | SerializedSecret | SerializedNotImplemented;
|
|
15
|
-
/**
|
|
16
|
-
* Get a unique name for the module, rather than parent class implementations.
|
|
17
|
-
* Should not be subclassed, subclass lc_name above instead.
|
|
18
|
-
*/
|
|
19
|
-
export declare function get_lc_unique_name(serializableClass: typeof Serializable): string;
|
|
20
|
-
export declare abstract class Serializable {
|
|
21
|
-
lc_serializable: boolean;
|
|
22
|
-
lc_kwargs: SerializedFields;
|
|
23
|
-
/**
|
|
24
|
-
* A path to the module that contains the class, eg. ["langchain", "llms"]
|
|
25
|
-
* Usually should be the same as the entrypoint the class is exported from.
|
|
26
|
-
*/
|
|
27
|
-
abstract lc_namespace: string[];
|
|
28
|
-
/**
|
|
29
|
-
* The name of the serializable. Override to provide an alias or
|
|
30
|
-
* to preserve the serialized module name in minified environments.
|
|
31
|
-
*
|
|
32
|
-
* Implemented as a static method to support loading logic.
|
|
33
|
-
*/
|
|
34
|
-
static lc_name(): string;
|
|
35
|
-
/**
|
|
36
|
-
* The final serialized identifier for the module.
|
|
37
|
-
*/
|
|
38
|
-
get lc_id(): string[];
|
|
39
|
-
/**
|
|
40
|
-
* A map of secrets, which will be omitted from serialization.
|
|
41
|
-
* Keys are paths to the secret in constructor args, e.g. "foo.bar.baz".
|
|
42
|
-
* Values are the secret ids, which will be used when deserializing.
|
|
43
|
-
*/
|
|
44
|
-
get lc_secrets(): {
|
|
45
|
-
[key: string]: string;
|
|
46
|
-
} | undefined;
|
|
47
|
-
/**
|
|
48
|
-
* A map of additional attributes to merge with constructor args.
|
|
49
|
-
* Keys are the attribute names, e.g. "foo".
|
|
50
|
-
* Values are the attribute values, which will be serialized.
|
|
51
|
-
* These attributes need to be accepted by the constructor as arguments.
|
|
52
|
-
*/
|
|
53
|
-
get lc_attributes(): SerializedFields | undefined;
|
|
54
|
-
/**
|
|
55
|
-
* A map of aliases for constructor args.
|
|
56
|
-
* Keys are the attribute names, e.g. "foo".
|
|
57
|
-
* Values are the alias that will replace the key in serialization.
|
|
58
|
-
* This is used to eg. make argument names match Python.
|
|
59
|
-
*/
|
|
60
|
-
get lc_aliases(): {
|
|
61
|
-
[key: string]: string;
|
|
62
|
-
} | undefined;
|
|
63
|
-
constructor(kwargs?: SerializedFields, ..._args: never[]);
|
|
64
|
-
toJSON(): Serialized;
|
|
65
|
-
toJSONNotImplemented(): SerializedNotImplemented;
|
|
66
|
-
}
|
|
1
|
+
export * from "langchain-core/load/serializable";
|
|
@@ -1,175 +1 @@
|
|
|
1
|
-
|
|
2
|
-
function shallowCopy(obj) {
|
|
3
|
-
return Array.isArray(obj) ? [...obj] : { ...obj };
|
|
4
|
-
}
|
|
5
|
-
function replaceSecrets(root, secretsMap) {
|
|
6
|
-
const result = shallowCopy(root);
|
|
7
|
-
for (const [path, secretId] of Object.entries(secretsMap)) {
|
|
8
|
-
const [last, ...partsReverse] = path.split(".").reverse();
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
-
let current = result;
|
|
11
|
-
for (const part of partsReverse.reverse()) {
|
|
12
|
-
if (current[part] === undefined) {
|
|
13
|
-
break;
|
|
14
|
-
}
|
|
15
|
-
current[part] = shallowCopy(current[part]);
|
|
16
|
-
current = current[part];
|
|
17
|
-
}
|
|
18
|
-
if (current[last] !== undefined) {
|
|
19
|
-
current[last] = {
|
|
20
|
-
lc: 1,
|
|
21
|
-
type: "secret",
|
|
22
|
-
id: [secretId],
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Get a unique name for the module, rather than parent class implementations.
|
|
30
|
-
* Should not be subclassed, subclass lc_name above instead.
|
|
31
|
-
*/
|
|
32
|
-
export function get_lc_unique_name(
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
34
|
-
serializableClass) {
|
|
35
|
-
// "super" here would refer to the parent class of Serializable,
|
|
36
|
-
// when we want the parent class of the module actually calling this method.
|
|
37
|
-
const parentClass = Object.getPrototypeOf(serializableClass);
|
|
38
|
-
const lcNameIsSubclassed = typeof serializableClass.lc_name === "function" &&
|
|
39
|
-
(typeof parentClass.lc_name !== "function" ||
|
|
40
|
-
serializableClass.lc_name() !== parentClass.lc_name());
|
|
41
|
-
if (lcNameIsSubclassed) {
|
|
42
|
-
return serializableClass.lc_name();
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
return serializableClass.name;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
export class Serializable {
|
|
49
|
-
/**
|
|
50
|
-
* The name of the serializable. Override to provide an alias or
|
|
51
|
-
* to preserve the serialized module name in minified environments.
|
|
52
|
-
*
|
|
53
|
-
* Implemented as a static method to support loading logic.
|
|
54
|
-
*/
|
|
55
|
-
static lc_name() {
|
|
56
|
-
return this.name;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* The final serialized identifier for the module.
|
|
60
|
-
*/
|
|
61
|
-
get lc_id() {
|
|
62
|
-
return [
|
|
63
|
-
...this.lc_namespace,
|
|
64
|
-
get_lc_unique_name(this.constructor),
|
|
65
|
-
];
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* A map of secrets, which will be omitted from serialization.
|
|
69
|
-
* Keys are paths to the secret in constructor args, e.g. "foo.bar.baz".
|
|
70
|
-
* Values are the secret ids, which will be used when deserializing.
|
|
71
|
-
*/
|
|
72
|
-
get lc_secrets() {
|
|
73
|
-
return undefined;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* A map of additional attributes to merge with constructor args.
|
|
77
|
-
* Keys are the attribute names, e.g. "foo".
|
|
78
|
-
* Values are the attribute values, which will be serialized.
|
|
79
|
-
* These attributes need to be accepted by the constructor as arguments.
|
|
80
|
-
*/
|
|
81
|
-
get lc_attributes() {
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* A map of aliases for constructor args.
|
|
86
|
-
* Keys are the attribute names, e.g. "foo".
|
|
87
|
-
* Values are the alias that will replace the key in serialization.
|
|
88
|
-
* This is used to eg. make argument names match Python.
|
|
89
|
-
*/
|
|
90
|
-
get lc_aliases() {
|
|
91
|
-
return undefined;
|
|
92
|
-
}
|
|
93
|
-
constructor(kwargs, ..._args) {
|
|
94
|
-
Object.defineProperty(this, "lc_serializable", {
|
|
95
|
-
enumerable: true,
|
|
96
|
-
configurable: true,
|
|
97
|
-
writable: true,
|
|
98
|
-
value: false
|
|
99
|
-
});
|
|
100
|
-
Object.defineProperty(this, "lc_kwargs", {
|
|
101
|
-
enumerable: true,
|
|
102
|
-
configurable: true,
|
|
103
|
-
writable: true,
|
|
104
|
-
value: void 0
|
|
105
|
-
});
|
|
106
|
-
this.lc_kwargs = kwargs || {};
|
|
107
|
-
}
|
|
108
|
-
toJSON() {
|
|
109
|
-
if (!this.lc_serializable) {
|
|
110
|
-
return this.toJSONNotImplemented();
|
|
111
|
-
}
|
|
112
|
-
if (
|
|
113
|
-
// eslint-disable-next-line no-instanceof/no-instanceof
|
|
114
|
-
this.lc_kwargs instanceof Serializable ||
|
|
115
|
-
typeof this.lc_kwargs !== "object" ||
|
|
116
|
-
Array.isArray(this.lc_kwargs)) {
|
|
117
|
-
// We do not support serialization of classes with arg not a POJO
|
|
118
|
-
// I'm aware the check above isn't as strict as it could be
|
|
119
|
-
return this.toJSONNotImplemented();
|
|
120
|
-
}
|
|
121
|
-
const aliases = {};
|
|
122
|
-
const secrets = {};
|
|
123
|
-
const kwargs = Object.keys(this.lc_kwargs).reduce((acc, key) => {
|
|
124
|
-
acc[key] = key in this ? this[key] : this.lc_kwargs[key];
|
|
125
|
-
return acc;
|
|
126
|
-
}, {});
|
|
127
|
-
// get secrets, attributes and aliases from all superclasses
|
|
128
|
-
for (
|
|
129
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
130
|
-
let current = Object.getPrototypeOf(this); current; current = Object.getPrototypeOf(current)) {
|
|
131
|
-
Object.assign(aliases, Reflect.get(current, "lc_aliases", this));
|
|
132
|
-
Object.assign(secrets, Reflect.get(current, "lc_secrets", this));
|
|
133
|
-
Object.assign(kwargs, Reflect.get(current, "lc_attributes", this));
|
|
134
|
-
}
|
|
135
|
-
// include all secrets used, even if not in kwargs,
|
|
136
|
-
// will be replaced with sentinel value in replaceSecrets
|
|
137
|
-
Object.keys(secrets).forEach((keyPath) => {
|
|
138
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias, @typescript-eslint/no-explicit-any
|
|
139
|
-
let read = this;
|
|
140
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
141
|
-
let write = kwargs;
|
|
142
|
-
const [last, ...partsReverse] = keyPath.split(".").reverse();
|
|
143
|
-
for (const key of partsReverse.reverse()) {
|
|
144
|
-
if (!(key in read) || read[key] === undefined)
|
|
145
|
-
return;
|
|
146
|
-
if (!(key in write) || write[key] === undefined) {
|
|
147
|
-
if (typeof read[key] === "object" && read[key] != null) {
|
|
148
|
-
write[key] = {};
|
|
149
|
-
}
|
|
150
|
-
else if (Array.isArray(read[key])) {
|
|
151
|
-
write[key] = [];
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
read = read[key];
|
|
155
|
-
write = write[key];
|
|
156
|
-
}
|
|
157
|
-
if (last in read && read[last] !== undefined) {
|
|
158
|
-
write[last] = write[last] || read[last];
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
return {
|
|
162
|
-
lc: 1,
|
|
163
|
-
type: "constructor",
|
|
164
|
-
id: this.lc_id,
|
|
165
|
-
kwargs: mapKeys(Object.keys(secrets).length ? replaceSecrets(kwargs, secrets) : kwargs, keyToJson, aliases),
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
toJSONNotImplemented() {
|
|
169
|
-
return {
|
|
170
|
-
lc: 1,
|
|
171
|
-
type: "not_implemented",
|
|
172
|
-
id: this.lc_id,
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
}
|
|
1
|
+
export * from "langchain-core/load/serializable";
|