langchain 0.0.133 → 0.0.135

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.
Files changed (70) hide show
  1. package/dist/agents/chat_convo/outputParser.cjs +13 -10
  2. package/dist/agents/chat_convo/outputParser.js +13 -10
  3. package/dist/callbacks/base.d.ts +6 -3
  4. package/dist/callbacks/handlers/tracer.cjs +2 -2
  5. package/dist/callbacks/handlers/tracer.d.ts +2 -2
  6. package/dist/callbacks/handlers/tracer.js +2 -2
  7. package/dist/callbacks/index.cjs +2 -1
  8. package/dist/callbacks/index.d.ts +1 -1
  9. package/dist/callbacks/index.js +1 -1
  10. package/dist/callbacks/manager.cjs +2 -2
  11. package/dist/callbacks/manager.d.ts +2 -2
  12. package/dist/callbacks/manager.js +2 -2
  13. package/dist/chains/sql_db/sql_db_chain.d.ts +1 -1
  14. package/dist/chains/sql_db/sql_db_prompt.d.ts +6 -6
  15. package/dist/chat_models/openai.cjs +10 -5
  16. package/dist/chat_models/openai.js +10 -5
  17. package/dist/document_loaders/web/recursive_url.cjs +177 -0
  18. package/dist/document_loaders/web/recursive_url.d.ts +27 -0
  19. package/dist/document_loaders/web/recursive_url.js +173 -0
  20. package/dist/hub.cjs +16 -0
  21. package/dist/hub.d.ts +4 -0
  22. package/dist/hub.js +11 -0
  23. package/dist/llms/bedrock.cjs +63 -19
  24. package/dist/llms/bedrock.d.ts +9 -1
  25. package/dist/llms/bedrock.js +63 -19
  26. package/dist/llms/writer.cjs +167 -0
  27. package/dist/llms/writer.d.ts +60 -0
  28. package/dist/llms/writer.js +163 -0
  29. package/dist/load/import_constants.cjs +4 -0
  30. package/dist/load/import_constants.js +4 -0
  31. package/dist/load/import_map.cjs +2 -1
  32. package/dist/load/import_map.d.ts +1 -0
  33. package/dist/load/import_map.js +1 -0
  34. package/dist/memory/summary_buffer.d.ts +1 -1
  35. package/dist/retrievers/score_threshold.cjs +45 -0
  36. package/dist/retrievers/score_threshold.d.ts +15 -0
  37. package/dist/retrievers/score_threshold.js +41 -0
  38. package/dist/sql_db.cjs +8 -1
  39. package/dist/sql_db.d.ts +1 -0
  40. package/dist/sql_db.js +8 -1
  41. package/dist/stores/message/mongodb.cjs +48 -0
  42. package/dist/stores/message/mongodb.d.ts +15 -0
  43. package/dist/stores/message/mongodb.js +44 -0
  44. package/dist/tools/sql.cjs +9 -3
  45. package/dist/tools/sql.d.ts +0 -1
  46. package/dist/tools/sql.js +9 -3
  47. package/dist/util/sql_utils.cjs +8 -2
  48. package/dist/util/sql_utils.d.ts +2 -1
  49. package/dist/util/sql_utils.js +8 -2
  50. package/dist/vectorstores/googlevertexai.cjs +2 -1
  51. package/dist/vectorstores/googlevertexai.js +2 -1
  52. package/dist/vectorstores/myscale.cjs +2 -2
  53. package/dist/vectorstores/myscale.d.ts +1 -1
  54. package/dist/vectorstores/myscale.js +2 -2
  55. package/document_loaders/web/recursive_url.cjs +1 -0
  56. package/document_loaders/web/recursive_url.d.ts +1 -0
  57. package/document_loaders/web/recursive_url.js +1 -0
  58. package/hub.cjs +1 -0
  59. package/hub.d.ts +1 -0
  60. package/hub.js +1 -0
  61. package/llms/writer.cjs +1 -0
  62. package/llms/writer.d.ts +1 -0
  63. package/llms/writer.js +1 -0
  64. package/package.json +61 -1
  65. package/retrievers/score_threshold.cjs +1 -0
  66. package/retrievers/score_threshold.d.ts +1 -0
  67. package/retrievers/score_threshold.js +1 -0
  68. package/stores/message/mongodb.cjs +1 -0
  69. package/stores/message/mongodb.d.ts +1 -0
  70. package/stores/message/mongodb.js +1 -0
