langchain 0.0.170 → 0.0.172
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/agents/format_scratchpad/log.cjs +1 -0
- package/agents/format_scratchpad/log.d.ts +1 -0
- package/agents/format_scratchpad/log.js +1 -0
- package/agents/format_scratchpad/log_to_message.cjs +1 -0
- package/agents/format_scratchpad/log_to_message.d.ts +1 -0
- package/agents/format_scratchpad/log_to_message.js +1 -0
- package/agents/format_scratchpad/xml.cjs +1 -0
- package/agents/format_scratchpad/xml.d.ts +1 -0
- package/agents/format_scratchpad/xml.js +1 -0
- package/agents/format_scratchpad.cjs +1 -1
- package/agents/format_scratchpad.d.ts +1 -1
- package/agents/format_scratchpad.js +1 -1
- package/agents/react/output_parser.cjs +1 -0
- package/agents/react/output_parser.d.ts +1 -0
- package/agents/react/output_parser.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/format_scratchpad/log.cjs +16 -0
- package/dist/agents/format_scratchpad/log.d.ts +9 -0
- package/dist/agents/format_scratchpad/log.js +12 -0
- package/dist/agents/format_scratchpad/log_to_message.cjs +22 -0
- package/dist/agents/format_scratchpad/log_to_message.d.ts +2 -0
- package/dist/agents/format_scratchpad/log_to_message.js +18 -0
- package/dist/agents/{format_scratchpad.cjs → format_scratchpad/openai_functions.cjs} +3 -3
- package/dist/agents/{format_scratchpad.d.ts → format_scratchpad/openai_functions.d.ts} +1 -1
- package/dist/agents/{format_scratchpad.js → format_scratchpad/openai_functions.js} +3 -3
- package/dist/agents/format_scratchpad/xml.cjs +12 -0
- package/dist/agents/format_scratchpad/xml.d.ts +2 -0
- package/dist/agents/format_scratchpad/xml.js +8 -0
- package/dist/agents/react/output_parser.cjs +96 -0
- package/dist/agents/react/output_parser.d.ts +47 -0
- package/dist/agents/react/output_parser.js +92 -0
- package/dist/agents/react/prompt.cjs +13 -0
- package/dist/agents/react/prompt.d.ts +1 -0
- package/dist/agents/react/prompt.js +10 -0
- package/dist/agents/toolkits/openapi/openapi.cjs +1 -1
- package/dist/agents/toolkits/openapi/openapi.d.ts +1 -1
- package/dist/agents/toolkits/openapi/openapi.js +1 -1
- package/dist/chains/sql_db/sql_db_chain.cjs +2 -0
- package/dist/chains/sql_db/sql_db_chain.d.ts +2 -0
- package/dist/chains/sql_db/sql_db_chain.js +2 -0
- 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/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/embeddings/openai.cjs +11 -0
- package/dist/embeddings/openai.d.ts +2 -0
- package/dist/embeddings/openai.js +11 -0
- 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 +8 -3
- package/dist/load/import_map.d.ts +6 -1
- package/dist/load/import_map.js +6 -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/schema/runnable/passthrough.cjs +3 -1
- package/dist/schema/runnable/passthrough.js +3 -1
- package/dist/sql_db.cjs +2 -0
- package/dist/sql_db.d.ts +2 -0
- package/dist/sql_db.js +2 -0
- package/dist/storage/file_system.cjs +147 -0
- package/dist/storage/file_system.d.ts +60 -0
- package/dist/storage/file_system.js +140 -0
- package/dist/tools/render.cjs +18 -0
- package/dist/tools/render.d.ts +13 -0
- package/dist/tools/render.js +14 -0
- package/dist/util/stream.cjs +3 -0
- package/dist/util/stream.js +3 -0
- package/dist/vectorstores/analyticdb.cjs +7 -3
- package/dist/vectorstores/analyticdb.d.ts +1 -1
- package/dist/vectorstores/analyticdb.js +7 -3
- 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/qdrant.cjs +19 -11
- package/dist/vectorstores/qdrant.d.ts +1 -1
- package/dist/vectorstores/qdrant.js +19 -11
- package/dist/vectorstores/redis.cjs +4 -1
- package/dist/vectorstores/redis.d.ts +1 -1
- package/dist/vectorstores/redis.js +4 -1
- package/package.json +63 -7
- package/storage/file_system.cjs +1 -0
- package/storage/file_system.d.ts +1 -0
- package/storage/file_system.js +1 -0
- package/tools/render.cjs +1 -0
- package/tools/render.d.ts +1 -0
- package/tools/render.js +1 -0
|
@@ -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
|
+
}
|
|
@@ -70,6 +70,12 @@ class OpenAIEmbeddings extends base_js_1.Embeddings {
|
|
|
70
70
|
writable: true,
|
|
71
71
|
value: void 0
|
|
72
72
|
});
|
|
73
|
+
Object.defineProperty(this, "organization", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
configurable: true,
|
|
76
|
+
writable: true,
|
|
77
|
+
value: void 0
|
|
78
|
+
});
|
|
73
79
|
Object.defineProperty(this, "client", {
|
|
74
80
|
enumerable: true,
|
|
75
81
|
configurable: true,
|
|
@@ -100,6 +106,9 @@ class OpenAIEmbeddings extends base_js_1.Embeddings {
|
|
|
100
106
|
this.azureOpenAIBasePath =
|
|
101
107
|
fieldsWithDefaults?.azureOpenAIBasePath ??
|
|
102
108
|
(0, env_js_1.getEnvironmentVariable)("AZURE_OPENAI_BASE_PATH");
|
|
109
|
+
this.organization =
|
|
110
|
+
fieldsWithDefaults?.configuration?.organization ??
|
|
111
|
+
(0, env_js_1.getEnvironmentVariable)("OPENAI_ORGANIZATION");
|
|
103
112
|
this.modelName = fieldsWithDefaults?.modelName ?? this.modelName;
|
|
104
113
|
this.batchSize =
|
|
105
114
|
fieldsWithDefaults?.batchSize ?? (azureApiKey ? 1 : this.batchSize);
|
|
@@ -124,11 +133,13 @@ class OpenAIEmbeddings extends base_js_1.Embeddings {
|
|
|
124
133
|
}
|
|
125
134
|
this.clientConfig = {
|
|
126
135
|
apiKey,
|
|
136
|
+
organization: this.organization,
|
|
127
137
|
baseURL: configuration?.basePath,
|
|
128
138
|
dangerouslyAllowBrowser: true,
|
|
129
139
|
defaultHeaders: configuration?.baseOptions?.headers,
|
|
130
140
|
defaultQuery: configuration?.baseOptions?.params,
|
|
131
141
|
...configuration,
|
|
142
|
+
...fields?.configuration,
|
|
132
143
|
};
|
|
133
144
|
}
|
|
134
145
|
/**
|
|
@@ -38,11 +38,13 @@ export declare class OpenAIEmbeddings extends Embeddings implements OpenAIEmbedd
|
|
|
38
38
|
azureOpenAIApiInstanceName?: string;
|
|
39
39
|
azureOpenAIApiDeploymentName?: string;
|
|
40
40
|
azureOpenAIBasePath?: string;
|
|
41
|
+
organization?: string;
|
|
41
42
|
private client;
|
|
42
43
|
private clientConfig;
|
|
43
44
|
constructor(fields?: Partial<OpenAIEmbeddingsParams> & Partial<AzureOpenAIInput> & {
|
|
44
45
|
verbose?: boolean;
|
|
45
46
|
openAIApiKey?: string;
|
|
47
|
+
configuration?: ClientOptions;
|
|
46
48
|
}, configuration?: ClientOptions & LegacyOpenAIInput);
|
|
47
49
|
/**
|
|
48
50
|
* Method to generate embeddings for an array of documents. Splits the
|
|
@@ -67,6 +67,12 @@ export class OpenAIEmbeddings extends Embeddings {
|
|
|
67
67
|
writable: true,
|
|
68
68
|
value: void 0
|
|
69
69
|
});
|
|
70
|
+
Object.defineProperty(this, "organization", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
configurable: true,
|
|
73
|
+
writable: true,
|
|
74
|
+
value: void 0
|
|
75
|
+
});
|
|
70
76
|
Object.defineProperty(this, "client", {
|
|
71
77
|
enumerable: true,
|
|
72
78
|
configurable: true,
|
|
@@ -97,6 +103,9 @@ export class OpenAIEmbeddings extends Embeddings {
|
|
|
97
103
|
this.azureOpenAIBasePath =
|
|
98
104
|
fieldsWithDefaults?.azureOpenAIBasePath ??
|
|
99
105
|
getEnvironmentVariable("AZURE_OPENAI_BASE_PATH");
|
|
106
|
+
this.organization =
|
|
107
|
+
fieldsWithDefaults?.configuration?.organization ??
|
|
108
|
+
getEnvironmentVariable("OPENAI_ORGANIZATION");
|
|
100
109
|
this.modelName = fieldsWithDefaults?.modelName ?? this.modelName;
|
|
101
110
|
this.batchSize =
|
|
102
111
|
fieldsWithDefaults?.batchSize ?? (azureApiKey ? 1 : this.batchSize);
|
|
@@ -121,11 +130,13 @@ export class OpenAIEmbeddings extends Embeddings {
|
|
|
121
130
|
}
|
|
122
131
|
this.clientConfig = {
|
|
123
132
|
apiKey,
|
|
133
|
+
organization: this.organization,
|
|
124
134
|
baseURL: configuration?.basePath,
|
|
125
135
|
dangerouslyAllowBrowser: true,
|
|
126
136
|
defaultHeaders: configuration?.baseOptions?.headers,
|
|
127
137
|
defaultQuery: configuration?.baseOptions?.params,
|
|
128
138
|
...configuration,
|
|
139
|
+
...fields?.configuration,
|
|
129
140
|
};
|
|
130
141
|
}
|
|
131
142
|
/**
|
|
@@ -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",
|
|
@@ -145,6 +146,7 @@ exports.optionalImportEntrypoints = [
|
|
|
145
146
|
"langchain/storage/ioredis",
|
|
146
147
|
"langchain/storage/vercel_kv",
|
|
147
148
|
"langchain/storage/upstash_redis",
|
|
149
|
+
"langchain/storage/file_system",
|
|
148
150
|
"langchain/graphs/neo4j_graph",
|
|
149
151
|
"langchain/hub",
|
|
150
152
|
"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",
|
|
@@ -142,6 +143,7 @@ export const optionalImportEntrypoints = [
|
|
|
142
143
|
"langchain/storage/ioredis",
|
|
143
144
|
"langchain/storage/vercel_kv",
|
|
144
145
|
"langchain/storage/upstash_redis",
|
|
146
|
+
"langchain/storage/file_system",
|
|
145
147
|
"langchain/graphs/neo4j_graph",
|
|
146
148
|
"langchain/hub",
|
|
147
149
|
"langchain/experimental/multimodal_embeddings/googlevertexai",
|
package/dist/load/import_map.cjs
CHANGED
|
@@ -24,14 +24,19 @@ 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 = exports.schema__query_constructor = void 0;
|
|
27
|
+
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__render = exports.tools = exports.base_language = exports.agents__react__output_parser = exports.agents__format_scratchpad__log_to_message = exports.agents__format_scratchpad__xml = exports.agents__format_scratchpad__log = 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 = exports.schema__output_parser = exports.schema__document = exports.schema = exports.chat_models__fake = exports.chat_models__yandex = 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
|
+
exports.agents__format_scratchpad = __importStar(require("../agents/format_scratchpad/openai_functions.cjs"));
|
|
33
|
+
exports.agents__format_scratchpad__log = __importStar(require("../agents/format_scratchpad/log.cjs"));
|
|
34
|
+
exports.agents__format_scratchpad__xml = __importStar(require("../agents/format_scratchpad/xml.cjs"));
|
|
35
|
+
exports.agents__format_scratchpad__log_to_message = __importStar(require("../agents/format_scratchpad/log_to_message.cjs"));
|
|
36
|
+
exports.agents__react__output_parser = __importStar(require("../agents/react/output_parser.cjs"));
|
|
33
37
|
exports.base_language = __importStar(require("../base_language/index.cjs"));
|
|
34
38
|
exports.tools = __importStar(require("../tools/index.cjs"));
|
|
39
|
+
exports.tools__render = __importStar(require("../tools/render.cjs"));
|
|
35
40
|
exports.chains = __importStar(require("../chains/index.cjs"));
|
|
36
41
|
exports.chains__openai_functions = __importStar(require("../chains/openai_functions/index.cjs"));
|
|
37
42
|
exports.embeddings__base = __importStar(require("../embeddings/base.cjs"));
|
|
@@ -1,9 +1,14 @@
|
|
|
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
|
+
export * as agents__format_scratchpad from "../agents/format_scratchpad/openai_functions.js";
|
|
5
|
+
export * as agents__format_scratchpad__log from "../agents/format_scratchpad/log.js";
|
|
6
|
+
export * as agents__format_scratchpad__xml from "../agents/format_scratchpad/xml.js";
|
|
7
|
+
export * as agents__format_scratchpad__log_to_message from "../agents/format_scratchpad/log_to_message.js";
|
|
8
|
+
export * as agents__react__output_parser from "../agents/react/output_parser.js";
|
|
5
9
|
export * as base_language from "../base_language/index.js";
|
|
6
10
|
export * as tools from "../tools/index.js";
|
|
11
|
+
export * as tools__render from "../tools/render.js";
|
|
7
12
|
export * as chains from "../chains/index.js";
|
|
8
13
|
export * as chains__openai_functions from "../chains/openai_functions/index.js";
|
|
9
14
|
export * as embeddings__base from "../embeddings/base.js";
|
package/dist/load/import_map.js
CHANGED
|
@@ -2,9 +2,14 @@
|
|
|
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
|
+
export * as agents__format_scratchpad from "../agents/format_scratchpad/openai_functions.js";
|
|
6
|
+
export * as agents__format_scratchpad__log from "../agents/format_scratchpad/log.js";
|
|
7
|
+
export * as agents__format_scratchpad__xml from "../agents/format_scratchpad/xml.js";
|
|
8
|
+
export * as agents__format_scratchpad__log_to_message from "../agents/format_scratchpad/log_to_message.js";
|
|
9
|
+
export * as agents__react__output_parser from "../agents/react/output_parser.js";
|
|
6
10
|
export * as base_language from "../base_language/index.js";
|
|
7
11
|
export * as tools from "../tools/index.js";
|
|
12
|
+
export * as tools__render from "../tools/render.js";
|
|
8
13
|
export * as chains from "../chains/index.js";
|
|
9
14
|
export * as chains__openai_functions from "../chains/openai_functions/index.js";
|
|
10
15
|
export * as embeddings__base from "../embeddings/base.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
|
}
|
|
@@ -56,7 +56,9 @@ class RunnablePassthrough extends base_js_1.Runnable {
|
|
|
56
56
|
async invoke(input, options) {
|
|
57
57
|
return this._callWithConfig((input) => Promise.resolve(input), input, options);
|
|
58
58
|
}
|
|
59
|
-
static assign(
|
|
59
|
+
static assign(
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
+
mapping) {
|
|
60
62
|
return new RunnableAssign(new base_js_1.RunnableMap({ steps: mapping }));
|
|
61
63
|
}
|
|
62
64
|
}
|
|
@@ -52,7 +52,9 @@ export class RunnablePassthrough extends Runnable {
|
|
|
52
52
|
async invoke(input, options) {
|
|
53
53
|
return this._callWithConfig((input) => Promise.resolve(input), input, options);
|
|
54
54
|
}
|
|
55
|
-
static assign(
|
|
55
|
+
static assign(
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
mapping) {
|
|
56
58
|
return new RunnableAssign(new RunnableMap({ steps: mapping }));
|
|
57
59
|
}
|
|
58
60
|
}
|
package/dist/sql_db.cjs
CHANGED
|
@@ -14,6 +14,8 @@ const serializable_js_1 = require("./load/serializable.cjs");
|
|
|
14
14
|
* to read and scope to the tables that are needed.
|
|
15
15
|
* Optionally, use the includesTables or ignoreTables class parameters
|
|
16
16
|
* to limit which tables can/cannot be accessed.
|
|
17
|
+
*
|
|
18
|
+
* @link See https://js.langchain.com/docs/security for more information.
|
|
17
19
|
*/
|
|
18
20
|
class SqlDatabase extends serializable_js_1.Serializable {
|
|
19
21
|
toJSON() {
|
package/dist/sql_db.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export type { SqlDatabaseDataSourceParams, SqlDatabaseOptionsParams };
|
|
|
13
13
|
* to read and scope to the tables that are needed.
|
|
14
14
|
* Optionally, use the includesTables or ignoreTables class parameters
|
|
15
15
|
* to limit which tables can/cannot be accessed.
|
|
16
|
+
*
|
|
17
|
+
* @link See https://js.langchain.com/docs/security for more information.
|
|
16
18
|
*/
|
|
17
19
|
export declare class SqlDatabase extends Serializable implements SqlDatabaseOptionsParams, SqlDatabaseDataSourceParams {
|
|
18
20
|
lc_namespace: string[];
|
package/dist/sql_db.js
CHANGED
|
@@ -11,6 +11,8 @@ import { Serializable } from "./load/serializable.js";
|
|
|
11
11
|
* to read and scope to the tables that are needed.
|
|
12
12
|
* Optionally, use the includesTables or ignoreTables class parameters
|
|
13
13
|
* to limit which tables can/cannot be accessed.
|
|
14
|
+
*
|
|
15
|
+
* @link See https://js.langchain.com/docs/security for more information.
|
|
14
16
|
*/
|
|
15
17
|
export class SqlDatabase extends Serializable {
|
|
16
18
|
toJSON() {
|