triangle-utils 1.4.173 → 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/package.json +2 -3
- package/src/UtilsBedrock.ts +28 -26
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/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
|
}
|