@langchain/core 0.1.39 → 0.1.40
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/retrievers.cjs
CHANGED
|
@@ -50,7 +50,7 @@ class BaseRetriever extends base_js_1.Runnable {
|
|
|
50
50
|
throw new Error("Not implemented!");
|
|
51
51
|
}
|
|
52
52
|
async invoke(input, options) {
|
|
53
|
-
return this.getRelevantDocuments(input, options);
|
|
53
|
+
return this.getRelevantDocuments(input, (0, config_js_1.ensureConfig)(options));
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Main method used to retrieve relevant documents. It takes a query
|
package/dist/retrievers.d.ts
CHANGED
|
@@ -11,15 +11,15 @@ export interface BaseRetrieverInput {
|
|
|
11
11
|
metadata?: Record<string, unknown>;
|
|
12
12
|
verbose?: boolean;
|
|
13
13
|
}
|
|
14
|
-
export interface BaseRetrieverInterface extends RunnableInterface<string, DocumentInterface[]> {
|
|
15
|
-
getRelevantDocuments(query: string, config?: Callbacks | BaseCallbackConfig): Promise<DocumentInterface[]>;
|
|
14
|
+
export interface BaseRetrieverInterface<Metadata extends Record<string, any> = Record<string, any>> extends RunnableInterface<string, DocumentInterface<Metadata>[]> {
|
|
15
|
+
getRelevantDocuments(query: string, config?: Callbacks | BaseCallbackConfig): Promise<DocumentInterface<Metadata>[]>;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Abstract base class for a Document retrieval system. A retrieval system
|
|
19
19
|
* is defined as something that can take string queries and return the
|
|
20
20
|
* most 'relevant' Documents from some source.
|
|
21
21
|
*/
|
|
22
|
-
export declare abstract class BaseRetriever extends Runnable<string, DocumentInterface[]> implements BaseRetrieverInterface {
|
|
22
|
+
export declare abstract class BaseRetriever<Metadata extends Record<string, any> = Record<string, any>> extends Runnable<string, DocumentInterface<Metadata>[]> implements BaseRetrieverInterface {
|
|
23
23
|
callbacks?: Callbacks;
|
|
24
24
|
tags?: string[];
|
|
25
25
|
metadata?: Record<string, unknown>;
|
|
@@ -30,8 +30,8 @@ export declare abstract class BaseRetriever extends Runnable<string, DocumentInt
|
|
|
30
30
|
* changes to people currently using subclassed custom retrievers.
|
|
31
31
|
* Change it on next major release.
|
|
32
32
|
*/
|
|
33
|
-
_getRelevantDocuments(_query: string, _callbacks?: CallbackManagerForRetrieverRun): Promise<DocumentInterface[]>;
|
|
34
|
-
invoke(input: string, options?: RunnableConfig): Promise<DocumentInterface[]>;
|
|
33
|
+
_getRelevantDocuments(_query: string, _callbacks?: CallbackManagerForRetrieverRun): Promise<DocumentInterface<Metadata>[]>;
|
|
34
|
+
invoke(input: string, options?: RunnableConfig): Promise<DocumentInterface<Metadata>[]>;
|
|
35
35
|
/**
|
|
36
36
|
* Main method used to retrieve relevant documents. It takes a query
|
|
37
37
|
* string and an optional configuration object, and returns a promise that
|
|
@@ -42,5 +42,5 @@ export declare abstract class BaseRetriever extends Runnable<string, DocumentInt
|
|
|
42
42
|
* @param config Optional configuration object for the retrieval process.
|
|
43
43
|
* @returns A promise that resolves to an array of `Document` objects.
|
|
44
44
|
*/
|
|
45
|
-
getRelevantDocuments(query: string, config?: Callbacks | BaseCallbackConfig): Promise<DocumentInterface[]>;
|
|
45
|
+
getRelevantDocuments(query: string, config?: Callbacks | BaseCallbackConfig): Promise<DocumentInterface<Metadata>[]>;
|
|
46
46
|
}
|
package/dist/retrievers.js
CHANGED
|
@@ -47,7 +47,7 @@ export class BaseRetriever extends Runnable {
|
|
|
47
47
|
throw new Error("Not implemented!");
|
|
48
48
|
}
|
|
49
49
|
async invoke(input, options) {
|
|
50
|
-
return this.getRelevantDocuments(input, options);
|
|
50
|
+
return this.getRelevantDocuments(input, ensureConfig(options));
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Main method used to retrieve relevant documents. It takes a query
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RouterRunnable = void 0;
|
|
4
4
|
const base_js_1 = require("./base.cjs");
|
|
5
|
+
const config_js_1 = require("./config.cjs");
|
|
5
6
|
/**
|
|
6
7
|
* A runnable that routes to a set of runnables based on Input['key'].
|
|
7
8
|
* Returns the output of the selected runnable.
|
|
@@ -38,7 +39,7 @@ class RouterRunnable extends base_js_1.Runnable {
|
|
|
38
39
|
if (runnable === undefined) {
|
|
39
40
|
throw new Error(`No runnable associated with key "${key}".`);
|
|
40
41
|
}
|
|
41
|
-
return runnable.invoke(actualInput, options);
|
|
42
|
+
return runnable.invoke(actualInput, (0, config_js_1.ensureConfig)(options));
|
|
42
43
|
}
|
|
43
44
|
async batch(inputs, options, batchOptions) {
|
|
44
45
|
const keys = inputs.map((input) => input.key);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Runnable, type RunnableBatchOptions } from "./base.js";
|
|
2
2
|
import { IterableReadableStream } from "../utils/stream.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type RunnableConfig } from "./config.js";
|
|
4
4
|
export type RouterInput = {
|
|
5
5
|
key: string;
|
|
6
6
|
input: any;
|
package/dist/runnables/router.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Runnable } from "./base.js";
|
|
2
|
+
import { ensureConfig } from "./config.js";
|
|
2
3
|
/**
|
|
3
4
|
* A runnable that routes to a set of runnables based on Input['key'].
|
|
4
5
|
* Returns the output of the selected runnable.
|
|
@@ -35,7 +36,7 @@ export class RouterRunnable extends Runnable {
|
|
|
35
36
|
if (runnable === undefined) {
|
|
36
37
|
throw new Error(`No runnable associated with key "${key}".`);
|
|
37
38
|
}
|
|
38
|
-
return runnable.invoke(actualInput, options);
|
|
39
|
+
return runnable.invoke(actualInput, ensureConfig(options));
|
|
39
40
|
}
|
|
40
41
|
async batch(inputs, options, batchOptions) {
|
|
41
42
|
const keys = inputs.map((input) => input.key);
|