langchain 0.0.195 → 0.0.197-rc.0
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/LICENSE +21 -0
- package/dist/agents/openai/index.cjs +6 -2
- package/dist/agents/openai/index.js +6 -2
- 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/anthropic.cjs +15 -348
- package/dist/chat_models/anthropic.d.ts +1 -156
- package/dist/chat_models/anthropic.js +1 -346
- 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.cjs +21 -1
- package/dist/chat_models/bedrock/web.d.ts +2 -2
- package/dist/chat_models/bedrock/web.js +21 -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/github.cjs +105 -0
- package/dist/document_loaders/web/github.d.ts +26 -0
- package/dist/document_loaders/web/github.js +105 -0
- 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/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/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.cjs +21 -1
- package/dist/llms/bedrock/web.d.ts +2 -2
- package/dist/llms/bedrock/web.js +21 -1
- package/dist/llms/fireworks.d.ts +1 -1
- package/dist/load/import_map.cjs +2 -1
- package/dist/load/import_map.d.ts +1 -0
- package/dist/load/import_map.js +1 -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/list.cjs +4 -122
- package/dist/output_parsers/list.d.ts +1 -57
- package/dist/output_parsers/list.js +1 -119
- 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 +13 -477
- package/dist/prompts/chat.d.ts +2 -219
- package/dist/prompts/chat.js +2 -466
- package/dist/prompts/few_shot.cjs +3 -352
- 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 +2 -141
- package/dist/prompts/pipeline.d.ts +1 -98
- package/dist/prompts/pipeline.js +1 -140
- package/dist/prompts/prompt.cjs +2 -145
- package/dist/prompts/prompt.d.ts +1 -92
- package/dist/prompts/prompt.js +1 -144
- package/dist/prompts/selectors/LengthBasedExampleSelector.cjs +2 -147
- 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 +5 -73
- package/dist/prompts/selectors/conditional.d.ts +1 -63
- package/dist/prompts/selectors/conditional.js +1 -69
- package/dist/prompts/serde.d.ts +1 -43
- package/dist/prompts/template.cjs +8 -88
- package/dist/prompts/template.d.ts +1 -36
- package/dist/prompts/template.js +1 -83
- 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/momento_vector_index.cjs +39 -0
- package/dist/vectorstores/momento_vector_index.d.ts +17 -1
- package/dist/vectorstores/momento_vector_index.js +40 -1
- package/dist/vectorstores/mongodb_atlas.cjs +22 -2
- package/dist/vectorstores/mongodb_atlas.d.ts +13 -0
- package/dist/vectorstores/mongodb_atlas.js +22 -2
- package/package.json +18 -11
- 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
|
@@ -216,6 +216,22 @@ class GithubRepoLoader extends base_js_1.BaseDocumentLoader {
|
|
|
216
216
|
}
|
|
217
217
|
return documents;
|
|
218
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Asynchronously streams documents from the entire GitHub repository.
|
|
221
|
+
* It is suitable for situations where processing large repositories in a memory-efficient manner is required.
|
|
222
|
+
* @yields Yields a Promise that resolves to a Document object for each file or submodule content found in the repository.
|
|
223
|
+
*/
|
|
224
|
+
async *loadAsStream() {
|
|
225
|
+
this.log(`Loading documents from ${this.baseUrl}/${this.owner}/${this.repo}/${this.initialPath}...`);
|
|
226
|
+
yield* await this.processRepoAsStream(this.initialPath);
|
|
227
|
+
if (!this.processSubmodules) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
await this.getSubmoduleInfo();
|
|
231
|
+
for (const submoduleInfo of this.submoduleInfos) {
|
|
232
|
+
yield* await this.loadSubmoduleAsStream(submoduleInfo);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
219
235
|
/**
|
|
220
236
|
* Loads the information about Git submodules from the repository, if available.
|
|
221
237
|
*/
|
|
@@ -323,6 +339,37 @@ class GithubRepoLoader extends base_js_1.BaseDocumentLoader {
|
|
|
323
339
|
}).load();
|
|
324
340
|
}
|
|
325
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Asynchronously processes and streams the contents of a specified submodule in the GitHub repository.
|
|
344
|
+
* @param submoduleInfo the info about the submodule to be loaded
|
|
345
|
+
* @yields Yields a Promise that resolves to a Document object for each file found in the submodule.
|
|
346
|
+
*/
|
|
347
|
+
async *loadSubmoduleAsStream(submoduleInfo) {
|
|
348
|
+
if (!submoduleInfo.url.startsWith(this.baseUrl)) {
|
|
349
|
+
this.log(`Ignoring external submodule ${submoduleInfo.url}.`);
|
|
350
|
+
yield* [];
|
|
351
|
+
}
|
|
352
|
+
if (!submoduleInfo.path.startsWith(this.initialPath)) {
|
|
353
|
+
this.log(`Ignoring submodule ${submoduleInfo.url}, as it is not on initial path.`);
|
|
354
|
+
yield* [];
|
|
355
|
+
}
|
|
356
|
+
this.log(`Accessing submodule ${submoduleInfo.name} (${submoduleInfo.url})...`);
|
|
357
|
+
const submoduleLoader = new GithubRepoLoader(submoduleInfo.url, {
|
|
358
|
+
accessToken: this.accessToken,
|
|
359
|
+
baseUrl: this.baseUrl,
|
|
360
|
+
apiUrl: this.apiUrl,
|
|
361
|
+
branch: submoduleInfo.ref,
|
|
362
|
+
recursive: this.recursive,
|
|
363
|
+
processSubmodules: this.processSubmodules,
|
|
364
|
+
unknown: this.unknown,
|
|
365
|
+
ignoreFiles: this.ignoreFiles,
|
|
366
|
+
ignorePaths: this.ignorePaths,
|
|
367
|
+
verbose: this.verbose,
|
|
368
|
+
maxConcurrency: this.maxConcurrency,
|
|
369
|
+
maxRetries: this.maxRetries,
|
|
370
|
+
});
|
|
371
|
+
yield* await submoduleLoader.processRepoAsStream(submoduleInfo.path);
|
|
372
|
+
}
|
|
326
373
|
/**
|
|
327
374
|
* Determines whether a file or directory should be ignored based on its
|
|
328
375
|
* path and type.
|
|
@@ -414,6 +461,35 @@ class GithubRepoLoader extends base_js_1.BaseDocumentLoader {
|
|
|
414
461
|
return Promise.reject(error);
|
|
415
462
|
}
|
|
416
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* Asynchronously processes the contents of the entire GitHub repository,
|
|
466
|
+
* streaming each file as a Document object.
|
|
467
|
+
* @param path The path of the directory to process.
|
|
468
|
+
* @yields Yields a Promise that resolves to a Document object for each file found in the repository.
|
|
469
|
+
*/
|
|
470
|
+
async *processRepoAsStream(path) {
|
|
471
|
+
const files = await this.fetchRepoFiles(path);
|
|
472
|
+
for (const file of files) {
|
|
473
|
+
if (this.shouldIgnore(file.path, file.type)) {
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
if (file.type === "file") {
|
|
477
|
+
try {
|
|
478
|
+
const fileResponse = await this.fetchFileContentWrapper(file);
|
|
479
|
+
yield new document_js_1.Document({
|
|
480
|
+
pageContent: fileResponse.contents,
|
|
481
|
+
metadata: fileResponse.metadata,
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
catch (error) {
|
|
485
|
+
this.handleError(`Failed to fetch file content: ${file.path}, ${error}`);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
else if (this.recursive) {
|
|
489
|
+
yield* await this.processDirectoryAsStream(file.path);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
417
493
|
/**
|
|
418
494
|
* Fetches the contents of a directory and maps the file / directory paths
|
|
419
495
|
* to promises that will fetch the file / directory contents.
|
|
@@ -430,6 +506,35 @@ class GithubRepoLoader extends base_js_1.BaseDocumentLoader {
|
|
|
430
506
|
return Promise.reject(error);
|
|
431
507
|
}
|
|
432
508
|
}
|
|
509
|
+
/**
|
|
510
|
+
* Asynchronously processes the contents of a given directory in the GitHub repository,
|
|
511
|
+
* streaming each file as a Document object.
|
|
512
|
+
* @param path The path of the directory to process.
|
|
513
|
+
* @yields Yields a Promise that resolves to a Document object for each file in the directory.
|
|
514
|
+
*/
|
|
515
|
+
async *processDirectoryAsStream(path) {
|
|
516
|
+
const files = await this.fetchRepoFiles(path);
|
|
517
|
+
for (const file of files) {
|
|
518
|
+
if (this.shouldIgnore(file.path, file.type)) {
|
|
519
|
+
continue;
|
|
520
|
+
}
|
|
521
|
+
if (file.type === "file") {
|
|
522
|
+
try {
|
|
523
|
+
const fileResponse = await this.fetchFileContentWrapper(file);
|
|
524
|
+
yield new document_js_1.Document({
|
|
525
|
+
pageContent: fileResponse.contents,
|
|
526
|
+
metadata: fileResponse.metadata,
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
catch {
|
|
530
|
+
this.handleError(`Failed to fetch file content: ${file.path}`);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
else if (this.recursive) {
|
|
534
|
+
yield* await this.processDirectoryAsStream(file.path);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
433
538
|
/**
|
|
434
539
|
* Fetches the files from a GitHub repository.
|
|
435
540
|
* If the path denotes a single file, the resulting array contains only one element.
|
|
@@ -99,6 +99,12 @@ export declare class GithubRepoLoader extends BaseDocumentLoader implements Gith
|
|
|
99
99
|
* @returns A promise that resolves to an array of Document instances.
|
|
100
100
|
*/
|
|
101
101
|
load(): Promise<Document[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Asynchronously streams documents from the entire GitHub repository.
|
|
104
|
+
* It is suitable for situations where processing large repositories in a memory-efficient manner is required.
|
|
105
|
+
* @yields Yields a Promise that resolves to a Document object for each file or submodule content found in the repository.
|
|
106
|
+
*/
|
|
107
|
+
loadAsStream(): AsyncGenerator<Document, void, undefined>;
|
|
102
108
|
/**
|
|
103
109
|
* Loads the information about Git submodules from the repository, if available.
|
|
104
110
|
*/
|
|
@@ -115,6 +121,12 @@ export declare class GithubRepoLoader extends BaseDocumentLoader implements Gith
|
|
|
115
121
|
* @param submoduleInfo the info about the submodule to be loaded
|
|
116
122
|
*/
|
|
117
123
|
private loadSubmodule;
|
|
124
|
+
/**
|
|
125
|
+
* Asynchronously processes and streams the contents of a specified submodule in the GitHub repository.
|
|
126
|
+
* @param submoduleInfo the info about the submodule to be loaded
|
|
127
|
+
* @yields Yields a Promise that resolves to a Document object for each file found in the submodule.
|
|
128
|
+
*/
|
|
129
|
+
private loadSubmoduleAsStream;
|
|
118
130
|
/**
|
|
119
131
|
* Determines whether a file or directory should be ignored based on its
|
|
120
132
|
* path and type.
|
|
@@ -137,6 +149,13 @@ export declare class GithubRepoLoader extends BaseDocumentLoader implements Gith
|
|
|
137
149
|
* Begins the process of fetching the contents of the repository
|
|
138
150
|
*/
|
|
139
151
|
private processRepo;
|
|
152
|
+
/**
|
|
153
|
+
* Asynchronously processes the contents of the entire GitHub repository,
|
|
154
|
+
* streaming each file as a Document object.
|
|
155
|
+
* @param path The path of the directory to process.
|
|
156
|
+
* @yields Yields a Promise that resolves to a Document object for each file found in the repository.
|
|
157
|
+
*/
|
|
158
|
+
private processRepoAsStream;
|
|
140
159
|
/**
|
|
141
160
|
* Fetches the contents of a directory and maps the file / directory paths
|
|
142
161
|
* to promises that will fetch the file / directory contents.
|
|
@@ -144,6 +163,13 @@ export declare class GithubRepoLoader extends BaseDocumentLoader implements Gith
|
|
|
144
163
|
* @returns A promise that resolves to an array of promises that will fetch the file / directory contents.
|
|
145
164
|
*/
|
|
146
165
|
private processDirectory;
|
|
166
|
+
/**
|
|
167
|
+
* Asynchronously processes the contents of a given directory in the GitHub repository,
|
|
168
|
+
* streaming each file as a Document object.
|
|
169
|
+
* @param path The path of the directory to process.
|
|
170
|
+
* @yields Yields a Promise that resolves to a Document object for each file in the directory.
|
|
171
|
+
*/
|
|
172
|
+
private processDirectoryAsStream;
|
|
147
173
|
/**
|
|
148
174
|
* Fetches the files from a GitHub repository.
|
|
149
175
|
* If the path denotes a single file, the resulting array contains only one element.
|
|
@@ -210,6 +210,22 @@ export class GithubRepoLoader extends BaseDocumentLoader {
|
|
|
210
210
|
}
|
|
211
211
|
return documents;
|
|
212
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Asynchronously streams documents from the entire GitHub repository.
|
|
215
|
+
* It is suitable for situations where processing large repositories in a memory-efficient manner is required.
|
|
216
|
+
* @yields Yields a Promise that resolves to a Document object for each file or submodule content found in the repository.
|
|
217
|
+
*/
|
|
218
|
+
async *loadAsStream() {
|
|
219
|
+
this.log(`Loading documents from ${this.baseUrl}/${this.owner}/${this.repo}/${this.initialPath}...`);
|
|
220
|
+
yield* await this.processRepoAsStream(this.initialPath);
|
|
221
|
+
if (!this.processSubmodules) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
await this.getSubmoduleInfo();
|
|
225
|
+
for (const submoduleInfo of this.submoduleInfos) {
|
|
226
|
+
yield* await this.loadSubmoduleAsStream(submoduleInfo);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
213
229
|
/**
|
|
214
230
|
* Loads the information about Git submodules from the repository, if available.
|
|
215
231
|
*/
|
|
@@ -317,6 +333,37 @@ export class GithubRepoLoader extends BaseDocumentLoader {
|
|
|
317
333
|
}).load();
|
|
318
334
|
}
|
|
319
335
|
}
|
|
336
|
+
/**
|
|
337
|
+
* Asynchronously processes and streams the contents of a specified submodule in the GitHub repository.
|
|
338
|
+
* @param submoduleInfo the info about the submodule to be loaded
|
|
339
|
+
* @yields Yields a Promise that resolves to a Document object for each file found in the submodule.
|
|
340
|
+
*/
|
|
341
|
+
async *loadSubmoduleAsStream(submoduleInfo) {
|
|
342
|
+
if (!submoduleInfo.url.startsWith(this.baseUrl)) {
|
|
343
|
+
this.log(`Ignoring external submodule ${submoduleInfo.url}.`);
|
|
344
|
+
yield* [];
|
|
345
|
+
}
|
|
346
|
+
if (!submoduleInfo.path.startsWith(this.initialPath)) {
|
|
347
|
+
this.log(`Ignoring submodule ${submoduleInfo.url}, as it is not on initial path.`);
|
|
348
|
+
yield* [];
|
|
349
|
+
}
|
|
350
|
+
this.log(`Accessing submodule ${submoduleInfo.name} (${submoduleInfo.url})...`);
|
|
351
|
+
const submoduleLoader = new GithubRepoLoader(submoduleInfo.url, {
|
|
352
|
+
accessToken: this.accessToken,
|
|
353
|
+
baseUrl: this.baseUrl,
|
|
354
|
+
apiUrl: this.apiUrl,
|
|
355
|
+
branch: submoduleInfo.ref,
|
|
356
|
+
recursive: this.recursive,
|
|
357
|
+
processSubmodules: this.processSubmodules,
|
|
358
|
+
unknown: this.unknown,
|
|
359
|
+
ignoreFiles: this.ignoreFiles,
|
|
360
|
+
ignorePaths: this.ignorePaths,
|
|
361
|
+
verbose: this.verbose,
|
|
362
|
+
maxConcurrency: this.maxConcurrency,
|
|
363
|
+
maxRetries: this.maxRetries,
|
|
364
|
+
});
|
|
365
|
+
yield* await submoduleLoader.processRepoAsStream(submoduleInfo.path);
|
|
366
|
+
}
|
|
320
367
|
/**
|
|
321
368
|
* Determines whether a file or directory should be ignored based on its
|
|
322
369
|
* path and type.
|
|
@@ -408,6 +455,35 @@ export class GithubRepoLoader extends BaseDocumentLoader {
|
|
|
408
455
|
return Promise.reject(error);
|
|
409
456
|
}
|
|
410
457
|
}
|
|
458
|
+
/**
|
|
459
|
+
* Asynchronously processes the contents of the entire GitHub repository,
|
|
460
|
+
* streaming each file as a Document object.
|
|
461
|
+
* @param path The path of the directory to process.
|
|
462
|
+
* @yields Yields a Promise that resolves to a Document object for each file found in the repository.
|
|
463
|
+
*/
|
|
464
|
+
async *processRepoAsStream(path) {
|
|
465
|
+
const files = await this.fetchRepoFiles(path);
|
|
466
|
+
for (const file of files) {
|
|
467
|
+
if (this.shouldIgnore(file.path, file.type)) {
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
if (file.type === "file") {
|
|
471
|
+
try {
|
|
472
|
+
const fileResponse = await this.fetchFileContentWrapper(file);
|
|
473
|
+
yield new Document({
|
|
474
|
+
pageContent: fileResponse.contents,
|
|
475
|
+
metadata: fileResponse.metadata,
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
catch (error) {
|
|
479
|
+
this.handleError(`Failed to fetch file content: ${file.path}, ${error}`);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
else if (this.recursive) {
|
|
483
|
+
yield* await this.processDirectoryAsStream(file.path);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
411
487
|
/**
|
|
412
488
|
* Fetches the contents of a directory and maps the file / directory paths
|
|
413
489
|
* to promises that will fetch the file / directory contents.
|
|
@@ -424,6 +500,35 @@ export class GithubRepoLoader extends BaseDocumentLoader {
|
|
|
424
500
|
return Promise.reject(error);
|
|
425
501
|
}
|
|
426
502
|
}
|
|
503
|
+
/**
|
|
504
|
+
* Asynchronously processes the contents of a given directory in the GitHub repository,
|
|
505
|
+
* streaming each file as a Document object.
|
|
506
|
+
* @param path The path of the directory to process.
|
|
507
|
+
* @yields Yields a Promise that resolves to a Document object for each file in the directory.
|
|
508
|
+
*/
|
|
509
|
+
async *processDirectoryAsStream(path) {
|
|
510
|
+
const files = await this.fetchRepoFiles(path);
|
|
511
|
+
for (const file of files) {
|
|
512
|
+
if (this.shouldIgnore(file.path, file.type)) {
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
if (file.type === "file") {
|
|
516
|
+
try {
|
|
517
|
+
const fileResponse = await this.fetchFileContentWrapper(file);
|
|
518
|
+
yield new Document({
|
|
519
|
+
pageContent: fileResponse.contents,
|
|
520
|
+
metadata: fileResponse.metadata,
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
catch {
|
|
524
|
+
this.handleError(`Failed to fetch file content: ${file.path}`);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
else if (this.recursive) {
|
|
528
|
+
yield* await this.processDirectoryAsStream(file.path);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
427
532
|
/**
|
|
428
533
|
* Fetches the files from a GitHub repository.
|
|
429
534
|
* If the path denotes a single file, the resulting array contains only one element.
|
|
@@ -70,5 +70,5 @@ export declare class S3Loader extends BaseDocumentLoader {
|
|
|
70
70
|
* and then uses the UnstructuredLoader to load the file as a document.
|
|
71
71
|
* @returns An array of Document objects representing the loaded documents.
|
|
72
72
|
*/
|
|
73
|
-
load(): Promise<import("
|
|
73
|
+
load(): Promise<import("langchain-core/documents").Document<Record<string, any>>[]>;
|
|
74
74
|
}
|
package/dist/embeddings/base.cjs
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* queries using LangChain.
|
|
8
|
-
*/
|
|
9
|
-
class Embeddings {
|
|
10
|
-
constructor(params) {
|
|
11
|
-
/**
|
|
12
|
-
* The async caller should be used by subclasses to make any async calls,
|
|
13
|
-
* which will thus benefit from the concurrency and retry logic.
|
|
14
|
-
*/
|
|
15
|
-
Object.defineProperty(this, "caller", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true,
|
|
19
|
-
value: void 0
|
|
20
|
-
});
|
|
21
|
-
this.caller = new async_caller_js_1.AsyncCaller(params ?? {});
|
|
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]; } };
|
|
22
7
|
}
|
|
23
|
-
|
|
24
|
-
|
|
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
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("langchain-core/embeddings"), exports);
|
|
@@ -1,33 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* The parameters required to initialize an instance of the Embeddings
|
|
4
|
-
* class.
|
|
5
|
-
*/
|
|
6
|
-
export type EmbeddingsParams = AsyncCallerParams;
|
|
7
|
-
/**
|
|
8
|
-
* An abstract class that provides methods for embedding documents and
|
|
9
|
-
* queries using LangChain.
|
|
10
|
-
*/
|
|
11
|
-
export declare abstract class Embeddings {
|
|
12
|
-
/**
|
|
13
|
-
* The async caller should be used by subclasses to make any async calls,
|
|
14
|
-
* which will thus benefit from the concurrency and retry logic.
|
|
15
|
-
*/
|
|
16
|
-
caller: AsyncCaller;
|
|
17
|
-
constructor(params: EmbeddingsParams);
|
|
18
|
-
/**
|
|
19
|
-
* An abstract method that takes an array of documents as input and
|
|
20
|
-
* returns a promise that resolves to an array of vectors for each
|
|
21
|
-
* document.
|
|
22
|
-
* @param documents An array of documents to be embedded.
|
|
23
|
-
* @returns A promise that resolves to an array of vectors for each document.
|
|
24
|
-
*/
|
|
25
|
-
abstract embedDocuments(documents: string[]): Promise<number[][]>;
|
|
26
|
-
/**
|
|
27
|
-
* An abstract method that takes a single document as input and returns a
|
|
28
|
-
* promise that resolves to a vector for the query document.
|
|
29
|
-
* @param document A single document to be embedded.
|
|
30
|
-
* @returns A promise that resolves to a vector for the query document.
|
|
31
|
-
*/
|
|
32
|
-
abstract embedQuery(document: string): Promise<number[]>;
|
|
33
|
-
}
|
|
1
|
+
export * from "langchain-core/embeddings";
|
package/dist/embeddings/base.js
CHANGED
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* An abstract class that provides methods for embedding documents and
|
|
4
|
-
* queries using LangChain.
|
|
5
|
-
*/
|
|
6
|
-
export class Embeddings {
|
|
7
|
-
constructor(params) {
|
|
8
|
-
/**
|
|
9
|
-
* The async caller should be used by subclasses to make any async calls,
|
|
10
|
-
* which will thus benefit from the concurrency and retry logic.
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(this, "caller", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
configurable: true,
|
|
15
|
-
writable: true,
|
|
16
|
-
value: void 0
|
|
17
|
-
});
|
|
18
|
-
this.caller = new AsyncCaller(params ?? {});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
export * from "langchain-core/embeddings";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CacheBackedEmbeddings = void 0;
|
|
4
|
-
const
|
|
4
|
+
const hash_1 = require("langchain-core/utils/hash");
|
|
5
5
|
const encoder_backed_js_1 = require("../storage/encoder_backed.cjs");
|
|
6
6
|
const base_js_1 = require("./base.cjs");
|
|
7
7
|
/**
|
|
@@ -130,7 +130,7 @@ class CacheBackedEmbeddings extends base_js_1.Embeddings {
|
|
|
130
130
|
const decoder = new TextDecoder();
|
|
131
131
|
const encoderBackedStore = new encoder_backed_js_1.EncoderBackedStore({
|
|
132
132
|
store: documentEmbeddingStore,
|
|
133
|
-
keyEncoder: (key) => (options?.namespace ?? "") + (0,
|
|
133
|
+
keyEncoder: (key) => (options?.namespace ?? "") + (0, hash_1.insecureHash)(key),
|
|
134
134
|
valueSerializer: (value) => encoder.encode(JSON.stringify(value)),
|
|
135
135
|
valueDeserializer: (serializedValue) => JSON.parse(decoder.decode(serializedValue)),
|
|
136
136
|
});
|
|
@@ -27,7 +27,7 @@ export declare class TrajectoryEvalChain extends AgentTrajectoryEvaluator {
|
|
|
27
27
|
requiresInput: boolean;
|
|
28
28
|
requiresReference: boolean;
|
|
29
29
|
outputParser: TrajectoryOutputParser;
|
|
30
|
-
static resolveTrajectoryPrompt(prompt?: BasePromptTemplate | undefined, agentTools?: StructuredTool[]): import("../../
|
|
30
|
+
static resolveTrajectoryPrompt(prompt?: BasePromptTemplate | undefined, agentTools?: StructuredTool[]): BasePromptTemplate<any, import("../../schema/index.js").BasePromptValue, any> | import("../../prompts/index.js").ChatPromptTemplate<any, any>;
|
|
31
31
|
/**
|
|
32
32
|
* Get the description of the agent tools.
|
|
33
33
|
*
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { PromptTemplate } from "../../prompts/index.js";
|
|
2
2
|
export declare const CRITERIA_PROMPT: PromptTemplate<{
|
|
3
|
-
output: any;
|
|
4
3
|
input: any;
|
|
4
|
+
output: any;
|
|
5
5
|
criteria: any;
|
|
6
6
|
}, any>;
|
|
7
7
|
export declare const PROMPT_WITH_REFERENCES: PromptTemplate<{
|
|
8
|
-
output: any;
|
|
9
8
|
input: any;
|
|
9
|
+
output: any;
|
|
10
10
|
criteria: any;
|
|
11
11
|
reference: any;
|
|
12
12
|
}, any>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PromptTemplate } from "../../prompts/prompt.js";
|
|
2
2
|
export declare const QA_PROMPT: PromptTemplate<{
|
|
3
|
-
query: any;
|
|
4
3
|
answer: any;
|
|
4
|
+
query: any;
|
|
5
5
|
result: any;
|
|
6
6
|
}, any>;
|
|
7
7
|
export declare const SQL_PROMPT: PromptTemplate<{
|
|
8
|
-
query: any;
|
|
9
8
|
answer: any;
|
|
9
|
+
query: any;
|
|
10
10
|
result: any;
|
|
11
11
|
}, any>;
|
|
@@ -118,7 +118,7 @@ export declare class MakerSuitePrompt {
|
|
|
118
118
|
* will have the parameters (model name, temperature, etc) from those in
|
|
119
119
|
* MakerSuite.
|
|
120
120
|
*/
|
|
121
|
-
toChain(): import("../../../schema/runnable/
|
|
121
|
+
toChain(): import("../../../schema/runnable/index.js").RunnableSequence<any, any>;
|
|
122
122
|
}
|
|
123
123
|
interface DriveFileReadParams extends GoogleVertexAIConnectionParams<GoogleAuthOptions> {
|
|
124
124
|
fileId: string;
|
|
@@ -10,4 +10,4 @@ export declare const DEFAULT_STEP_EXECUTOR_HUMAN_CHAT_MESSAGE_TEMPLATE = "Previo
|
|
|
10
10
|
* @param tools the tools available to the `planner`
|
|
11
11
|
* @returns
|
|
12
12
|
*/
|
|
13
|
-
export declare const getPlannerChatPrompt: (tools: Tool[] | DynamicStructuredTool[]) => Promise<ChatPromptTemplate<import("
|
|
13
|
+
export declare const getPlannerChatPrompt: (tools: Tool[] | DynamicStructuredTool[]) => Promise<ChatPromptTemplate<import("langchain-core/utils/types").InputValues<string>, any>>;
|