package/dist/tools/sql.js CHANGED
@@ -121,14 +121,20 @@ export class ListTablesSqlTool extends Tool {
121
121
  enumerable: true,
122
122
  configurable: true,
123
123
  writable: true,
124
- value: `Input is an empty string, output is a comma separated list of tables in the database.`
124
+ value: `Input is an empty string, output is a comma-separated list of tables in the database.`
125
125
  });
126
126
  this.db = db;
127
127
  }
128
- /** @ignore */
129
128
  async _call(_) {
130
129
  try {
131
- const tables = this.db.allTables.map((table) => table.tableName);
130
+ let selectedTables = this.db.allTables;
131
+ if (this.db.includesTables.length > 0) {
132
+ selectedTables = selectedTables.filter((currentTable) => this.db.includesTables.includes(currentTable.tableName));
133
+ }
134
+ if (this.db.ignoreTables.length > 0) {
135
+ selectedTables = selectedTables.filter((currentTable) => !this.db.ignoreTables.includes(currentTable.tableName));
136
+ }
137
+ const tables = selectedTables.map((table) => table.tableName);
132
138
  return tables.join(", ");
133
139
  }
134
140
  catch (error) {
@@ -139,12 +139,17 @@ const formatSqlResponseToSimpleTableString = (rawResult) => {
139
139
  }
140
140
  return globalString;
141
141
  };
142
- const generateTableInfoFromTables = async (tables, appDataSource, nbSampleRow) => {
142
+ const generateTableInfoFromTables = async (tables, appDataSource, nbSampleRow, customDescription) => {
143
143
  if (!tables) {
144
144
  return "";
145
145
  }
146
146
  let globalString = "";
147
147
  for (const currentTable of tables) {
148
+ // Add the custom info of the table
149
+ const tableCustomDescription = customDescription &&
150
+ Object.keys(customDescription).includes(currentTable.tableName)
151
+ ? `${customDescription[currentTable.tableName]}\n`
152
+ : "";
148
153
  // Add the creation of the table in SQL
149
154
  let schema = null;
150
155
  if (appDataSource.options.type === "postgres") {
@@ -199,7 +204,8 @@ const generateTableInfoFromTables = async (tables, appDataSource, nbSampleRow) =
199
204
  // If the request fails we catch it and only display a log message
200
205
  console.log(error);
201
206
  }
202
- globalString = globalString.concat(sqlCreateTableQuery +
207
+ globalString = globalString.concat(tableCustomDescription +
208
+ sqlCreateTableQuery +
203
209
  sqlSelectInfoQuery +
204
210
  columnNamesConcatString +
205
211
  sample);
@@ -4,6 +4,7 @@ export interface SqlDatabaseParams {
4
4
  includesTables?: Array<string>;
5
5
  ignoreTables?: Array<string>;
6
6
  sampleRowsInTableInfo?: number;
7
+ customDescription?: Record<string, string>;
7
8
  }
8
9
  export interface SqlDatabaseOptionsParams extends SqlDatabaseParams {
9
10
  appDataSourceOptions: DataSourceOptions;
@@ -27,5 +28,5 @@ export declare const verifyListTablesExistInDatabase: (tablesFromDatabase: Array
27
28
  export declare const verifyIncludeTablesExistInDatabase: (tablesFromDatabase: Array<SqlTable>, includeTables: Array<string>) => void;
28
29
  export declare const verifyIgnoreTablesExistInDatabase: (tablesFromDatabase: Array<SqlTable>, ignoreTables: Array<string>) => void;
29
30
  export declare const getTableAndColumnsName: (appDataSource: DataSource) => Promise<Array<SqlTable>>;
30
- export declare const generateTableInfoFromTables: (tables: Array<SqlTable> | undefined, appDataSource: DataSource, nbSampleRow: number) => Promise<string>;
31
+ export declare const generateTableInfoFromTables: (tables: Array<SqlTable> | undefined, appDataSource: DataSource, nbSampleRow: number, customDescription?: Record<string, string>) => Promise<string>;
31
32
  export declare const getPromptTemplateFromDataSource: (appDataSource: DataSource) => PromptTemplate;
@@ -132,12 +132,17 @@ const formatSqlResponseToSimpleTableString = (rawResult) => {
132
132
  }
133
133
  return globalString;
134
134
  };
135
- export const generateTableInfoFromTables = async (tables, appDataSource, nbSampleRow) => {
135
+ export const generateTableInfoFromTables = async (tables, appDataSource, nbSampleRow, customDescription) => {
136
136
  if (!tables) {
137
137
  return "";
138
138
  }
139
139
  let globalString = "";
140
140
  for (const currentTable of tables) {
141
+ // Add the custom info of the table
142
+ const tableCustomDescription = customDescription &&
143
+ Object.keys(customDescription).includes(currentTable.tableName)
144
+ ? `${customDescription[currentTable.tableName]}\n`
145
+ : "";
141
146
  // Add the creation of the table in SQL
142
147
  let schema = null;
143
148
  if (appDataSource.options.type === "postgres") {
@@ -192,7 +197,8 @@ export const generateTableInfoFromTables = async (tables, appDataSource, nbSampl
192
197
  // If the request fails we catch it and only display a log message
193
198
  console.log(error);
194
199
  }
195
- globalString = globalString.concat(sqlCreateTableQuery +
200
+ globalString = globalString.concat(tableCustomDescription +
201
+ sqlCreateTableQuery +
196
202
  sqlSelectInfoQuery +
197
203
  columnNamesConcatString +
198
204
  sample);
@@ -373,8 +373,9 @@ class MatchingEngine extends base_js_1.VectorStore {
373
373
  * @param documentMetadata - The metadata from a document
374
374
  * @returns a Restriction[] (or an array of a subclass, from the FilterType)
375
375
  */
376
+ metadataToRestrictions(
376
377
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
377
- metadataToRestrictions(documentMetadata) {
378
+ documentMetadata) {
378
379
  const metadata = this.cleanMetadata(documentMetadata);
379
380
  const restrictions = [];
380
381
  for (const key of Object.keys(metadata)) {
@@ -343,8 +343,9 @@ export class MatchingEngine extends VectorStore {
343
343
  * @param documentMetadata - The metadata from a document
344
344
  * @returns a Restriction[] (or an array of a subclass, from the FilterType)
345
345
  */
346
+ metadataToRestrictions(
346
347
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
347
- metadataToRestrictions(documentMetadata) {
348
+ documentMetadata) {
348
349
  const metadata = this.cleanMetadata(documentMetadata);
349
350
  const restrictions = [];
350
351
  for (const key of Object.keys(metadata)) {
@@ -98,7 +98,7 @@ class MyScaleStore extends base_js_1.VectorStore {
98
98
  };
99
99
  this.database = args.database || "default";
100
100
  this.table = args.table || "vector_table";
101
- this.metric = args.metric || "cosine";
101
+ this.metric = args.metric || "Cosine";
102
102
  this.client = (0, client_1.createClient)({
103
103
  host: `${args.protocol ?? "https://"}${args.host}:${args.port}`,
104
104
  username: args.username,
@@ -263,7 +263,7 @@ class MyScaleStore extends base_js_1.VectorStore {
263
263
  * @returns The SQL query string.
264
264
  */
265
265
  buildSearchQuery(query, k, filter) {
266
- const order = this.metric === "ip" ? "DESC" : "ASC";
266
+ const order = this.metric === "IP" ? "DESC" : "ASC";
267
267
  const whereStr = filter ? `PREWHERE ${filter.whereStr}` : "";
268
268
  return `
269
269
  SELECT ${this.columnMap.text} AS text, ${this.columnMap.metadata} AS metadata, dist
@@ -31,7 +31,7 @@ export interface ColumnMap {
31
31
  /**
32
32
  * Type of metric used in the MyScale database.
33
33
  */
34
- export type metric = "ip" | "cosine" | "l2";
34
+ export type metric = "L2" | "Cosine" | "IP";
35
35
  /**
36
36
  * Type for filtering search results in the MyScale database.
37
37
  */
@@ -72,7 +72,7 @@ export class MyScaleStore extends VectorStore {
72
72
  };
73
73
  this.database = args.database || "default";
74
74
  this.table = args.table || "vector_table";
75
- this.metric = args.metric || "cosine";
75
+ this.metric = args.metric || "Cosine";
76
76
  this.client = createClient({
77
77
  host: `${args.protocol ?? "https://"}${args.host}:${args.port}`,
78
78
  username: args.username,
@@ -237,7 +237,7 @@ export class MyScaleStore extends VectorStore {
237
237
  * @returns The SQL query string.
238
238
  */
239
239
  buildSearchQuery(query, k, filter) {
240
- const order = this.metric === "ip" ? "DESC" : "ASC";
240
+ const order = this.metric === "IP" ? "DESC" : "ASC";
241
241
  const whereStr = filter ? `PREWHERE ${filter.whereStr}` : "";
242
242
  return `
243
243
  SELECT ${this.columnMap.text} AS text, ${this.columnMap.metadata} AS metadata, dist
@@ -0,0 +1 @@
1
+ module.exports = require('../../dist/document_loaders/web/recursive_url.cjs');
@@ -0,0 +1 @@
1
+ export * from '../../dist/document_loaders/web/recursive_url.js'
@@ -0,0 +1 @@
1
+ export * from '../../dist/document_loaders/web/recursive_url.js'
package/hub.cjs ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/hub.cjs');
package/hub.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/hub.js'
package/hub.js ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/hub.js'
@@ -0,0 +1 @@
1
+ module.exports = require('../dist/llms/writer.cjs');
@@ -0,0 +1 @@
1
+ export * from '../dist/llms/writer.js'
package/llms/writer.js ADDED
@@ -0,0 +1 @@
1
+ export * from '../dist/llms/writer.js'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "0.0.133",
3
+ "version": "0.0.135",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "type": "module",
6
6
  "engines": {
@@ -145,6 +145,9 @@
145
145
  "llms/bedrock.cjs",
146
146
  "llms/bedrock.js",
147
147
  "llms/bedrock.d.ts",
148
+ "llms/writer.cjs",
149
+ "llms/writer.js",
150
+ "llms/writer.d.ts",
148
151
  "prompts.cjs",
149
152
  "prompts.js",
150
153
  "prompts.d.ts",
@@ -301,6 +304,9 @@
301
304
  "document_loaders/web/notionapi.cjs",
302
305
  "document_loaders/web/notionapi.js",
303
306
  "document_loaders/web/notionapi.d.ts",
307
+ "document_loaders/web/recursive_url.cjs",
308
+ "document_loaders/web/recursive_url.js",
309
+ "document_loaders/web/recursive_url.d.ts",
304
310
  "document_loaders/web/s3.cjs",
305
311
  "document_loaders/web/s3.js",
306
312
  "document_loaders/web/s3.d.ts",
@@ -454,6 +460,9 @@
454
460
  "retrievers/hyde.cjs",
455
461
  "retrievers/hyde.js",
456
462
  "retrievers/hyde.d.ts",
463
+ "retrievers/score_threshold.cjs",
464
+ "retrievers/score_threshold.js",
465
+ "retrievers/score_threshold.d.ts",
457
466
  "retrievers/self_query.cjs",
458
467
  "retrievers/self_query.js",
459
468
  "retrievers/self_query.d.ts",
@@ -514,6 +523,9 @@
514
523
  "stores/message/momento.cjs",
515
524
  "stores/message/momento.js",
516
525
  "stores/message/momento.d.ts",
526
+ "stores/message/mongodb.cjs",
527
+ "stores/message/mongodb.js",
528
+ "stores/message/mongodb.d.ts",
517
529
  "stores/message/redis.cjs",
518
530
  "stores/message/redis.js",
519
531
  "stores/message/redis.d.ts",
@@ -535,6 +547,9 @@
535
547
  "storage/ioredis.cjs",
536
548
  "storage/ioredis.js",
537
549
  "storage/ioredis.d.ts",
550
+ "hub.cjs",
551
+ "hub.js",
552
+ "hub.d.ts",
538
553
  "util/math.cjs",
539
554
  "util/math.js",
540
555
  "util/math.d.ts",
@@ -614,6 +629,8 @@
614
629
  "@planetscale/database": "^1.8.0",
615
630
  "@qdrant/js-client-rest": "^1.2.0",
616
631
  "@raycast/api": "^1.55.2",
632
+ "@smithy/eventstream-codec": "^2.0.5",
633
+ "@smithy/util-utf8": "^2.0.0",
617
634
  "@supabase/postgrest-js": "^1.1.1",
618
635
  "@supabase/supabase-js": "^2.10.0",
619
636
  "@tensorflow-models/universal-sentence-encoder": "^1.3.3",
@@ -637,6 +654,7 @@
637
654
  "@typescript-eslint/eslint-plugin": "^5.58.0",
638
655
  "@typescript-eslint/parser": "^5.58.0",
639
656
  "@upstash/redis": "^1.20.6",
657
+ "@writerai/writer-sdk": "^0.40.2",
640
658
  "@xata.io/client": "^0.25.1",
641
659
  "@zilliz/milvus2-sdk-node": ">=2.2.11",
642
660
  "apify-client": "^2.7.1",
@@ -664,6 +682,7 @@
664
682
  "ioredis": "^5.3.2",
665
683
  "jest": "^29.5.0",
666
684
  "jsdom": "^22.1.0",
685
+ "langchainhub": "~0.0.3",
667
686
  "mammoth": "^1.5.1",
668
687
  "ml-matrix": "^6.10.4",
669
688
  "mongodb": "^5.2.0",
@@ -722,6 +741,8 @@
722
741
  "@planetscale/database": "^1.8.0",
723
742
  "@qdrant/js-client-rest": "^1.2.0",
724
743
  "@raycast/api": "^1.55.2",
744
+ "@smithy/eventstream-codec": "^2.0.5",
745
+ "@smithy/util-utf8": "^2.0.0",
725
746
  "@supabase/postgrest-js": "^1.1.1",
726
747
  "@supabase/supabase-js": "^2.10.0",
727
748
  "@tensorflow-models/universal-sentence-encoder": "*",
@@ -729,6 +750,7 @@
729
750
  "@tensorflow/tfjs-core": "*",
730
751
  "@tigrisdata/vector": "^1.1.0",
731
752
  "@upstash/redis": "^1.20.6",
753
+ "@writerai/writer-sdk": "^0.40.2",
732
754
  "@xata.io/client": "^0.25.1",
733
755
  "@zilliz/milvus2-sdk-node": ">=2.2.7",
734
756
  "apify-client": "^2.7.1",
@@ -746,6 +768,7 @@
746
768
  "ignore": "^5.2.0",
747
769
  "ioredis": "^5.3.2",
748
770
  "jsdom": "*",
771
+ "langchainhub": "~0.0.3",
749
772
  "mammoth": "*",
750
773
  "mongodb": "^5.2.0",
751
774
  "mysql2": "^3.3.3",
@@ -848,6 +871,12 @@
848
871
  "@raycast/api": {
849
872
  "optional": true
850
873
  },
874
+ "@smithy/eventstream-codec": {
875
+ "optional": true
876
+ },
877
+ "@smithy/util-utf8": {
878
+ "optional": true
879
+ },
851
880
  "@supabase/postgrest-js": {
852
881
  "optional": true
853
882
  },
@@ -869,6 +898,9 @@
869
898
  "@upstash/redis": {
870
899
  "optional": true
871
900
  },
901
+ "@writerai/writer-sdk": {
902
+ "optional": true
903
+ },
872
904
  "@xata.io/client": {
873
905
  "optional": true
874
906
  },
@@ -920,6 +952,9 @@
920
952
  "jsdom": {
921
953
  "optional": true
922
954
  },
955
+ "langchainhub": {
956
+ "optional": true
957
+ },
923
958
  "mammoth": {
924
959
  "optional": true
925
960
  },
@@ -1262,6 +1297,11 @@
1262
1297
  "import": "./llms/bedrock.js",
1263
1298
  "require": "./llms/bedrock.cjs"
1264
1299
  },
1300
+ "./llms/writer": {
1301
+ "types": "./llms/writer.d.ts",
1302
+ "import": "./llms/writer.js",
1303
+ "require": "./llms/writer.cjs"
1304
+ },
1265
1305
  "./prompts": {
1266
1306
  "types": "./prompts.d.ts",
1267
1307
  "import": "./prompts.js",
@@ -1526,6 +1566,11 @@
1526
1566
  "import": "./document_loaders/web/notionapi.js",
1527
1567
  "require": "./document_loaders/web/notionapi.cjs"
1528
1568
  },
1569
+ "./document_loaders/web/recursive_url": {
1570
+ "types": "./document_loaders/web/recursive_url.d.ts",
1571
+ "import": "./document_loaders/web/recursive_url.js",
1572
+ "require": "./document_loaders/web/recursive_url.cjs"
1573
+ },
1529
1574
  "./document_loaders/web/s3": {
1530
1575
  "types": "./document_loaders/web/s3.d.ts",
1531
1576
  "import": "./document_loaders/web/s3.js",
@@ -1785,6 +1830,11 @@
1785
1830
  "import": "./retrievers/hyde.js",
1786
1831
  "require": "./retrievers/hyde.cjs"
1787
1832
  },
1833
+ "./retrievers/score_threshold": {
1834
+ "types": "./retrievers/score_threshold.d.ts",
1835
+ "import": "./retrievers/score_threshold.js",
1836
+ "require": "./retrievers/score_threshold.cjs"
1837
+ },
1788
1838
  "./retrievers/self_query": {
1789
1839
  "types": "./retrievers/self_query.d.ts",
1790
1840
  "import": "./retrievers/self_query.js",
@@ -1885,6 +1935,11 @@
1885
1935
  "import": "./stores/message/momento.js",
1886
1936
  "require": "./stores/message/momento.cjs"
1887
1937
  },
1938
+ "./stores/message/mongodb": {
1939
+ "types": "./stores/message/mongodb.d.ts",
1940
+ "import": "./stores/message/mongodb.js",
1941
+ "require": "./stores/message/mongodb.cjs"
1942
+ },
1888
1943
  "./stores/message/redis": {
1889
1944
  "types": "./stores/message/redis.d.ts",
1890
1945
  "import": "./stores/message/redis.js",
@@ -1920,6 +1975,11 @@
1920
1975
  "import": "./storage/ioredis.js",
1921
1976
  "require": "./storage/ioredis.cjs"
1922
1977
  },
1978
+ "./hub": {
1979
+ "types": "./hub.d.ts",
1980
+ "import": "./hub.js",
1981
+ "require": "./hub.cjs"
1982
+ },
1923
1983
  "./util/math": {
1924
1984
  "types": "./util/math.d.ts",
1925
1985
  "import": "./util/math.js",
@@ -0,0 +1 @@
1
+ module.exports = require('../dist/retrievers/score_threshold.cjs');
@@ -0,0 +1 @@
1
+ export * from '../dist/retrievers/score_threshold.js'
@@ -0,0 +1 @@
1
+ export * from '../dist/retrievers/score_threshold.js'
@@ -0,0 +1 @@
1
+ module.exports = require('../../dist/stores/message/mongodb.cjs');
@@ -0,0 +1 @@
1
+ export * from '../../dist/stores/message/mongodb.js'
@@ -0,0 +1 @@
1
+ export * from '../../dist/stores/message/mongodb.js'