langchain 0.0.169 → 0.0.171
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/README.md +2 -2
- package/agents/format_scratchpad.cjs +1 -0
- package/agents/format_scratchpad.d.ts +1 -0
- package/agents/format_scratchpad.js +1 -0
- package/chat_models/llama_cpp.cjs +1 -0
- package/chat_models/llama_cpp.d.ts +1 -0
- package/chat_models/llama_cpp.js +1 -0
- package/dist/agents/agent.cjs +49 -1
- package/dist/agents/agent.d.ts +19 -1
- package/dist/agents/agent.js +47 -0
- package/dist/agents/executor.cjs +10 -1
- package/dist/agents/executor.d.ts +22 -8
- package/dist/agents/executor.js +11 -2
- package/dist/agents/format_scratchpad.cjs +25 -0
- package/dist/agents/format_scratchpad.d.ts +10 -0
- package/dist/agents/format_scratchpad.js +21 -0
- package/dist/agents/toolkits/aws_sfn.d.ts +4 -1
- package/dist/agents/toolkits/conversational_retrieval/openai_functions.d.ts +1 -1
- package/dist/agents/toolkits/json/json.d.ts +4 -1
- package/dist/agents/toolkits/openapi/openapi.cjs +8 -0
- package/dist/agents/toolkits/openapi/openapi.d.ts +12 -1
- package/dist/agents/toolkits/openapi/openapi.js +8 -0
- package/dist/agents/toolkits/sql/sql.d.ts +4 -1
- package/dist/agents/toolkits/vectorstore/vectorstore.d.ts +8 -2
- package/dist/agents/types.d.ts +13 -1
- package/dist/chains/sql_db/sql_db_chain.cjs +11 -0
- package/dist/chains/sql_db/sql_db_chain.d.ts +11 -0
- package/dist/chains/sql_db/sql_db_chain.js +11 -0
- package/dist/chat_models/baiduwenxin.cjs +12 -1
- package/dist/chat_models/baiduwenxin.d.ts +3 -1
- package/dist/chat_models/baiduwenxin.js +12 -1
- package/dist/chat_models/llama_cpp.cjs +243 -0
- package/dist/chat_models/llama_cpp.d.ts +94 -0
- package/dist/chat_models/llama_cpp.js +239 -0
- package/dist/document_loaders/web/assemblyai.cjs +63 -114
- package/dist/document_loaders/web/assemblyai.d.ts +38 -57
- package/dist/document_loaders/web/assemblyai.js +63 -100
- package/dist/document_loaders/web/pdf.cjs +23 -5
- package/dist/document_loaders/web/pdf.d.ts +9 -1
- package/dist/document_loaders/web/pdf.js +20 -2
- package/dist/graphs/neo4j_graph.cjs +14 -0
- package/dist/graphs/neo4j_graph.d.ts +14 -0
- package/dist/graphs/neo4j_graph.js +14 -0
- package/dist/llms/googlepalm.cjs +3 -0
- package/dist/llms/googlepalm.js +3 -0
- package/dist/load/import_constants.cjs +2 -0
- package/dist/load/import_constants.js +2 -0
- package/dist/load/import_map.cjs +3 -2
- package/dist/load/import_map.d.ts +1 -0
- package/dist/load/import_map.js +1 -0
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/retrievers/parent_document.cjs +22 -2
- package/dist/retrievers/parent_document.d.ts +8 -1
- package/dist/retrievers/parent_document.js +22 -2
- package/dist/retrievers/time_weighted.cjs +1 -1
- package/dist/retrievers/time_weighted.d.ts +1 -1
- package/dist/retrievers/time_weighted.js +1 -1
- package/dist/schema/runnable/base.cjs +4 -1
- package/dist/schema/runnable/base.d.ts +1 -0
- package/dist/schema/runnable/base.js +4 -1
- package/dist/schema/runnable/passthrough.cjs +35 -1
- package/dist/schema/runnable/passthrough.d.ts +11 -1
- package/dist/schema/runnable/passthrough.js +34 -1
- package/dist/sql_db.cjs +14 -0
- package/dist/sql_db.d.ts +14 -0
- package/dist/sql_db.js +14 -0
- package/dist/storage/ioredis.cjs +2 -1
- package/dist/storage/ioredis.js +2 -1
- package/dist/storage/upstash_redis.cjs +155 -0
- package/dist/storage/upstash_redis.d.ts +59 -0
- package/dist/storage/upstash_redis.js +151 -0
- package/dist/storage/vercel_kv.cjs +2 -1
- package/dist/storage/vercel_kv.js +2 -1
- package/dist/types/assemblyai-types.cjs +0 -150
- package/dist/types/assemblyai-types.d.ts +4 -670
- package/dist/types/assemblyai-types.js +1 -149
- package/dist/util/stream.cjs +3 -0
- package/dist/util/stream.js +3 -0
- package/dist/vectorstores/cassandra.cjs +25 -4
- package/dist/vectorstores/cassandra.d.ts +11 -1
- package/dist/vectorstores/cassandra.js +25 -4
- package/dist/vectorstores/momento_vector_index.cjs +3 -15
- package/dist/vectorstores/momento_vector_index.d.ts +0 -8
- package/dist/vectorstores/momento_vector_index.js +3 -15
- package/dist/vectorstores/neo4j_vector.cjs +14 -0
- package/dist/vectorstores/neo4j_vector.d.ts +14 -0
- package/dist/vectorstores/neo4j_vector.js +14 -0
- package/dist/vectorstores/pgvector.cjs +1 -1
- package/dist/vectorstores/pgvector.js +1 -1
- package/package.json +37 -8
- package/storage/upstash_redis.cjs +1 -0
- package/storage/upstash_redis.d.ts +1 -0
- package/storage/upstash_redis.js +1 -0
- package/dist/util/assemblyai-client.cjs +0 -173
- package/dist/util/assemblyai-client.d.ts +0 -63
- package/dist/util/assemblyai-client.js +0 -170
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebPDFLoader = void 0;
|
|
4
|
-
const pdf_js_1 = require("pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js");
|
|
5
4
|
const document_js_1 = require("../../document.cjs");
|
|
6
5
|
const base_js_1 = require("../base.cjs");
|
|
7
6
|
/**
|
|
8
7
|
* A document loader for loading data from PDFs.
|
|
9
8
|
*/
|
|
10
9
|
class WebPDFLoader extends base_js_1.BaseDocumentLoader {
|
|
11
|
-
constructor(blob, { splitPages = true } = {}) {
|
|
10
|
+
constructor(blob, { splitPages = true, pdfjs = PDFLoaderImports } = {}) {
|
|
12
11
|
super();
|
|
13
12
|
Object.defineProperty(this, "blob", {
|
|
14
13
|
enumerable: true,
|
|
@@ -22,15 +21,23 @@ class WebPDFLoader extends base_js_1.BaseDocumentLoader {
|
|
|
22
21
|
writable: true,
|
|
23
22
|
value: true
|
|
24
23
|
});
|
|
24
|
+
Object.defineProperty(this, "pdfjs", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
25
30
|
this.blob = blob;
|
|
26
31
|
this.splitPages = splitPages ?? this.splitPages;
|
|
32
|
+
this.pdfjs = pdfjs;
|
|
27
33
|
}
|
|
28
34
|
/**
|
|
29
35
|
* Loads the contents of the PDF as documents.
|
|
30
36
|
* @returns An array of Documents representing the retrieved data.
|
|
31
37
|
*/
|
|
32
38
|
async load() {
|
|
33
|
-
const
|
|
39
|
+
const { getDocument, version } = await this.pdfjs();
|
|
40
|
+
const parsedPdf = await getDocument({
|
|
34
41
|
data: new Uint8Array(await this.blob.arrayBuffer()),
|
|
35
42
|
useWorkerFetch: false,
|
|
36
43
|
isEvalSupported: false,
|
|
@@ -51,7 +58,7 @@ class WebPDFLoader extends base_js_1.BaseDocumentLoader {
|
|
|
51
58
|
pageContent: text,
|
|
52
59
|
metadata: {
|
|
53
60
|
pdf: {
|
|
54
|
-
version
|
|
61
|
+
version,
|
|
55
62
|
info: meta?.info,
|
|
56
63
|
metadata: meta?.metadata,
|
|
57
64
|
totalPages: parsedPdf.numPages,
|
|
@@ -73,7 +80,7 @@ class WebPDFLoader extends base_js_1.BaseDocumentLoader {
|
|
|
73
80
|
pageContent: documents.map((doc) => doc.pageContent).join("\n\n"),
|
|
74
81
|
metadata: {
|
|
75
82
|
pdf: {
|
|
76
|
-
version
|
|
83
|
+
version,
|
|
77
84
|
info: meta?.info,
|
|
78
85
|
metadata: meta?.metadata,
|
|
79
86
|
totalPages: parsedPdf.numPages,
|
|
@@ -85,3 +92,14 @@ class WebPDFLoader extends base_js_1.BaseDocumentLoader {
|
|
|
85
92
|
}
|
|
86
93
|
}
|
|
87
94
|
exports.WebPDFLoader = WebPDFLoader;
|
|
95
|
+
async function PDFLoaderImports() {
|
|
96
|
+
try {
|
|
97
|
+
const { default: mod } = await import("pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js");
|
|
98
|
+
const { getDocument, version } = mod;
|
|
99
|
+
return { getDocument, version };
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
console.error(e);
|
|
103
|
+
throw new Error("Failed to load pdf-parse. Please install it with eg. `npm install pdf-parse`.");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference path="../../../src/types/pdf-parse.d.ts" />
|
|
1
2
|
import { Document } from "../../document.js";
|
|
2
3
|
import { BaseDocumentLoader } from "../base.js";
|
|
3
4
|
/**
|
|
@@ -6,8 +7,10 @@ import { BaseDocumentLoader } from "../base.js";
|
|
|
6
7
|
export declare class WebPDFLoader extends BaseDocumentLoader {
|
|
7
8
|
protected blob: Blob;
|
|
8
9
|
protected splitPages: boolean;
|
|
9
|
-
|
|
10
|
+
private pdfjs;
|
|
11
|
+
constructor(blob: Blob, { splitPages, pdfjs }?: {
|
|
10
12
|
splitPages?: boolean | undefined;
|
|
13
|
+
pdfjs?: typeof PDFLoaderImports | undefined;
|
|
11
14
|
});
|
|
12
15
|
/**
|
|
13
16
|
* Loads the contents of the PDF as documents.
|
|
@@ -15,3 +18,8 @@ export declare class WebPDFLoader extends BaseDocumentLoader {
|
|
|
15
18
|
*/
|
|
16
19
|
load(): Promise<Document[]>;
|
|
17
20
|
}
|
|
21
|
+
declare function PDFLoaderImports(): Promise<{
|
|
22
|
+
getDocument: typeof import("pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js").getDocument;
|
|
23
|
+
version: string;
|
|
24
|
+
}>;
|
|
25
|
+
export {};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { getDocument, version, } from "pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js";
|
|
2
1
|
import { Document } from "../../document.js";
|
|
3
2
|
import { BaseDocumentLoader } from "../base.js";
|
|
4
3
|
/**
|
|
5
4
|
* A document loader for loading data from PDFs.
|
|
6
5
|
*/
|
|
7
6
|
export class WebPDFLoader extends BaseDocumentLoader {
|
|
8
|
-
constructor(blob, { splitPages = true } = {}) {
|
|
7
|
+
constructor(blob, { splitPages = true, pdfjs = PDFLoaderImports } = {}) {
|
|
9
8
|
super();
|
|
10
9
|
Object.defineProperty(this, "blob", {
|
|
11
10
|
enumerable: true,
|
|
@@ -19,14 +18,22 @@ export class WebPDFLoader extends BaseDocumentLoader {
|
|
|
19
18
|
writable: true,
|
|
20
19
|
value: true
|
|
21
20
|
});
|
|
21
|
+
Object.defineProperty(this, "pdfjs", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: void 0
|
|
26
|
+
});
|
|
22
27
|
this.blob = blob;
|
|
23
28
|
this.splitPages = splitPages ?? this.splitPages;
|
|
29
|
+
this.pdfjs = pdfjs;
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
32
|
* Loads the contents of the PDF as documents.
|
|
27
33
|
* @returns An array of Documents representing the retrieved data.
|
|
28
34
|
*/
|
|
29
35
|
async load() {
|
|
36
|
+
const { getDocument, version } = await this.pdfjs();
|
|
30
37
|
const parsedPdf = await getDocument({
|
|
31
38
|
data: new Uint8Array(await this.blob.arrayBuffer()),
|
|
32
39
|
useWorkerFetch: false,
|
|
@@ -81,3 +88,14 @@ export class WebPDFLoader extends BaseDocumentLoader {
|
|
|
81
88
|
return documents;
|
|
82
89
|
}
|
|
83
90
|
}
|
|
91
|
+
async function PDFLoaderImports() {
|
|
92
|
+
try {
|
|
93
|
+
const { default: mod } = await import("pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js");
|
|
94
|
+
const { getDocument, version } = mod;
|
|
95
|
+
return { getDocument, version };
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
console.error(e);
|
|
99
|
+
throw new Error("Failed to load pdf-parse. Please install it with eg. `npm install pdf-parse`.");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -5,6 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Neo4jGraph = void 0;
|
|
7
7
|
const neo4j_driver_1 = __importDefault(require("neo4j-driver"));
|
|
8
|
+
/**
|
|
9
|
+
* @security *Security note*: Make sure that the database connection uses credentials
|
|
10
|
+
* that are narrowly-scoped to only include necessary permissions.
|
|
11
|
+
* Failure to do so may result in data corruption or loss, since the calling
|
|
12
|
+
* code may attempt commands that would result in deletion, mutation
|
|
13
|
+
* of data if appropriately prompted or reading sensitive data if such
|
|
14
|
+
* data is present in the database.
|
|
15
|
+
* The best way to guard against such negative outcomes is to (as appropriate)
|
|
16
|
+
* limit the permissions granted to the credentials used with this tool.
|
|
17
|
+
* For example, creating read only users for the database is a good way to
|
|
18
|
+
* ensure that the calling code cannot mutate or delete data.
|
|
19
|
+
*
|
|
20
|
+
* @link See https://js.langchain.com/docs/security for more information.
|
|
21
|
+
*/
|
|
8
22
|
class Neo4jGraph {
|
|
9
23
|
constructor({ url, username, password, database = "neo4j", }) {
|
|
10
24
|
Object.defineProperty(this, "driver", {
|
|
@@ -4,6 +4,20 @@ interface Neo4jGraphConfig {
|
|
|
4
4
|
password: string;
|
|
5
5
|
database?: string;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* @security *Security note*: Make sure that the database connection uses credentials
|
|
9
|
+
* that are narrowly-scoped to only include necessary permissions.
|
|
10
|
+
* Failure to do so may result in data corruption or loss, since the calling
|
|
11
|
+
* code may attempt commands that would result in deletion, mutation
|
|
12
|
+
* of data if appropriately prompted or reading sensitive data if such
|
|
13
|
+
* data is present in the database.
|
|
14
|
+
* The best way to guard against such negative outcomes is to (as appropriate)
|
|
15
|
+
* limit the permissions granted to the credentials used with this tool.
|
|
16
|
+
* For example, creating read only users for the database is a good way to
|
|
17
|
+
* ensure that the calling code cannot mutate or delete data.
|
|
18
|
+
*
|
|
19
|
+
* @link See https://js.langchain.com/docs/security for more information.
|
|
20
|
+
*/
|
|
7
21
|
export declare class Neo4jGraph {
|
|
8
22
|
private driver;
|
|
9
23
|
private database;
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import neo4j from "neo4j-driver";
|
|
2
|
+
/**
|
|
3
|
+
* @security *Security note*: Make sure that the database connection uses credentials
|
|
4
|
+
* that are narrowly-scoped to only include necessary permissions.
|
|
5
|
+
* Failure to do so may result in data corruption or loss, since the calling
|
|
6
|
+
* code may attempt commands that would result in deletion, mutation
|
|
7
|
+
* of data if appropriately prompted or reading sensitive data if such
|
|
8
|
+
* data is present in the database.
|
|
9
|
+
* The best way to guard against such negative outcomes is to (as appropriate)
|
|
10
|
+
* limit the permissions granted to the credentials used with this tool.
|
|
11
|
+
* For example, creating read only users for the database is a good way to
|
|
12
|
+
* ensure that the calling code cannot mutate or delete data.
|
|
13
|
+
*
|
|
14
|
+
* @link See https://js.langchain.com/docs/security for more information.
|
|
15
|
+
*/
|
|
2
16
|
export class Neo4jGraph {
|
|
3
17
|
constructor({ url, username, password, database = "neo4j", }) {
|
|
4
18
|
Object.defineProperty(this, "driver", {
|
package/dist/llms/googlepalm.cjs
CHANGED
|
@@ -83,6 +83,9 @@ class GooglePaLM extends base_js_1.LLM {
|
|
|
83
83
|
if (this.topP && this.topP < 0) {
|
|
84
84
|
throw new Error("`topP` must be a positive integer");
|
|
85
85
|
}
|
|
86
|
+
if (this.topP && this.topP > 1) {
|
|
87
|
+
throw new Error("Google PaLM `topP` must in the range of [0,1]");
|
|
88
|
+
}
|
|
86
89
|
this.topK = fields?.topK ?? this.topK;
|
|
87
90
|
if (this.topK && this.topK < 0) {
|
|
88
91
|
throw new Error("`topK` must be a positive integer");
|
package/dist/llms/googlepalm.js
CHANGED
|
@@ -80,6 +80,9 @@ export class GooglePaLM extends LLM {
|
|
|
80
80
|
if (this.topP && this.topP < 0) {
|
|
81
81
|
throw new Error("`topP` must be a positive integer");
|
|
82
82
|
}
|
|
83
|
+
if (this.topP && this.topP > 1) {
|
|
84
|
+
throw new Error("Google PaLM `topP` must in the range of [0,1]");
|
|
85
|
+
}
|
|
83
86
|
this.topK = fields?.topK ?? this.topK;
|
|
84
87
|
if (this.topK && this.topK < 0) {
|
|
85
88
|
throw new Error("`topK` must be a positive integer");
|
|
@@ -112,6 +112,7 @@ exports.optionalImportEntrypoints = [
|
|
|
112
112
|
"langchain/chat_models/googlevertexai",
|
|
113
113
|
"langchain/chat_models/googlevertexai/web",
|
|
114
114
|
"langchain/chat_models/googlepalm",
|
|
115
|
+
"langchain/chat_models/llama_cpp",
|
|
115
116
|
"langchain/sql_db",
|
|
116
117
|
"langchain/callbacks/handlers/llmonitor",
|
|
117
118
|
"langchain/output_parsers/expression",
|
|
@@ -144,6 +145,7 @@ exports.optionalImportEntrypoints = [
|
|
|
144
145
|
"langchain/stores/message/xata",
|
|
145
146
|
"langchain/storage/ioredis",
|
|
146
147
|
"langchain/storage/vercel_kv",
|
|
148
|
+
"langchain/storage/upstash_redis",
|
|
147
149
|
"langchain/graphs/neo4j_graph",
|
|
148
150
|
"langchain/hub",
|
|
149
151
|
"langchain/experimental/multimodal_embeddings/googlevertexai",
|
|
@@ -109,6 +109,7 @@ export const optionalImportEntrypoints = [
|
|
|
109
109
|
"langchain/chat_models/googlevertexai",
|
|
110
110
|
"langchain/chat_models/googlevertexai/web",
|
|
111
111
|
"langchain/chat_models/googlepalm",
|
|
112
|
+
"langchain/chat_models/llama_cpp",
|
|
112
113
|
"langchain/sql_db",
|
|
113
114
|
"langchain/callbacks/handlers/llmonitor",
|
|
114
115
|
"langchain/output_parsers/expression",
|
|
@@ -141,6 +142,7 @@ export const optionalImportEntrypoints = [
|
|
|
141
142
|
"langchain/stores/message/xata",
|
|
142
143
|
"langchain/storage/ioredis",
|
|
143
144
|
"langchain/storage/vercel_kv",
|
|
145
|
+
"langchain/storage/upstash_redis",
|
|
144
146
|
"langchain/graphs/neo4j_graph",
|
|
145
147
|
"langchain/hub",
|
|
146
148
|
"langchain/experimental/multimodal_embeddings/googlevertexai",
|
package/dist/load/import_map.cjs
CHANGED
|
@@ -24,11 +24,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.
|
|
28
|
-
exports.runnables__remote = exports.evaluation = exports.experimental__chains__violation_of_expectations = exports.experimental__chat_models__bittensor = exports.experimental__plan_and_execute = exports.experimental__generative_agents = exports.experimental__babyagi = exports.experimental__autogpt = exports.util__time = exports.util__math = exports.storage__in_memory = exports.storage__encoder_backed = exports.stores__message__in_memory = exports.stores__file__in_memory = exports.stores__doc__in_memory = exports.cache = exports.retrievers__vespa = exports.retrievers__score_threshold = exports.retrievers__hyde = exports.retrievers__document_compressors__embeddings_filter = exports.retrievers__document_compressors__chain_extract = exports.retrievers__time_weighted = exports.retrievers__tavily_search_api = exports.retrievers__parent_document = exports.retrievers__multi_vector = exports.retrievers__multi_query = exports.retrievers__document_compressors = exports.retrievers__contextual_compression = exports.retrievers__databerry = exports.retrievers__chaindesk = exports.retrievers__remote = exports.output_parsers = exports.callbacks = exports.schema__storage = exports.schema__runnable = exports.schema__retriever = void 0;
|
|
27
|
+
exports.schema__output_parser = exports.schema__document = exports.schema = exports.chat_models__fake = exports.chat_models__yandex = exports.chat_models__minimax = exports.chat_models__ollama = exports.chat_models__baiduwenxin = exports.chat_models__fireworks = exports.chat_models__cloudflare_workersai = exports.chat_models__anthropic = exports.chat_models__openai = exports.chat_models__base = exports.document_transformers__openai_functions = exports.document_loaders__web__sort_xyz_blockchain = exports.document_loaders__web__serpapi = exports.document_loaders__web__searchapi = exports.document_loaders__base = exports.document = exports.memory = exports.text_splitter = exports.vectorstores__xata = exports.vectorstores__vectara = exports.vectorstores__prisma = exports.vectorstores__memory = exports.vectorstores__base = exports.prompts = exports.llms__fake = exports.llms__yandex = exports.llms__fireworks = exports.llms__ollama = exports.llms__cloudflare_workersai = exports.llms__aleph_alpha = exports.llms__ai21 = exports.llms__openai = exports.llms__base = exports.embeddings__minimax = exports.embeddings__openai = exports.embeddings__ollama = exports.embeddings__fake = exports.embeddings__cache_backed = exports.embeddings__base = exports.chains__openai_functions = exports.chains = exports.tools = exports.base_language = exports.agents__format_scratchpad = exports.agents__toolkits = exports.agents = exports.load__serializable = void 0;
|
|
28
|
+
exports.runnables__remote = exports.evaluation = exports.experimental__chains__violation_of_expectations = exports.experimental__chat_models__bittensor = exports.experimental__plan_and_execute = exports.experimental__generative_agents = exports.experimental__babyagi = exports.experimental__autogpt = exports.util__time = exports.util__math = exports.storage__in_memory = exports.storage__encoder_backed = exports.stores__message__in_memory = exports.stores__file__in_memory = exports.stores__doc__in_memory = exports.cache = exports.retrievers__vespa = exports.retrievers__score_threshold = exports.retrievers__hyde = exports.retrievers__document_compressors__embeddings_filter = exports.retrievers__document_compressors__chain_extract = exports.retrievers__time_weighted = exports.retrievers__tavily_search_api = exports.retrievers__parent_document = exports.retrievers__multi_vector = exports.retrievers__multi_query = exports.retrievers__document_compressors = exports.retrievers__contextual_compression = exports.retrievers__databerry = exports.retrievers__chaindesk = exports.retrievers__remote = exports.output_parsers = exports.callbacks = exports.schema__storage = exports.schema__runnable = exports.schema__retriever = exports.schema__query_constructor = void 0;
|
|
29
29
|
exports.load__serializable = __importStar(require("../load/serializable.cjs"));
|
|
30
30
|
exports.agents = __importStar(require("../agents/index.cjs"));
|
|
31
31
|
exports.agents__toolkits = __importStar(require("../agents/toolkits/index.cjs"));
|
|
32
|
+
exports.agents__format_scratchpad = __importStar(require("../agents/format_scratchpad.cjs"));
|
|
32
33
|
exports.base_language = __importStar(require("../base_language/index.cjs"));
|
|
33
34
|
exports.tools = __importStar(require("../tools/index.cjs"));
|
|
34
35
|
exports.chains = __importStar(require("../chains/index.cjs"));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * as load__serializable from "../load/serializable.js";
|
|
2
2
|
export * as agents from "../agents/index.js";
|
|
3
3
|
export * as agents__toolkits from "../agents/toolkits/index.js";
|
|
4
|
+
export * as agents__format_scratchpad from "../agents/format_scratchpad.js";
|
|
4
5
|
export * as base_language from "../base_language/index.js";
|
|
5
6
|
export * as tools from "../tools/index.js";
|
|
6
7
|
export * as chains from "../chains/index.js";
|
package/dist/load/import_map.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export * as load__serializable from "../load/serializable.js";
|
|
3
3
|
export * as agents from "../agents/index.js";
|
|
4
4
|
export * as agents__toolkits from "../agents/toolkits/index.js";
|
|
5
|
+
export * as agents__format_scratchpad from "../agents/format_scratchpad.js";
|
|
5
6
|
export * as base_language from "../base_language/index.js";
|
|
6
7
|
export * as tools from "../tools/index.js";
|
|
7
8
|
export * as chains from "../chains/index.js";
|
package/dist/memory/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { BufferMemory, type BufferMemoryInput } from "./buffer_memory.js";
|
|
2
|
-
export { BaseMemory, getInputValue, getBufferString } from "./base.js";
|
|
2
|
+
export { BaseMemory, getInputValue, getBufferString, type InputValues, type OutputValues, type MemoryVariables, } from "./base.js";
|
|
3
3
|
export { ConversationSummaryMemory, type ConversationSummaryMemoryInput, BaseConversationSummaryMemory, type BaseConversationSummaryMemoryInput, } from "./summary.js";
|
|
4
4
|
export { BufferWindowMemory, type BufferWindowMemoryInput, } from "./buffer_window_memory.js";
|
|
5
5
|
export { BaseChatMemory, type BaseChatMemoryInput } from "./chat_memory.js";
|
package/dist/memory/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { BufferMemory } from "./buffer_memory.js";
|
|
2
|
-
export { BaseMemory, getInputValue, getBufferString } from "./base.js";
|
|
2
|
+
export { BaseMemory, getInputValue, getBufferString, } from "./base.js";
|
|
3
3
|
export { ConversationSummaryMemory, BaseConversationSummaryMemory, } from "./summary.js";
|
|
4
4
|
export { BufferWindowMemory, } from "./buffer_window_memory.js";
|
|
5
5
|
export { BaseChatMemory } from "./chat_memory.js";
|
|
@@ -84,6 +84,12 @@ class ParentDocumentRetriever extends multi_vector_js_1.MultiVectorRetriever {
|
|
|
84
84
|
writable: true,
|
|
85
85
|
value: void 0
|
|
86
86
|
});
|
|
87
|
+
Object.defineProperty(this, "childDocumentRetriever", {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
configurable: true,
|
|
90
|
+
writable: true,
|
|
91
|
+
value: void 0
|
|
92
|
+
});
|
|
87
93
|
this.vectorstore = fields.vectorstore;
|
|
88
94
|
this.docstore = fields.docstore;
|
|
89
95
|
this.childSplitter = fields.childSplitter;
|
|
@@ -91,9 +97,17 @@ class ParentDocumentRetriever extends multi_vector_js_1.MultiVectorRetriever {
|
|
|
91
97
|
this.idKey = fields.idKey ?? this.idKey;
|
|
92
98
|
this.childK = fields.childK;
|
|
93
99
|
this.parentK = fields.parentK;
|
|
100
|
+
this.childDocumentRetriever = fields.childDocumentRetriever;
|
|
94
101
|
}
|
|
95
102
|
async _getRelevantDocuments(query) {
|
|
96
|
-
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
|
+
let subDocs = [];
|
|
105
|
+
if (this.childDocumentRetriever) {
|
|
106
|
+
subDocs = await this.childDocumentRetriever.getRelevantDocuments(query);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
subDocs = await this.vectorstore.similaritySearch(query, this.childK);
|
|
110
|
+
}
|
|
97
111
|
// Maintain order
|
|
98
112
|
const parentDocIds = [];
|
|
99
113
|
for (const doc of subDocs) {
|
|
@@ -109,6 +123,7 @@ class ParentDocumentRetriever extends multi_vector_js_1.MultiVectorRetriever {
|
|
|
109
123
|
}
|
|
110
124
|
/**
|
|
111
125
|
* Adds documents to the docstore and vectorstores.
|
|
126
|
+
* If a retriever is provided, it will be used to add documents instead of the vectorstore.
|
|
112
127
|
* @param docs The documents to add
|
|
113
128
|
* @param config.ids Optional list of ids for documents. If provided should be the same
|
|
114
129
|
* length as the list of documents. Can provided if parent documents
|
|
@@ -150,7 +165,12 @@ class ParentDocumentRetriever extends multi_vector_js_1.MultiVectorRetriever {
|
|
|
150
165
|
embeddedDocs.push(...taggedSubDocs);
|
|
151
166
|
fullDocs[parentDocId] = parentDoc;
|
|
152
167
|
}
|
|
153
|
-
|
|
168
|
+
if (this.childDocumentRetriever) {
|
|
169
|
+
await this.childDocumentRetriever.addDocuments(embeddedDocs);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
await this.vectorstore.addDocuments(embeddedDocs);
|
|
173
|
+
}
|
|
154
174
|
if (addToDocstore) {
|
|
155
175
|
await this.docstore.mset(Object.entries(fullDocs));
|
|
156
176
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document } from "../document.js";
|
|
2
|
-
import { VectorStore } from "../vectorstores/base.js";
|
|
2
|
+
import { VectorStore, VectorStoreRetriever } from "../vectorstores/base.js";
|
|
3
3
|
import { TextSplitter } from "../text_splitter.js";
|
|
4
4
|
import { MultiVectorRetriever, type MultiVectorRetrieverInput } from "./multi_vector.js";
|
|
5
5
|
/**
|
|
@@ -9,6 +9,11 @@ import { MultiVectorRetriever, type MultiVectorRetrieverInput } from "./multi_ve
|
|
|
9
9
|
export type ParentDocumentRetrieverFields = MultiVectorRetrieverInput & {
|
|
10
10
|
childSplitter: TextSplitter;
|
|
11
11
|
parentSplitter?: TextSplitter;
|
|
12
|
+
/**
|
|
13
|
+
* A custom retriever to use when retrieving instead of
|
|
14
|
+
* the `.similaritySearch` method of the vectorstore.
|
|
15
|
+
*/
|
|
16
|
+
childDocumentRetriever?: VectorStoreRetriever<VectorStore>;
|
|
12
17
|
};
|
|
13
18
|
/**
|
|
14
19
|
* A type of document retriever that splits input documents into smaller chunks
|
|
@@ -28,10 +33,12 @@ export declare class ParentDocumentRetriever extends MultiVectorRetriever {
|
|
|
28
33
|
protected idKey: string;
|
|
29
34
|
protected childK?: number;
|
|
30
35
|
protected parentK?: number;
|
|
36
|
+
childDocumentRetriever: VectorStoreRetriever<VectorStore> | undefined;
|
|
31
37
|
constructor(fields: ParentDocumentRetrieverFields);
|
|
32
38
|
_getRelevantDocuments(query: string): Promise<Document[]>;
|
|
33
39
|
/**
|
|
34
40
|
* Adds documents to the docstore and vectorstores.
|
|
41
|
+
* If a retriever is provided, it will be used to add documents instead of the vectorstore.
|
|
35
42
|
* @param docs The documents to add
|
|
36
43
|
* @param config.ids Optional list of ids for documents. If provided should be the same
|
|
37
44
|
* length as the list of documents. Can provided if parent documents
|
|
@@ -58,6 +58,12 @@ export class ParentDocumentRetriever extends MultiVectorRetriever {
|
|
|
58
58
|
writable: true,
|
|
59
59
|
value: void 0
|
|
60
60
|
});
|
|
61
|
+
Object.defineProperty(this, "childDocumentRetriever", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
configurable: true,
|
|
64
|
+
writable: true,
|
|
65
|
+
value: void 0
|
|
66
|
+
});
|
|
61
67
|
this.vectorstore = fields.vectorstore;
|
|
62
68
|
this.docstore = fields.docstore;
|
|
63
69
|
this.childSplitter = fields.childSplitter;
|
|
@@ -65,9 +71,17 @@ export class ParentDocumentRetriever extends MultiVectorRetriever {
|
|
|
65
71
|
this.idKey = fields.idKey ?? this.idKey;
|
|
66
72
|
this.childK = fields.childK;
|
|
67
73
|
this.parentK = fields.parentK;
|
|
74
|
+
this.childDocumentRetriever = fields.childDocumentRetriever;
|
|
68
75
|
}
|
|
69
76
|
async _getRelevantDocuments(query) {
|
|
70
|
-
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
+
let subDocs = [];
|
|
79
|
+
if (this.childDocumentRetriever) {
|
|
80
|
+
subDocs = await this.childDocumentRetriever.getRelevantDocuments(query);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
subDocs = await this.vectorstore.similaritySearch(query, this.childK);
|
|
84
|
+
}
|
|
71
85
|
// Maintain order
|
|
72
86
|
const parentDocIds = [];
|
|
73
87
|
for (const doc of subDocs) {
|
|
@@ -83,6 +97,7 @@ export class ParentDocumentRetriever extends MultiVectorRetriever {
|
|
|
83
97
|
}
|
|
84
98
|
/**
|
|
85
99
|
* Adds documents to the docstore and vectorstores.
|
|
100
|
+
* If a retriever is provided, it will be used to add documents instead of the vectorstore.
|
|
86
101
|
* @param docs The documents to add
|
|
87
102
|
* @param config.ids Optional list of ids for documents. If provided should be the same
|
|
88
103
|
* length as the list of documents. Can provided if parent documents
|
|
@@ -124,7 +139,12 @@ export class ParentDocumentRetriever extends MultiVectorRetriever {
|
|
|
124
139
|
embeddedDocs.push(...taggedSubDocs);
|
|
125
140
|
fullDocs[parentDocId] = parentDoc;
|
|
126
141
|
}
|
|
127
|
-
|
|
142
|
+
if (this.childDocumentRetriever) {
|
|
143
|
+
await this.childDocumentRetriever.addDocuments(embeddedDocs);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
await this.vectorstore.addDocuments(embeddedDocs);
|
|
147
|
+
}
|
|
128
148
|
if (addToDocstore) {
|
|
129
149
|
await this.docstore.mset(Object.entries(fullDocs));
|
|
130
150
|
}
|
|
@@ -6,7 +6,7 @@ exports.LAST_ACCESSED_AT_KEY = "last_accessed_at";
|
|
|
6
6
|
exports.BUFFER_IDX = "buffer_idx";
|
|
7
7
|
/**
|
|
8
8
|
* TimeWeightedVectorStoreRetriever retrieves documents based on their time-weighted relevance.
|
|
9
|
-
* ref: https://github.com/
|
|
9
|
+
* ref: https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/retrievers/time_weighted_retriever.py
|
|
10
10
|
*/
|
|
11
11
|
class TimeWeightedVectorStoreRetriever extends retriever_js_1.BaseRetriever {
|
|
12
12
|
static lc_name() {
|
|
@@ -19,7 +19,7 @@ export declare const LAST_ACCESSED_AT_KEY = "last_accessed_at";
|
|
|
19
19
|
export declare const BUFFER_IDX = "buffer_idx";
|
|
20
20
|
/**
|
|
21
21
|
* TimeWeightedVectorStoreRetriever retrieves documents based on their time-weighted relevance.
|
|
22
|
-
* ref: https://github.com/
|
|
22
|
+
* ref: https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/retrievers/time_weighted_retriever.py
|
|
23
23
|
*/
|
|
24
24
|
export declare class TimeWeightedVectorStoreRetriever extends BaseRetriever {
|
|
25
25
|
static lc_name(): string;
|
|
@@ -3,7 +3,7 @@ export const LAST_ACCESSED_AT_KEY = "last_accessed_at";
|
|
|
3
3
|
export const BUFFER_IDX = "buffer_idx";
|
|
4
4
|
/**
|
|
5
5
|
* TimeWeightedVectorStoreRetriever retrieves documents based on their time-weighted relevance.
|
|
6
|
-
* ref: https://github.com/
|
|
6
|
+
* ref: https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/retrievers/time_weighted_retriever.py
|
|
7
7
|
*/
|
|
8
8
|
export class TimeWeightedVectorStoreRetriever extends BaseRetriever {
|
|
9
9
|
static lc_name() {
|
|
@@ -366,7 +366,7 @@ class Runnable extends serializable_js_1.Serializable {
|
|
|
366
366
|
}
|
|
367
367
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
368
368
|
static isRunnable(thing) {
|
|
369
|
-
return thing.lc_runnable;
|
|
369
|
+
return thing ? thing.lc_runnable : false;
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
exports.Runnable = Runnable;
|
|
@@ -844,6 +844,9 @@ class RunnableMap extends Runnable {
|
|
|
844
844
|
static lc_name() {
|
|
845
845
|
return "RunnableMap";
|
|
846
846
|
}
|
|
847
|
+
getStepsKeys() {
|
|
848
|
+
return Object.keys(this.steps);
|
|
849
|
+
}
|
|
847
850
|
constructor(fields) {
|
|
848
851
|
super(fields);
|
|
849
852
|
Object.defineProperty(this, "lc_namespace", {
|
|
@@ -289,6 +289,7 @@ export declare class RunnableMap<RunInput> extends Runnable<RunInput, Record<str
|
|
|
289
289
|
lc_namespace: string[];
|
|
290
290
|
lc_serializable: boolean;
|
|
291
291
|
protected steps: Record<string, Runnable<RunInput>>;
|
|
292
|
+
getStepsKeys(): string[];
|
|
292
293
|
constructor(fields: {
|
|
293
294
|
steps: Record<string, RunnableLike<RunInput>>;
|
|
294
295
|
});
|
|
@@ -360,7 +360,7 @@ export class Runnable extends Serializable {
|
|
|
360
360
|
}
|
|
361
361
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
362
362
|
static isRunnable(thing) {
|
|
363
|
-
return thing.lc_runnable;
|
|
363
|
+
return thing ? thing.lc_runnable : false;
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
/**
|
|
@@ -833,6 +833,9 @@ export class RunnableMap extends Runnable {
|
|
|
833
833
|
static lc_name() {
|
|
834
834
|
return "RunnableMap";
|
|
835
835
|
}
|
|
836
|
+
getStepsKeys() {
|
|
837
|
+
return Object.keys(this.steps);
|
|
838
|
+
}
|
|
836
839
|
constructor(fields) {
|
|
837
840
|
super(fields);
|
|
838
841
|
Object.defineProperty(this, "lc_namespace", {
|
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RunnablePassthrough = void 0;
|
|
3
|
+
exports.RunnablePassthrough = exports.RunnableAssign = void 0;
|
|
4
4
|
const base_js_1 = require("./base.cjs");
|
|
5
|
+
/**
|
|
6
|
+
* A runnable that assigns key-value pairs to inputs of type `Record<string, unknown>`.
|
|
7
|
+
*/
|
|
8
|
+
class RunnableAssign extends base_js_1.Runnable {
|
|
9
|
+
constructor(mapper) {
|
|
10
|
+
super();
|
|
11
|
+
Object.defineProperty(this, "lc_namespace", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: ["langchain", "schema", "runnable"]
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(this, "mapper", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
this.mapper = mapper;
|
|
24
|
+
}
|
|
25
|
+
async invoke(input, options) {
|
|
26
|
+
const mapperResult = await this.mapper.invoke(input, options);
|
|
27
|
+
return {
|
|
28
|
+
...input,
|
|
29
|
+
...mapperResult,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.RunnableAssign = RunnableAssign;
|
|
5
34
|
/**
|
|
6
35
|
* A runnable that passes through the input.
|
|
7
36
|
*/
|
|
@@ -27,5 +56,10 @@ class RunnablePassthrough extends base_js_1.Runnable {
|
|
|
27
56
|
async invoke(input, options) {
|
|
28
57
|
return this._callWithConfig((input) => Promise.resolve(input), input, options);
|
|
29
58
|
}
|
|
59
|
+
static assign(
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
+
mapping) {
|
|
62
|
+
return new RunnableAssign(new base_js_1.RunnableMap({ steps: mapping }));
|
|
63
|
+
}
|
|
30
64
|
}
|
|
31
65
|
exports.RunnablePassthrough = RunnablePassthrough;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import { Runnable } from "./base.js";
|
|
1
|
+
import { Runnable, RunnableLike, RunnableMap } from "./base.js";
|
|
2
2
|
import type { RunnableConfig } from "./config.js";
|
|
3
|
+
/**
|
|
4
|
+
* A runnable that assigns key-value pairs to inputs of type `Record<string, unknown>`.
|
|
5
|
+
*/
|
|
6
|
+
export declare class RunnableAssign<RunInput extends Record<string, any> = any, RunOutput extends Record<string, any> = any, CallOptions extends RunnableConfig = RunnableConfig> extends Runnable<RunInput, RunOutput> {
|
|
7
|
+
lc_namespace: string[];
|
|
8
|
+
mapper: RunnableMap<RunInput>;
|
|
9
|
+
constructor(mapper: RunnableMap<RunInput>);
|
|
10
|
+
invoke(input: RunInput, options?: Partial<CallOptions>): Promise<RunOutput>;
|
|
11
|
+
}
|
|
3
12
|
/**
|
|
4
13
|
* A runnable that passes through the input.
|
|
5
14
|
*/
|
|
@@ -8,4 +17,5 @@ export declare class RunnablePassthrough<RunInput> extends Runnable<RunInput, Ru
|
|
|
8
17
|
lc_namespace: string[];
|
|
9
18
|
lc_serializable: boolean;
|
|
10
19
|
invoke(input: RunInput, options?: Partial<RunnableConfig>): Promise<RunInput>;
|
|
20
|
+
static assign(mapping: Record<string, RunnableLike<Record<string, unknown>, any>>): RunnableAssign<Record<string, unknown>, Record<string, unknown>>;
|
|
11
21
|
}
|