langchain 0.0.204-rc.0 → 0.0.204-rc.1

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 (55) hide show
  1. package/dist/agents/toolkits/aws_sfn.cjs +3 -75
  2. package/dist/agents/toolkits/aws_sfn.d.ts +2 -45
  3. package/dist/agents/toolkits/aws_sfn.js +2 -73
  4. package/dist/agents/toolkits/base.cjs +15 -9
  5. package/dist/agents/toolkits/base.d.ts +1 -9
  6. package/dist/agents/toolkits/base.js +1 -7
  7. package/dist/agents/toolkits/connery/index.cjs +15 -37
  8. package/dist/agents/toolkits/connery/index.d.ts +1 -23
  9. package/dist/agents/toolkits/connery/index.js +1 -35
  10. package/dist/cache/ioredis.cjs +15 -77
  11. package/dist/cache/ioredis.d.ts +1 -40
  12. package/dist/cache/ioredis.js +1 -75
  13. package/dist/memory/chat_memory.cjs +15 -61
  14. package/dist/memory/chat_memory.d.ts +1 -36
  15. package/dist/memory/chat_memory.js +1 -59
  16. package/dist/memory/motorhead_memory.cjs +15 -161
  17. package/dist/memory/motorhead_memory.d.ts +1 -63
  18. package/dist/memory/motorhead_memory.js +1 -159
  19. package/dist/memory/zep.cjs +15 -222
  20. package/dist/memory/zep.d.ts +1 -86
  21. package/dist/memory/zep.js +1 -220
  22. package/dist/stores/message/in_memory.cjs +15 -49
  23. package/dist/stores/message/in_memory.d.ts +1 -28
  24. package/dist/stores/message/in_memory.js +1 -47
  25. package/dist/tools/aws_lambda.cjs +15 -83
  26. package/dist/tools/aws_lambda.d.ts +1 -25
  27. package/dist/tools/aws_lambda.js +1 -82
  28. package/dist/tools/dynamic.cjs +15 -87
  29. package/dist/tools/dynamic.d.ts +1 -48
  30. package/dist/tools/dynamic.js +1 -84
  31. package/dist/util/convex.cjs +15 -75
  32. package/dist/util/convex.d.ts +1 -26
  33. package/dist/util/convex.js +1 -74
  34. package/dist/vectorstores/memory.cjs +143 -15
  35. package/dist/vectorstores/memory.d.ts +92 -1
  36. package/dist/vectorstores/memory.js +141 -1
  37. package/package.json +2 -241
  38. package/dist/util/chunk.cjs +0 -11
  39. package/dist/util/chunk.d.ts +0 -1
  40. package/dist/util/chunk.js +0 -7
  41. package/dist/util/googlevertexai-gauth.cjs +0 -36
  42. package/dist/util/googlevertexai-gauth.d.ts +0 -8
  43. package/dist/util/googlevertexai-gauth.js +0 -32
  44. package/dist/util/googlevertexai-webauth.cjs +0 -96
  45. package/dist/util/googlevertexai-webauth.d.ts +0 -22
  46. package/dist/util/googlevertexai-webauth.js +0 -92
  47. package/dist/util/iflytek_websocket_stream.cjs +0 -81
  48. package/dist/util/iflytek_websocket_stream.d.ts +0 -27
  49. package/dist/util/iflytek_websocket_stream.js +0 -77
  50. package/dist/util/llama_cpp.cjs +0 -34
  51. package/dist/util/llama_cpp.d.ts +0 -46
  52. package/dist/util/llama_cpp.js +0 -28
  53. package/dist/util/momento.cjs +0 -26
  54. package/dist/util/momento.d.ts +0 -9
  55. package/dist/util/momento.js +0 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "0.0.204-rc.0",
