triangle-utils 1.4.172 → 1.4.174
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/dist/src/UtilsBedrock.js +29 -27
- package/dist/src/UtilsRDS.js +1 -1
- package/package.json +2 -3
- package/src/UtilsBedrock.ts +28 -26
- package/src/UtilsRDS.ts +1 -1
package/dist/src/UtilsBedrock.js
CHANGED
|
@@ -252,34 +252,36 @@ export class UtilsBedrock {
|
|
|
252
252
|
return undefined;
|
|
253
253
|
}
|
|
254
254
|
async cohere_invoke(model_id, text, options = {}) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
255
|
+
for (let i = 0; i < 3; i++) {
|
|
256
|
+
try {
|
|
257
|
+
const output = await this.bedrock_runtime.invokeModel({
|
|
258
|
+
modelId: model_id,
|
|
259
|
+
body: JSON.stringify({
|
|
260
|
+
input_type: options.input_type_id || "search_document",
|
|
261
|
+
inputs: [
|
|
262
|
+
{
|
|
263
|
+
content: [
|
|
264
|
+
{ type: "text", text: text }
|
|
265
|
+
]
|
|
266
|
+
}
|
|
267
|
+
],
|
|
268
|
+
output_dimension: 1024,
|
|
269
|
+
truncate: "RIGHT",
|
|
270
|
+
max_tokens: 128000
|
|
271
|
+
}),
|
|
272
|
+
contentType: "application/json"
|
|
273
|
+
});
|
|
274
|
+
const response = JSON.parse(this.text_decoder.decode(output.body));
|
|
275
|
+
const coordinates = response.embeddings.float[0];
|
|
276
|
+
if (coordinates !== undefined && Array.isArray(coordinates) && coordinates.every((i) => typeof i === "number")) {
|
|
277
|
+
return coordinates;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
console.log(error.stack);
|
|
282
|
+
console.log("Failed to get from Bedrock.");
|
|
277
283
|
}
|
|
278
284
|
}
|
|
279
|
-
|
|
280
|
-
console.log(error.stack);
|
|
281
|
-
console.log("Failed to get from Bedrock.");
|
|
282
|
-
}
|
|
283
|
-
return undefined;
|
|
285
|
+
throw new Error();
|
|
284
286
|
}
|
|
285
287
|
}
|
package/dist/src/UtilsRDS.js
CHANGED
|
@@ -124,7 +124,7 @@ export class UtilsRDS {
|
|
|
124
124
|
const attribute_names = Array.from(new Set(primary_keys.map(primary_key => Object.keys(primary_key)).flat())).sort();
|
|
125
125
|
const items = [];
|
|
126
126
|
for (let i = 0; i < primary_keys.length; i += batch_num_items) {
|
|
127
|
-
const sql = "SELECT " + (options.attribute_names === undefined ? "*" : options.attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + "(" + attribute_names.join(", ") + ")" + " IN " + "(" + primary_keys.map(primary_key => "(" + attribute_names.map(attribute_name => convert_postgres_input(primary_key[attribute_name])).join(", ") + ")").join(", ") + ")";
|
|
127
|
+
const sql = "SELECT " + (options.attribute_names === undefined ? "*" : options.attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + "(" + attribute_names.join(", ") + ")" + " IN " + "(" + primary_keys.slice(i, i + batch_num_items).map(primary_key => "(" + attribute_names.map(attribute_name => convert_postgres_input(primary_key[attribute_name])).join(", ") + ")").join(", ") + ")";
|
|
128
128
|
const new_items = await this.exec(sql, options);
|
|
129
129
|
items.push(...new_items);
|
|
130
130
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "triangle-utils",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.174",
|
|
4
4
|
"main": "dist/src/index.js",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"directories": {
|
|
@@ -36,8 +36,7 @@
|
|
|
36
36
|
"googleapis": "^170.0.0",
|
|
37
37
|
"jsdom": "^29.0.1",
|
|
38
38
|
"pg": "^8.23.0",
|
|
39
|
-
"scrapingbee": "^1.8.2"
|
|
40
|
-
"triangle-types": "^1.0.259"
|
|
39
|
+
"scrapingbee": "^1.8.2"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
43
42
|
"@eslint/js": "^9.39.2",
|
package/src/UtilsBedrock.ts
CHANGED
|
@@ -284,34 +284,36 @@ export class UtilsBedrock {
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
async cohere_invoke(model_id : string, text : string, options : { input_type_id? : string } = {}) : Promise<number[] | undefined> {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
287
|
+
for (let i = 0; i < 3; i++) {
|
|
288
|
+
try {
|
|
289
|
+
const output = await this.bedrock_runtime.invokeModel({
|
|
290
|
+
modelId : model_id,
|
|
291
|
+
body : JSON.stringify({
|
|
292
|
+
input_type: options.input_type_id || "search_document",
|
|
293
|
+
inputs: [
|
|
294
|
+
{
|
|
295
|
+
content: [
|
|
296
|
+
{ type : "text", text : text }
|
|
297
|
+
]
|
|
298
|
+
}
|
|
299
|
+
],
|
|
300
|
+
output_dimension: 1024,
|
|
301
|
+
truncate: "RIGHT",
|
|
302
|
+
max_tokens: 128000
|
|
303
|
+
}),
|
|
304
|
+
contentType : "application/json"
|
|
305
|
+
})
|
|
306
|
+
const response = JSON.parse(this.text_decoder.decode(output.body))
|
|
307
|
+
const coordinates = response.embeddings.float[0]
|
|
308
|
+
if (coordinates !== undefined && Array.isArray(coordinates) && coordinates.every((i : any) => typeof i === "number")) {
|
|
309
|
+
return coordinates
|
|
310
|
+
}
|
|
311
|
+
} catch (error : any) {
|
|
312
|
+
console.log(error.stack)
|
|
313
|
+
console.log("Failed to get from Bedrock.")
|
|
309
314
|
}
|
|
310
|
-
} catch (error : any) {
|
|
311
|
-
console.log(error.stack)
|
|
312
|
-
console.log("Failed to get from Bedrock.")
|
|
313
315
|
}
|
|
314
|
-
|
|
316
|
+
throw new Error()
|
|
315
317
|
}
|
|
316
318
|
|
|
317
319
|
}
|
package/src/UtilsRDS.ts
CHANGED
|
@@ -174,7 +174,7 @@ export class UtilsRDS {
|
|
|
174
174
|
const attribute_names = Array.from(new Set(primary_keys.map(primary_key => Object.keys(primary_key)).flat())).sort()
|
|
175
175
|
const items = []
|
|
176
176
|
for (let i = 0; i < primary_keys.length; i += batch_num_items) {
|
|
177
|
-
const sql = "SELECT " + (options.attribute_names === undefined ? "*" : options.attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + "(" + attribute_names.join(", ") + ")" + " IN " + "(" + primary_keys.map(primary_key => "(" + attribute_names.map(attribute_name => convert_postgres_input(primary_key[attribute_name])).join(", ") + ")" ).join(", ") + ")"
|
|
177
|
+
const sql = "SELECT " + (options.attribute_names === undefined ? "*" : options.attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + "(" + attribute_names.join(", ") + ")" + " IN " + "(" + primary_keys.slice(i, i + batch_num_items).map(primary_key => "(" + attribute_names.map(attribute_name => convert_postgres_input(primary_key[attribute_name])).join(", ") + ")" ).join(", ") + ")"
|
|
178
178
|
const new_items = await this.exec(sql, options)
|
|
179
179
|
items.push(...new_items)
|
|
180
180
|
}
|