triangle-utils 1.4.174 → 1.4.176
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 +5 -4
- package/package.json +1 -1
- package/src/UtilsBedrock.ts +5 -4
package/dist/src/UtilsBedrock.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BedrockRuntime } from "@aws-sdk/client-bedrock-runtime";
|
|
2
2
|
import { AnthropicBedrockMantle } from "@anthropic-ai/bedrock-sdk";
|
|
3
|
+
import { TriangleUtils } from "./index.js";
|
|
3
4
|
const message_roles = ["user", "assistant", "system"];
|
|
4
5
|
export function is_message_role(message_role) {
|
|
5
6
|
return message_roles.includes(message_role);
|
|
@@ -252,7 +253,7 @@ export class UtilsBedrock {
|
|
|
252
253
|
return undefined;
|
|
253
254
|
}
|
|
254
255
|
async cohere_invoke(model_id, text, options = {}) {
|
|
255
|
-
for (let i = 0; i <
|
|
256
|
+
for (let i = 0; i < 5; i++) {
|
|
256
257
|
try {
|
|
257
258
|
const output = await this.bedrock_runtime.invokeModel({
|
|
258
259
|
modelId: model_id,
|
|
@@ -278,10 +279,10 @@ export class UtilsBedrock {
|
|
|
278
279
|
}
|
|
279
280
|
}
|
|
280
281
|
catch (error) {
|
|
281
|
-
console.log(error.
|
|
282
|
-
|
|
282
|
+
console.log(error.message);
|
|
283
|
+
await TriangleUtils.wait(5000 * (i + 1));
|
|
283
284
|
}
|
|
284
285
|
}
|
|
285
|
-
throw new Error();
|
|
286
|
+
throw new Error("Failed to Cohere");
|
|
286
287
|
}
|
|
287
288
|
}
|
package/package.json
CHANGED
package/src/UtilsBedrock.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BedrockRuntime, InvokeModelCommandInput } from "@aws-sdk/client-bedrock-runtime"
|
|
2
2
|
import { AnthropicBedrockMantle } from "@anthropic-ai/bedrock-sdk"
|
|
3
3
|
import { ContentBlockParam, MessageCreateParams, MessageParam, OutputConfig } from "@anthropic-ai/sdk/resources"
|
|
4
|
+
import { TriangleUtils } from "."
|
|
4
5
|
|
|
5
6
|
const message_roles = ["user", "assistant", "system"] as const
|
|
6
7
|
|
|
@@ -284,7 +285,7 @@ export class UtilsBedrock {
|
|
|
284
285
|
}
|
|
285
286
|
|
|
286
287
|
async cohere_invoke(model_id : string, text : string, options : { input_type_id? : string } = {}) : Promise<number[] | undefined> {
|
|
287
|
-
for (let i = 0; i <
|
|
288
|
+
for (let i = 0; i < 5; i++) {
|
|
288
289
|
try {
|
|
289
290
|
const output = await this.bedrock_runtime.invokeModel({
|
|
290
291
|
modelId : model_id,
|
|
@@ -309,11 +310,11 @@ export class UtilsBedrock {
|
|
|
309
310
|
return coordinates
|
|
310
311
|
}
|
|
311
312
|
} catch (error : any) {
|
|
312
|
-
console.log(error.
|
|
313
|
-
|
|
313
|
+
console.log(error.message)
|
|
314
|
+
await TriangleUtils.wait(5000 * (i + 1))
|
|
314
315
|
}
|
|
315
316
|
}
|
|
316
|
-
throw new Error()
|
|
317
|
+
throw new Error("Failed to Cohere")
|
|
317
318
|
}
|
|
318
319
|
|
|
319
320
|
}
|