langchain 0.0.76 → 0.0.77
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/chains/query_constructor/ir.cjs +1 -0
- package/chains/query_constructor/ir.d.ts +1 -0
- package/chains/query_constructor/ir.js +1 -0
- package/chains/query_constructor.cjs +1 -0
- package/chains/query_constructor.d.ts +1 -0
- package/chains/query_constructor.js +1 -0
- package/dist/agents/chat_convo/index.cjs +27 -11
- package/dist/agents/chat_convo/index.d.ts +4 -1
- package/dist/agents/chat_convo/index.js +28 -12
- package/dist/agents/chat_convo/outputParser.cjs +79 -7
- package/dist/agents/chat_convo/outputParser.d.ts +25 -13
- package/dist/agents/chat_convo/outputParser.js +77 -6
- package/dist/agents/chat_convo/prompt.cjs +11 -8
- package/dist/agents/chat_convo/prompt.d.ts +2 -2
- package/dist/agents/chat_convo/prompt.js +11 -8
- package/dist/callbacks/handlers/tracer_langchain.cjs +12 -4
- package/dist/callbacks/handlers/tracer_langchain.d.ts +4 -1
- package/dist/callbacks/handlers/tracer_langchain.js +12 -4
- package/dist/callbacks/manager.cjs +6 -2
- package/dist/callbacks/manager.js +6 -2
- package/dist/chains/query_constructor/index.cjs +105 -0
- package/dist/chains/query_constructor/index.d.ts +37 -0
- package/dist/chains/query_constructor/index.js +95 -0
- package/dist/chains/query_constructor/ir.cjs +116 -0
- package/dist/chains/query_constructor/ir.d.ts +60 -0
- package/dist/chains/query_constructor/ir.js +107 -0
- package/dist/chains/query_constructor/parser.cjs +103 -0
- package/dist/chains/query_constructor/parser.d.ts +12 -0
- package/dist/chains/query_constructor/parser.js +99 -0
- package/dist/chains/query_constructor/prompt.cjs +127 -0
- package/dist/chains/query_constructor/prompt.d.ts +15 -0
- package/dist/chains/query_constructor/prompt.js +124 -0
- package/dist/chains/sql_db/sql_db_chain.cjs +13 -0
- package/dist/chains/sql_db/sql_db_chain.d.ts +2 -0
- package/dist/chains/sql_db/sql_db_chain.js +13 -0
- package/dist/client/langchainplus.cjs +21 -15
- package/dist/client/langchainplus.d.ts +4 -2
- package/dist/client/langchainplus.js +21 -15
- package/dist/llms/sagemaker_endpoint.cjs +123 -0
- package/dist/llms/sagemaker_endpoint.d.ts +82 -0
- package/dist/llms/sagemaker_endpoint.js +118 -0
- package/dist/memory/buffer_memory.cjs +1 -1
- package/dist/memory/buffer_memory.js +1 -1
- package/dist/memory/buffer_window_memory.cjs +1 -1
- package/dist/memory/buffer_window_memory.js +1 -1
- package/dist/output_parsers/expression.cjs +68 -0
- package/dist/output_parsers/expression.d.ts +25 -0
- package/dist/output_parsers/expression.js +49 -0
- package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.cjs +26 -0
- package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.d.ts +7 -0
- package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.js +22 -0
- package/dist/output_parsers/expression_type_handlers/base.cjs +67 -0
- package/dist/output_parsers/expression_type_handlers/base.d.ts +23 -0
- package/dist/output_parsers/expression_type_handlers/base.js +62 -0
- package/dist/output_parsers/expression_type_handlers/boolean_literal_handler.cjs +24 -0
- package/dist/output_parsers/expression_type_handlers/boolean_literal_handler.d.ts +7 -0
- package/dist/output_parsers/expression_type_handlers/boolean_literal_handler.js +20 -0
- package/dist/output_parsers/expression_type_handlers/call_expression_handler.cjs +52 -0
- package/dist/output_parsers/expression_type_handlers/call_expression_handler.d.ts +7 -0
- package/dist/output_parsers/expression_type_handlers/call_expression_handler.js +48 -0
- package/dist/output_parsers/expression_type_handlers/factory.cjs +56 -0
- package/dist/output_parsers/expression_type_handlers/factory.d.ts +9 -0
- package/dist/output_parsers/expression_type_handlers/factory.js +52 -0
- package/dist/output_parsers/expression_type_handlers/identifier_handler.cjs +22 -0
- package/dist/output_parsers/expression_type_handlers/identifier_handler.d.ts +7 -0
- package/dist/output_parsers/expression_type_handlers/identifier_handler.js +18 -0
- package/dist/output_parsers/expression_type_handlers/member_expression_handler.cjs +45 -0
- package/dist/output_parsers/expression_type_handlers/member_expression_handler.d.ts +7 -0
- package/dist/output_parsers/expression_type_handlers/member_expression_handler.js +41 -0
- package/dist/output_parsers/expression_type_handlers/numeric_literal_handler.cjs +24 -0
- package/dist/output_parsers/expression_type_handlers/numeric_literal_handler.d.ts +7 -0
- package/dist/output_parsers/expression_type_handlers/numeric_literal_handler.js +20 -0
- package/dist/output_parsers/expression_type_handlers/object_literal_expression_handler.cjs +29 -0
- package/dist/output_parsers/expression_type_handlers/object_literal_expression_handler.d.ts +7 -0
- package/dist/output_parsers/expression_type_handlers/object_literal_expression_handler.js +25 -0
- package/dist/output_parsers/expression_type_handlers/property_assignment_handler.cjs +36 -0
- package/dist/output_parsers/expression_type_handlers/property_assignment_handler.d.ts +7 -0
- package/dist/output_parsers/expression_type_handlers/property_assignment_handler.js +32 -0
- package/dist/output_parsers/expression_type_handlers/string_literal_handler.cjs +22 -0
- package/dist/output_parsers/expression_type_handlers/string_literal_handler.d.ts +7 -0
- package/dist/output_parsers/expression_type_handlers/string_literal_handler.js +18 -0
- package/dist/output_parsers/expression_type_handlers/types.cjs +2 -0
- package/dist/output_parsers/expression_type_handlers/types.d.ts +41 -0
- package/dist/output_parsers/expression_type_handlers/types.js +1 -0
- package/dist/output_parsers/index.cjs +2 -1
- package/dist/output_parsers/index.d.ts +1 -1
- package/dist/output_parsers/index.js +1 -1
- package/dist/output_parsers/structured.cjs +81 -23
- package/dist/output_parsers/structured.d.ts +18 -0
- package/dist/output_parsers/structured.js +79 -22
- package/dist/retrievers/self_query/index.cjs +79 -0
- package/dist/retrievers/self_query/index.d.ts +33 -0
- package/dist/retrievers/self_query/index.js +74 -0
- package/dist/retrievers/self_query/translator.cjs +72 -0
- package/dist/retrievers/self_query/translator.d.ts +14 -0
- package/dist/retrievers/self_query/translator.js +67 -0
- package/dist/schema/query_constructor.cjs +26 -0
- package/dist/schema/query_constructor.d.ts +6 -0
- package/dist/schema/query_constructor.js +22 -0
- package/dist/tools/json.cjs +3 -1
- package/dist/tools/json.js +3 -1
- package/dist/util/event-source-parse.cjs +31 -5
- package/dist/util/event-source-parse.d.ts +3 -3
- package/dist/util/event-source-parse.js +31 -5
- package/llms/sagemaker_endpoint.cjs +1 -0
- package/llms/sagemaker_endpoint.d.ts +1 -0
- package/llms/sagemaker_endpoint.js +1 -0
- package/output_parsers/expression.cjs +1 -0
- package/output_parsers/expression.d.ts +1 -0
- package/output_parsers/expression.js +1 -0
- package/package.json +61 -3
- package/retrievers/self_query.cjs +1 -0
- package/retrievers/self_query.d.ts +1 -0
- package/retrievers/self_query.js +1 -0
- package/schema/query_constructor.cjs +1 -0
- package/schema/query_constructor.d.ts +1 -0
- package/schema/query_constructor.js +1 -0
|
@@ -13,9 +13,18 @@ export const EventStreamContentType = "text/event-stream";
|
|
|
13
13
|
*/
|
|
14
14
|
export async function getBytes(stream, onChunk) {
|
|
15
15
|
const reader = stream.getReader();
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
|
|
16
|
+
// CHANGED: Introduced a "flush" mechanism to process potential pending messages when the stream ends.
|
|
17
|
+
// This change is essential to ensure that we capture every last piece of information from streams,
|
|
18
|
+
// such as those from Azure OpenAI, which may not terminate with a blank line. Without this
|
|
19
|
+
// mechanism, we risk ignoring a possibly significant last message.
|
|
20
|
+
// See https://github.com/hwchase17/langchainjs/issues/1299 for details.
|
|
21
|
+
// eslint-disable-next-line no-constant-condition
|
|
22
|
+
while (true) {
|
|
23
|
+
const result = await reader.read();
|
|
24
|
+
if (result.done) {
|
|
25
|
+
onChunk(new Uint8Array(), true);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
19
28
|
onChunk(result.value);
|
|
20
29
|
}
|
|
21
30
|
}
|
|
@@ -31,7 +40,11 @@ export function getLines(onLine) {
|
|
|
31
40
|
let fieldLength; // length of the `field` portion of the line
|
|
32
41
|
let discardTrailingNewline = false;
|
|
33
42
|
// return a function that can process each incoming byte chunk:
|
|
34
|
-
return function onChunk(arr) {
|
|
43
|
+
return function onChunk(arr, flush) {
|
|
44
|
+
if (flush) {
|
|
45
|
+
onLine(arr, 0, true);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
35
48
|
if (buffer === undefined) {
|
|
36
49
|
buffer = arr;
|
|
37
50
|
position = 0;
|
|
@@ -102,7 +115,14 @@ export function getMessages(onMessage, onId, onRetry) {
|
|
|
102
115
|
let message = newMessage();
|
|
103
116
|
const decoder = new TextDecoder();
|
|
104
117
|
// return a function that can process each incoming line buffer:
|
|
105
|
-
return function onLine(line, fieldLength) {
|
|
118
|
+
return function onLine(line, fieldLength, flush) {
|
|
119
|
+
if (flush) {
|
|
120
|
+
if (!isEmpty(message)) {
|
|
121
|
+
onMessage?.(message);
|
|
122
|
+
message = newMessage();
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
106
126
|
if (line.length === 0) {
|
|
107
127
|
// empty line denotes end of message. Trigger the callback and start a new message:
|
|
108
128
|
onMessage?.(message);
|
|
@@ -157,3 +177,9 @@ function newMessage() {
|
|
|
157
177
|
retry: undefined,
|
|
158
178
|
};
|
|
159
179
|
}
|
|
180
|
+
function isEmpty(message) {
|
|
181
|
+
return (message.data === "" &&
|
|
182
|
+
message.event === "" &&
|
|
183
|
+
message.id === "" &&
|
|
184
|
+
message.retry === undefined);
|
|
185
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/llms/sagemaker_endpoint.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/llms/sagemaker_endpoint.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/llms/sagemaker_endpoint.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/output_parsers/expression.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/output_parsers/expression.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/output_parsers/expression.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langchain",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.77",
|
|
4
4
|
"description": "Typescript bindings for langchain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -37,6 +37,12 @@
|
|
|
37
37
|
"chains/load.cjs",
|
|
38
38
|
"chains/load.js",
|
|
39
39
|
"chains/load.d.ts",
|
|
40
|
+
"chains/query_constructor.cjs",
|
|
41
|
+
"chains/query_constructor.js",
|
|
42
|
+
"chains/query_constructor.d.ts",
|
|
43
|
+
"chains/query_constructor/ir.cjs",
|
|
44
|
+
"chains/query_constructor/ir.js",
|
|
45
|
+
"chains/query_constructor/ir.d.ts",
|
|
40
46
|
"embeddings.cjs",
|
|
41
47
|
"embeddings.js",
|
|
42
48
|
"embeddings.d.ts",
|
|
@@ -79,6 +85,9 @@
|
|
|
79
85
|
"llms/replicate.cjs",
|
|
80
86
|
"llms/replicate.js",
|
|
81
87
|
"llms/replicate.d.ts",
|
|
88
|
+
"llms/sagemaker_endpoint.cjs",
|
|
89
|
+
"llms/sagemaker_endpoint.js",
|
|
90
|
+
"llms/sagemaker_endpoint.d.ts",
|
|
82
91
|
"prompts.cjs",
|
|
83
92
|
"prompts.js",
|
|
84
93
|
"prompts.d.ts",
|
|
@@ -229,6 +238,9 @@
|
|
|
229
238
|
"schema/output_parser.cjs",
|
|
230
239
|
"schema/output_parser.js",
|
|
231
240
|
"schema/output_parser.d.ts",
|
|
241
|
+
"schema/query_constructor.cjs",
|
|
242
|
+
"schema/query_constructor.js",
|
|
243
|
+
"schema/query_constructor.d.ts",
|
|
232
244
|
"sql_db.cjs",
|
|
233
245
|
"sql_db.js",
|
|
234
246
|
"sql_db.d.ts",
|
|
@@ -238,6 +250,9 @@
|
|
|
238
250
|
"output_parsers.cjs",
|
|
239
251
|
"output_parsers.js",
|
|
240
252
|
"output_parsers.d.ts",
|
|
253
|
+
"output_parsers/expression.cjs",
|
|
254
|
+
"output_parsers/expression.js",
|
|
255
|
+
"output_parsers/expression.d.ts",
|
|
241
256
|
"retrievers.cjs",
|
|
242
257
|
"retrievers.js",
|
|
243
258
|
"retrievers.d.ts",
|
|
@@ -268,6 +283,9 @@
|
|
|
268
283
|
"retrievers/hyde.cjs",
|
|
269
284
|
"retrievers/hyde.js",
|
|
270
285
|
"retrievers/hyde.d.ts",
|
|
286
|
+
"retrievers/self_query.cjs",
|
|
287
|
+
"retrievers/self_query.js",
|
|
288
|
+
"retrievers/self_query.d.ts",
|
|
271
289
|
"cache.cjs",
|
|
272
290
|
"cache.js",
|
|
273
291
|
"cache.d.ts",
|
|
@@ -319,8 +337,8 @@
|
|
|
319
337
|
"release": "release-it --only-version --config .release-it.json",
|
|
320
338
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000",
|
|
321
339
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
|
|
322
|
-
"test:integration": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout
|
|
323
|
-
"test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout
|
|
340
|
+
"test:integration": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000",
|
|
341
|
+
"test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
|
|
324
342
|
"format": "prettier --write \"src\"",
|
|
325
343
|
"format:check": "prettier --check \"src\""
|
|
326
344
|
},
|
|
@@ -330,6 +348,7 @@
|
|
|
330
348
|
"@aws-sdk/client-dynamodb": "^3.310.0",
|
|
331
349
|
"@aws-sdk/client-lambda": "^3.310.0",
|
|
332
350
|
"@aws-sdk/client-s3": "^3.310.0",
|
|
351
|
+
"@aws-sdk/client-sagemaker-runtime": "^3.310.0",
|
|
333
352
|
"@clickhouse/client": "^0.0.14",
|
|
334
353
|
"@faker-js/faker": "^7.6.0",
|
|
335
354
|
"@getmetal/metal-sdk": "^2.0.1",
|
|
@@ -371,6 +390,7 @@
|
|
|
371
390
|
"html-to-text": "^9.0.5",
|
|
372
391
|
"jest": "^29.5.0",
|
|
373
392
|
"mammoth": "^1.5.1",
|
|
393
|
+
"meriyah": "^4.3.7",
|
|
374
394
|
"mongodb": "^5.2.0",
|
|
375
395
|
"pdf-parse": "1.1.1",
|
|
376
396
|
"playwright": "^1.32.1",
|
|
@@ -391,6 +411,7 @@
|
|
|
391
411
|
"@aws-sdk/client-dynamodb": "^3.310.0",
|
|
392
412
|
"@aws-sdk/client-lambda": "^3.310.0",
|
|
393
413
|
"@aws-sdk/client-s3": "^3.310.0",
|
|
414
|
+
"@aws-sdk/client-sagemaker-runtime": "^3.310.0",
|
|
394
415
|
"@clickhouse/client": "^0.0.14",
|
|
395
416
|
"@getmetal/metal-sdk": "*",
|
|
396
417
|
"@huggingface/inference": "^1.5.1",
|
|
@@ -411,6 +432,7 @@
|
|
|
411
432
|
"hnswlib-node": "^1.4.2",
|
|
412
433
|
"html-to-text": "^9.0.5",
|
|
413
434
|
"mammoth": "*",
|
|
435
|
+
"meriyah": "*",
|
|
414
436
|
"mongodb": "^5.2.0",
|
|
415
437
|
"pdf-parse": "1.1.1",
|
|
416
438
|
"playwright": "^1.32.1",
|
|
@@ -431,6 +453,9 @@
|
|
|
431
453
|
"@aws-sdk/client-s3": {
|
|
432
454
|
"optional": true
|
|
433
455
|
},
|
|
456
|
+
"@aws-sdk/client-sagemaker-runtime": {
|
|
457
|
+
"optional": true
|
|
458
|
+
},
|
|
434
459
|
"@clickhouse/client": {
|
|
435
460
|
"optional": true
|
|
436
461
|
},
|
|
@@ -491,6 +516,9 @@
|
|
|
491
516
|
"mammoth": {
|
|
492
517
|
"optional": true
|
|
493
518
|
},
|
|
519
|
+
"meriyah": {
|
|
520
|
+
"optional": true
|
|
521
|
+
},
|
|
494
522
|
"mongodb": {
|
|
495
523
|
"optional": true
|
|
496
524
|
},
|
|
@@ -605,6 +633,16 @@
|
|
|
605
633
|
"import": "./chains/load.js",
|
|
606
634
|
"require": "./chains/load.cjs"
|
|
607
635
|
},
|
|
636
|
+
"./chains/query_constructor": {
|
|
637
|
+
"types": "./chains/query_constructor.d.ts",
|
|
638
|
+
"import": "./chains/query_constructor.js",
|
|
639
|
+
"require": "./chains/query_constructor.cjs"
|
|
640
|
+
},
|
|
641
|
+
"./chains/query_constructor/ir": {
|
|
642
|
+
"types": "./chains/query_constructor/ir.d.ts",
|
|
643
|
+
"import": "./chains/query_constructor/ir.js",
|
|
644
|
+
"require": "./chains/query_constructor/ir.cjs"
|
|
645
|
+
},
|
|
608
646
|
"./embeddings": {
|
|
609
647
|
"node": {
|
|
610
648
|
"types": "./embeddings.d.ts",
|
|
@@ -679,6 +717,11 @@
|
|
|
679
717
|
"import": "./llms/replicate.js",
|
|
680
718
|
"require": "./llms/replicate.cjs"
|
|
681
719
|
},
|
|
720
|
+
"./llms/sagemaker_endpoint": {
|
|
721
|
+
"types": "./llms/sagemaker_endpoint.d.ts",
|
|
722
|
+
"import": "./llms/sagemaker_endpoint.js",
|
|
723
|
+
"require": "./llms/sagemaker_endpoint.cjs"
|
|
724
|
+
},
|
|
682
725
|
"./prompts": {
|
|
683
726
|
"types": "./prompts.d.ts",
|
|
684
727
|
"import": "./prompts.js",
|
|
@@ -935,6 +978,11 @@
|
|
|
935
978
|
"import": "./schema/output_parser.js",
|
|
936
979
|
"require": "./schema/output_parser.cjs"
|
|
937
980
|
},
|
|
981
|
+
"./schema/query_constructor": {
|
|
982
|
+
"types": "./schema/query_constructor.d.ts",
|
|
983
|
+
"import": "./schema/query_constructor.js",
|
|
984
|
+
"require": "./schema/query_constructor.cjs"
|
|
985
|
+
},
|
|
938
986
|
"./sql_db": {
|
|
939
987
|
"types": "./sql_db.d.ts",
|
|
940
988
|
"import": "./sql_db.js",
|
|
@@ -950,6 +998,11 @@
|
|
|
950
998
|
"import": "./output_parsers.js",
|
|
951
999
|
"require": "./output_parsers.cjs"
|
|
952
1000
|
},
|
|
1001
|
+
"./output_parsers/expression": {
|
|
1002
|
+
"types": "./output_parsers/expression.d.ts",
|
|
1003
|
+
"import": "./output_parsers/expression.js",
|
|
1004
|
+
"require": "./output_parsers/expression.cjs"
|
|
1005
|
+
},
|
|
953
1006
|
"./retrievers": {
|
|
954
1007
|
"node": {
|
|
955
1008
|
"types": "./retrievers.d.ts",
|
|
@@ -1002,6 +1055,11 @@
|
|
|
1002
1055
|
"import": "./retrievers/hyde.js",
|
|
1003
1056
|
"require": "./retrievers/hyde.cjs"
|
|
1004
1057
|
},
|
|
1058
|
+
"./retrievers/self_query": {
|
|
1059
|
+
"types": "./retrievers/self_query.d.ts",
|
|
1060
|
+
"import": "./retrievers/self_query.js",
|
|
1061
|
+
"require": "./retrievers/self_query.cjs"
|
|
1062
|
+
},
|
|
1005
1063
|
"./cache": {
|
|
1006
1064
|
"types": "./cache.d.ts",
|
|
1007
1065
|
"import": "./cache.js",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/retrievers/self_query/index.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/retrievers/self_query/index.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/retrievers/self_query/index.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/schema/query_constructor.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/schema/query_constructor.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/schema/query_constructor.js'
|