3
+ "version": "0.0.204-rc.1",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "type": "module",
6
6
  "engines": {
@@ -882,79 +882,42 @@
882
882
  "author": "LangChain",
883
883
  "license": "MIT",
884
884
  "devDependencies": {
885
- "@aws-sdk/client-lambda": "^3.310.0",
886
885
  "@aws-sdk/client-s3": "^3.310.0",
887
886
  "@aws-sdk/client-sagemaker-runtime": "^3.414.0",
888
887
  "@aws-sdk/client-sfn": "^3.362.0",
889
888
  "@aws-sdk/credential-provider-node": "^3.388.0",
890
889
  "@aws-sdk/types": "^3.357.0",
891
890
  "@azure/storage-blob": "^12.15.0",
892
- "@clickhouse/client": "^0.2.5",
893
- "@cloudflare/ai": "^1.0.12",
894
891
  "@cloudflare/workers-types": "^4.20230922.0",
895
- "@elastic/elasticsearch": "^8.4.0",
896
892
  "@faker-js/faker": "^7.6.0",
897
- "@getmetal/metal-sdk": "^4.0.0",
898
- "@getzep/zep-js": "^0.9.0",
899
893
  "@gomomento/sdk": "^1.51.1",
900
894
  "@gomomento/sdk-core": "^1.51.1",
901
895
  "@google-ai/generativelanguage": "^0.2.1",
902
896
  "@google-cloud/storage": "^6.10.1",
903
- "@gradientai/nodejs-sdk": "^1.2.0",
904
- "@huggingface/inference": "^2.6.4",
905
897
  "@jest/globals": "^29.5.0",
906
- "@mozilla/readability": "^0.4.4",
907
898
  "@notionhq/client": "^2.2.10",
908
- "@opensearch-project/opensearch": "^2.2.0",
909
899
  "@pinecone-database/pinecone": "^1.1.0",
910
- "@planetscale/database": "^1.8.0",
911
- "@qdrant/js-client-rest": "^1.2.0",
912
- "@raycast/api": "^1.55.2",
913
- "@rockset/client": "^0.9.1",
914
- "@smithy/eventstream-codec": "^2.0.5",
915
- "@smithy/protocol-http": "^3.0.6",
916
- "@smithy/signature-v4": "^2.0.10",
917
- "@smithy/util-utf8": "^2.0.0",
918
- "@supabase/postgrest-js": "^1.1.1",
919
900
  "@supabase/supabase-js": "^2.10.0",
920
901
  "@swc/core": "^1.3.90",
921
902
  "@swc/jest": "^0.2.29",
922
- "@tensorflow-models/universal-sentence-encoder": "^1.3.3",
923
- "@tensorflow/tfjs-backend-cpu": "^3",
924
- "@tensorflow/tfjs-converter": "^3.6.0",
925
- "@tensorflow/tfjs-core": "^3.6.0",
926
903
  "@tsconfig/recommended": "^1.0.2",
927
904
  "@types/d3-dsv": "^2",
928
905
  "@types/decamelize": "^1.2.0",
929
906
  "@types/html-to-text": "^9",
930
907
  "@types/js-yaml": "^4",
931
908
  "@types/jsdom": "^21.1.1",
932
- "@types/lodash": "^4",
933
- "@types/mozilla-readability": "^0.2.1",
934
909
  "@types/pdf-parse": "^1.1.1",
935
- "@types/pg": "^8",
936
- "@types/pg-copy-streams": "^1.2.2",
937
910
  "@types/uuid": "^9",
938
911
  "@types/ws": "^8",
939
912
  "@typescript-eslint/eslint-plugin": "^5.58.0",
940
913
  "@typescript-eslint/parser": "^5.58.0",
941
- "@upstash/redis": "^1.20.6",
942
914
  "@vercel/kv": "^0.2.3",
943
- "@vercel/postgres": "^0.5.0",
944
- "@writerai/writer-sdk": "^0.40.2",
945
915
  "@xata.io/client": "^0.28.0",
946
- "@xenova/transformers": "^2.5.4",
947
- "@zilliz/milvus2-sdk-node": ">=2.2.11",
948
916
  "apify-client": "^2.7.1",
949
917
  "assemblyai": "^2.0.2",
950
918
  "axios": "^0.26.0",
951
- "cassandra-driver": "^4.7.2",
952
919
  "cheerio": "^1.0.0-rc.12",
953
920
  "chromadb": "^1.5.3",
954
- "closevector-common": "0.1.0-alpha.1",
955
- "closevector-node": "0.1.0-alpha.10",
956
- "closevector-web": "0.1.0-alpha.15",
957
- "cohere-ai": ">=6.0.0",
958
921
  "convex": "^1.3.1",
959
922
  "d3-dsv": "^2.0.0",
960
923
  "dotenv": "^16.0.3",
@@ -967,151 +930,87 @@
967
930
  "eslint-plugin-jest": "^27.6.0",
968
931
  "eslint-plugin-no-instanceof": "^1.0.1",
969
932
  "eslint-plugin-prettier": "^4.2.1",
970
- "faiss-node": "^0.5.1",
971
933
  "fast-xml-parser": "^4.2.7",
972
- "firebase-admin": "^11.9.0",
973
934
  "google-auth-library": "^8.9.0",
974
935
  "googleapis": "^126.0.1",
975
- "graphql": "^16.6.0",
976
- "hnswlib-node": "^1.4.2",
977
936
  "html-to-text": "^9.0.5",
978
937
  "ignore": "^5.2.0",
979
938
  "ioredis": "^5.3.2",
980
939
  "jest": "^29.5.0",
981
940
  "jest-environment-node": "^29.6.4",
982
941
  "jsdom": "^22.1.0",
983
- "llmonitor": "^0.5.9",
984
- "lodash": "^4.17.21",
985
942
  "mammoth": "^1.5.1",
986
943
  "mongodb": "^5.2.0",
987
- "mysql2": "^3.3.3",
988
- "neo4j-driver": "^5.12.0",
989
944
  "node-llama-cpp": "2.7.3",
990
945
  "notion-to-md": "^3.1.0",
991
946
  "officeparser": "^4.0.4",
992
947
  "pdf-parse": "1.1.1",
993
948
  "peggy": "^3.0.2",
994
- "pg": "^8.11.0",
995
- "pg-copy-streams": "^6.0.5",
996
- "pickleparser": "^0.2.1",
997
949
  "playwright": "^1.32.1",
998
- "portkey-ai": "^0.1.11",
999
950
  "prettier": "^2.8.3",
1000
951
  "puppeteer": "^19.7.2",
1001
952
  "pyodide": "^0.24.1",
1002
953
  "redis": "^4.6.6",
1003
954
  "release-it": "^15.10.1",
1004
- "replicate": "^0.18.0",
1005
955
  "rimraf": "^5.0.1",
1006
956
  "rollup": "^3.19.1",
1007
957
  "sonix-speech-recognition": "^2.1.1",
1008
- "sqlite3": "^5.1.4",
1009
958
  "srt-parser-2": "^1.2.2",
1010
959
  "ts-jest": "^29.1.0",
1011
960
  "typeorm": "^0.3.12",
1012
961
  "typescript": "~5.1.6",
1013
- "typesense": "^1.5.3",
1014
- "usearch": "^1.1.1",
1015
962
  "vectordb": "^0.1.4",
1016
- "voy-search": "0.6.2",
1017
963
  "weaviate-ts-client": "^1.4.0",
1018
964
  "web-auth-library": "^1.0.3",
1019
965
  "youtube-transcript": "^1.0.6",
1020
966
  "youtubei.js": "^5.8.0"
1021
967
  },
1022
968
  "peerDependencies": {
1023
- "@aws-sdk/client-lambda": "^3.310.0",
1024
969
  "@aws-sdk/client-s3": "^3.310.0",
1025
970
  "@aws-sdk/client-sagemaker-runtime": "^3.310.0",
1026
971
  "@aws-sdk/client-sfn": "^3.310.0",
1027
972
  "@aws-sdk/credential-provider-node": "^3.388.0",
1028
973
  "@azure/storage-blob": "^12.15.0",
1029
- "@clickhouse/client": "^0.2.5",
1030
- "@cloudflare/ai": "^1.0.12",
1031
- "@elastic/elasticsearch": "^8.4.0",
1032
- "@getmetal/metal-sdk": "*",
1033
- "@getzep/zep-js": "^0.9.0",
1034
974
  "@gomomento/sdk": "^1.51.1",
1035
975
  "@gomomento/sdk-core": "^1.51.1",
1036
976
  "@gomomento/sdk-web": "^1.51.1",
1037
977
  "@google-ai/generativelanguage": "^0.2.1",
1038
978
  "@google-cloud/storage": "^6.10.1",
1039
- "@gradientai/nodejs-sdk": "^1.2.0",
1040
- "@huggingface/inference": "^2.6.4",
1041
- "@mozilla/readability": "*",
1042
979
  "@notionhq/client": "^2.2.10",
1043
- "@opensearch-project/opensearch": "*",
1044
980
  "@pinecone-database/pinecone": "^1.1.0",
1045
- "@planetscale/database": "^1.8.0",
1046
- "@qdrant/js-client-rest": "^1.2.0",
1047
- "@raycast/api": "^1.55.2",
1048
- "@rockset/client": "^0.9.1",
1049
- "@smithy/eventstream-codec": "^2.0.5",
1050
- "@smithy/protocol-http": "^3.0.6",
1051
- "@smithy/signature-v4": "^2.0.10",
1052
- "@smithy/util-utf8": "^2.0.0",
1053
- "@supabase/postgrest-js": "^1.1.1",
1054
981
  "@supabase/supabase-js": "^2.10.0",
1055
- "@tensorflow-models/universal-sentence-encoder": "*",
1056
- "@tensorflow/tfjs-converter": "*",
1057
- "@tensorflow/tfjs-core": "*",
1058
- "@upstash/redis": "^1.20.6",
1059
982
  "@vercel/kv": "^0.2.3",
1060
- "@vercel/postgres": "^0.5.0",
1061
- "@writerai/writer-sdk": "^0.40.2",
1062
983
  "@xata.io/client": "^0.28.0",
1063
- "@xenova/transformers": "^2.5.4",
1064
- "@zilliz/milvus2-sdk-node": ">=2.2.7",
1065
984
  "apify-client": "^2.7.1",
1066
985
  "assemblyai": "^2.0.2",
1067
986
  "axios": "*",
1068
- "cassandra-driver": "^4.7.2",
1069
987
  "cheerio": "^1.0.0-rc.12",
1070
988
  "chromadb": "*",
1071
- "closevector-common": "0.1.0-alpha.1",
1072
- "closevector-node": "0.1.0-alpha.10",
1073
- "closevector-web": "0.1.0-alpha.16",
1074
- "cohere-ai": ">=6.0.0",
1075
989
  "convex": "^1.3.1",
1076
990
  "d3-dsv": "^2.0.0",
1077
991
  "epub2": "^3.0.1",
1078
- "faiss-node": "^0.5.1",
1079
992
  "fast-xml-parser": "^4.2.7",
1080
- "firebase-admin": "^11.9.0",
1081
993
  "google-auth-library": "^8.9.0",
1082
994
  "googleapis": "^126.0.1",
1083
- "hnswlib-node": "^1.4.2",
1084
995
  "html-to-text": "^9.0.5",
1085
996
  "ignore": "^5.2.0",
1086
997
  "ioredis": "^5.3.2",
1087
998
  "jsdom": "*",
1088
- "llmonitor": "^0.5.9",
1089
- "lodash": "^4.17.21",
1090
999
  "mammoth": "*",
1091
1000
  "mongodb": "^5.2.0",
1092
- "mysql2": "^3.3.3",
1093
- "neo4j-driver": "*",
1094
1001
  "node-llama-cpp": "*",
1095
1002
  "notion-to-md": "^3.1.0",
1096
1003
  "officeparser": "^4.0.4",
1097
1004
  "pdf-parse": "1.1.1",
1098
1005
  "peggy": "^3.0.2",
1099
- "pg": "^8.11.0",
1100
- "pg-copy-streams": "^6.0.5",
1101
- "pickleparser": "^0.2.1",
1102
1006
  "playwright": "^1.32.1",
1103
- "portkey-ai": "^0.1.11",
1104
1007
  "puppeteer": "^19.7.2",
1105
1008
  "pyodide": "^0.24.1",
1106
1009
  "redis": "^4.6.4",
1107
- "replicate": "^0.18.0",
1108
1010
  "sonix-speech-recognition": "^2.1.1",
1109
1011
  "srt-parser-2": "^1.2.2",
1110
1012
  "typeorm": "^0.3.12",
1111
- "typesense": "^1.5.3",
1112
- "usearch": "^1.1.1",
1113
1013
  "vectordb": "^0.1.4",
1114
- "voy-search": "0.6.2",
1115
1014
  "weaviate-ts-client": "^1.4.0",
1116
1015
  "web-auth-library": "^1.0.3",
1117
1016
  "ws": "^8.14.2",
@@ -1119,9 +1018,6 @@
1119
1018
  "youtubei.js": "^5.8.0"
1120
1019
  },
1121
1020
  "peerDependenciesMeta": {
1122
- "@aws-sdk/client-lambda": {
1123
- "optional": true
1124
- },
1125
1021
  "@aws-sdk/client-s3": {
1126
1022
  "optional": true
1127
1023
  },
@@ -1137,21 +1033,6 @@
1137
1033
  "@azure/storage-blob": {
1138
1034
  "optional": true
1139
1035
  },
1140
- "@clickhouse/client": {
1141
- "optional": true
1142
- },
1143
- "@cloudflare/ai": {
1144
- "optional": true
1145
- },
1146
- "@elastic/elasticsearch": {
1147
- "optional": true
1148
- },
1149
- "@getmetal/metal-sdk": {
1150
- "optional": true
1151
- },
1152
- "@getzep/zep-js": {
1153
- "optional": true
1154
- },
1155
1036
  "@gomomento/sdk": {
1156
1037
  "optional": true
1157
1038
  },
@@ -1167,84 +1048,21 @@
1167
1048
  "@google-cloud/storage": {
1168
1049
  "optional": true
1169
1050
  },
1170
- "@gradientai/nodejs-sdk": {
1171
- "optional": true
1172
- },
1173
- "@huggingface/inference": {
1174
- "optional": true
1175
- },
1176
- "@mozilla/readability": {
1177
- "optional": true
1178
- },
1179
1051
  "@notionhq/client": {
1180
1052
  "optional": true
1181
1053
  },
1182
- "@opensearch-project/opensearch": {
1183
- "optional": true
1184
- },
1185
1054
  "@pinecone-database/pinecone": {
1186
1055
  "optional": true
1187
1056
  },
1188
- "@planetscale/database": {
1189
- "optional": true
1190
- },
1191
- "@qdrant/js-client-rest": {
1192
- "optional": true
1193
- },
1194
- "@raycast/api": {
1195
- "optional": true
1196
- },
1197
- "@rockset/client": {
1198
- "optional": true
1199
- },
1200
- "@smithy/eventstream-codec": {
1201
- "optional": true
1202
- },
1203
- "@smithy/protocol-http": {
1204
- "optional": true
1205
- },
1206
- "@smithy/signature-v4": {
1207
- "optional": true
1208
- },
1209
- "@smithy/util-utf8": {
1210
- "optional": true
1211
- },
1212
- "@supabase/postgrest-js": {
1213
- "optional": true
1214
- },
1215
1057
  "@supabase/supabase-js": {
1216
1058
  "optional": true
1217
1059
  },
1218
- "@tensorflow-models/universal-sentence-encoder": {
1219
- "optional": true
1220
- },
1221
- "@tensorflow/tfjs-converter": {
1222
- "optional": true
1223
- },
1224
- "@tensorflow/tfjs-core": {
1225
- "optional": true
1226
- },
1227
- "@upstash/redis": {
1228
- "optional": true
1229
- },
1230
1060
  "@vercel/kv": {
1231
1061
  "optional": true
1232
1062
  },
1233
- "@vercel/postgres": {
1234
- "optional": true
1235
- },
1236
- "@writerai/writer-sdk": {
1237
- "optional": true
1238
- },
1239
1063
  "@xata.io/client": {
1240
1064
  "optional": true
1241
1065
  },
1242
- "@xenova/transformers": {
1243
- "optional": true
1244
- },
1245
- "@zilliz/milvus2-sdk-node": {
1246
- "optional": true
1247
- },
1248
1066
  "apify-client": {
1249
1067
  "optional": true
1250
1068
  },
@@ -1254,27 +1072,12 @@
1254
1072
  "axios": {
1255
1073
  "optional": true
1256
1074
  },
1257
- "cassandra-driver": {
1258
- "optional": true
1259
- },
1260
1075
  "cheerio": {
1261
1076
  "optional": true
1262
1077
  },
1263
1078
  "chromadb": {
1264
1079
  "optional": true
1265
1080
  },
1266
- "closevector-common": {
1267
- "optional": true
1268
- },
1269
- "closevector-node": {
1270
- "optional": true
1271
- },
1272
- "closevector-web": {
1273
- "optional": true
1274
- },
1275
- "cohere-ai": {
1276
- "optional": true
1277
- },
1278
1081
  "convex": {
1279
1082
  "optional": true
1280
1083
  },
@@ -1290,18 +1093,12 @@
1290
1093
  "fast-xml-parser": {
1291
1094
  "optional": true
1292
1095
  },
1293
- "firebase-admin": {
1294
- "optional": true
1295
- },
1296
1096
  "google-auth-library": {
1297
1097
  "optional": true
1298
1098
  },
1299
1099
  "googleapis": {
1300
1100
  "optional": true
1301
1101
  },
1302
- "hnswlib-node": {
1303
- "optional": true
1304
- },
1305
1102
  "html-to-text": {
1306
1103
  "optional": true
1307
1104
  },
@@ -1314,24 +1111,12 @@
1314
1111
  "jsdom": {
1315
1112
  "optional": true
1316
1113
  },
1317
- "llmonitor": {
1318
- "optional": true
1319
- },
1320
- "lodash": {
1321
- "optional": true
1322
- },
1323
1114
  "mammoth": {
1324
1115
  "optional": true
1325
1116
  },
1326
1117
  "mongodb": {
1327
1118
  "optional": true
1328
1119
  },
1329
- "mysql2": {
1330
- "optional": true
1331
- },
1332
- "neo4j-driver": {
1333
- "optional": true
1334
- },
1335
1120
  "node-llama-cpp": {
1336
1121
  "optional": true
1337
1122
  },
@@ -1347,21 +1132,9 @@
1347
1132
  "peggy": {
1348
1133
  "optional": true
1349
1134
  },
1350
- "pg": {
1351
- "optional": true
1352
- },
1353
- "pg-copy-streams": {
1354
- "optional": true
1355
- },
1356
- "pickleparser": {
1357
- "optional": true
1358
- },
1359
1135
  "playwright": {
1360
1136
  "optional": true
1361
1137
  },
1362
- "portkey-ai": {
1363
- "optional": true
1364
- },
1365
1138
  "puppeteer": {
1366
1139
  "optional": true
1367
1140
  },
@@ -1371,9 +1144,6 @@
1371
1144
  "redis": {
1372
1145
  "optional": true
1373
1146
  },
1374
- "replicate": {
1375
- "optional": true
1376
- },
1377
1147
  "sonix-speech-recognition": {
1378
1148
  "optional": true
1379
1149
  },
@@ -1383,18 +1153,9 @@
1383
1153
  "typeorm": {
1384
1154
  "optional": true
1385
1155
  },
1386
- "typesense": {
1387
- "optional": true
1388
- },
1389
- "usearch": {
1390
- "optional": true
1391
- },
1392
1156
  "vectordb": {
1393
1157
  "optional": true
1394
1158
  },
1395
- "voy-search": {
1396
- "optional": true
1397
- },
1398
1159
  "weaviate-ts-client": {
1399
1160
  "optional": true
1400
1161
  },
@@ -1413,7 +1174,7 @@
1413
1174
  },
1414
1175
  "dependencies": {
1415
1176
  "@anthropic-ai/sdk": "^0.9.1",
1416
- "@langchain/community": "~0.0.0",
1177
+ "@langchain/community": "~0.0.1-rc.1",
1417
1178
  "@langchain/core": "~0.0.11-rc.1",
1418
1179
  "@langchain/openai": "~0.0.2-rc.0",
1419
1180
  "binary-extensions": "^2.2.0",
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.chunkArray = void 0;
4
- const chunkArray = (arr, chunkSize) => arr.reduce((chunks, elem, index) => {
5
- const chunkIndex = Math.floor(index / chunkSize);
6
- const chunk = chunks[chunkIndex] || [];
7
- // eslint-disable-next-line no-param-reassign
8
- chunks[chunkIndex] = chunk.concat([elem]);
9
- return chunks;
10
- }, []);
11
- exports.chunkArray = chunkArray;
@@ -1 +0,0 @@
1
- export declare const chunkArray: <T>(arr: T[], chunkSize: number) => T[][];
@@ -1,7 +0,0 @@
1
- export const chunkArray = (arr, chunkSize) => arr.reduce((chunks, elem, index) => {
2
- const chunkIndex = Math.floor(index / chunkSize);
3
- const chunk = chunks[chunkIndex] || [];
4
- // eslint-disable-next-line no-param-reassign
5
- chunks[chunkIndex] = chunk.concat([elem]);
6
- return chunks;
7
- }, []);
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GAuthClient = void 0;
4
- const google_auth_library_1 = require("google-auth-library");
5
- const googlevertexai_connection_js_1 = require("./googlevertexai-connection.cjs");
6
- class GoogleVertexAINodeStream extends googlevertexai_connection_js_1.GoogleVertexAIStream {
7
- constructor(data) {
8
- super();
9
- data.on("data", (data) => this.appendBuffer(data.toString()));
10
- data.on("end", () => this.closeBuffer());
11
- }
12
- }
13
- class GAuthClient {
14
- constructor(options) {
15
- Object.defineProperty(this, "gauth", {
16
- enumerable: true,
17
- configurable: true,
18
- writable: true,
19
- value: void 0
20
- });
21
- this.gauth = new google_auth_library_1.GoogleAuth(options);
22
- }
23
- async getProjectId() {
24
- return this.gauth.getProjectId();
25
- }
26
- async request(opts) {
27
- const ret = await this.gauth.request(opts);
28
- return opts.responseType !== "stream"
29
- ? ret
30
- : {
31
- ...ret,
32
- data: new GoogleVertexAINodeStream(ret.data),
33
- };
34
- }
35
- }
36
- exports.GAuthClient = GAuthClient;
@@ -1,8 +0,0 @@
1
- import { GoogleAuth, GoogleAuthOptions } from "google-auth-library";
2
- import { GoogleAbstractedClient, GoogleAbstractedClientOps } from "../types/googlevertexai-types.js";
3
- export declare class GAuthClient implements GoogleAbstractedClient {
4
- gauth: GoogleAuth;
5
- constructor(options?: GoogleAuthOptions);
6
- getProjectId(): Promise<string>;
7
- request(opts: GoogleAbstractedClientOps): Promise<unknown>;
8
- }
@@ -1,32 +0,0 @@
1
- import { GoogleAuth } from "google-auth-library";
2
- import { GoogleVertexAIStream } from "./googlevertexai-connection.js";
3
- class GoogleVertexAINodeStream extends GoogleVertexAIStream {
4
- constructor(data) {
5
- super();
6
- data.on("data", (data) => this.appendBuffer(data.toString()));
7
- data.on("end", () => this.closeBuffer());
8
- }
9
- }
10
- export class GAuthClient {
11
- constructor(options) {
12
- Object.defineProperty(this, "gauth", {
13
- enumerable: true,
14
- configurable: true,
15
- writable: true,
16
- value: void 0
17
- });
18
- this.gauth = new GoogleAuth(options);
19
- }
20
- async getProjectId() {
21
- return this.gauth.getProjectId();
22
- }
23
- async request(opts) {
24
- const ret = await this.gauth.request(opts);
25
- return opts.responseType !== "stream"
26
- ? ret
27
- : {
28
- ...ret,
29
- data: new GoogleVertexAINodeStream(ret.data),
30
- };
31
- }
32
- }
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebGoogleAuth = void 0;
4
- const google_1 = require("web-auth-library/google");
5
- const env_js_1 = require("./env.cjs");
6
- const googlevertexai_connection_js_1 = require("./googlevertexai-connection.cjs");
7
- class GoogleVertexAIResponseStream extends googlevertexai_connection_js_1.GoogleVertexAIStream {
8
- constructor(body) {
9
- super();
10
- Object.defineProperty(this, "decoder", {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value: void 0
15
- });
16
- this.decoder = new TextDecoder();
17
- if (body) {
18
- void this.run(body);
19
- }
20
- else {
21
- console.error("Unexpected empty body while streaming");
22
- }
23
- }
24
- async run(body) {
25
- const reader = body.getReader();
26
- let isDone = false;
27
- while (!isDone) {
28
- const { value, done } = await reader.read();
29
- if (!done) {
30
- const svalue = this.decoder.decode(value);
31
- this.appendBuffer(svalue);
32
- }
33
- else {
34
- isDone = done;
35
- this.closeBuffer();
36
- }
37
- }
38
- }
39
- }
40
- class WebGoogleAuth {
41
- constructor(options) {
42
- Object.defineProperty(this, "options", {
43
- enumerable: true,
44
- configurable: true,
45
- writable: true,
46
- value: void 0
47
- });
48
- const accessToken = options?.accessToken;
49
- const credentials = options?.credentials ??
50
- (0, env_js_1.getEnvironmentVariable)("GOOGLE_VERTEX_AI_WEB_CREDENTIALS");
51
- if (credentials === undefined)
52
- throw new Error(`Credentials not found. Please set the GOOGLE_VERTEX_AI_WEB_CREDENTIALS environment variable or pass credentials into "authOptions.credentials".`);
53
- const scope = options?.scope ?? "https://www.googleapis.com/auth/cloud-platform";
54
- this.options = { ...options, accessToken, credentials, scope };
55
- }
56
- async getProjectId() {
57
- const credentials = (0, google_1.getCredentials)(this.options.credentials);
58
- return credentials.project_id;
59
- }
60
- async request(opts) {
61
- let { accessToken } = this.options;
62
- if (accessToken === undefined) {
63
- accessToken = await (0, google_1.getAccessToken)(this.options);
64
- }
65
- if (opts.url == null)
66
- throw new Error("Missing URL");
67
- const fetchOptions = {
68
- method: opts.method,
69
- headers: {
70
- Authorization: `Bearer ${accessToken}`,
71
- "Content-Type": "application/json",
72
- },
73
- };
74
- if (opts.data !== undefined) {
75
- fetchOptions.body = JSON.stringify(opts.data);
76
- }
77
- const res = await fetch(opts.url, fetchOptions);
78
- if (!res.ok) {
79
- const error = new Error(`Could not get access token for Vertex AI with status code: ${res.status}`);
80
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
- error.response = res;
82
- throw error;
83
- }
84
- return {
85
- data: opts.responseType === "json"
86
- ? await res.json()
87
- : new GoogleVertexAIResponseStream(res.body),
88
- config: {},
89
- status: res.status,
90
- statusText: res.statusText,
91
- headers: res.headers,
92
- request: { responseURL: res.url },
93
- };
94
- }
95
- }
96
- exports.WebGoogleAuth = WebGoogleAuth;