triangle-utils 1.4.85 → 1.4.87
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.
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export type
|
|
3
|
-
export declare function
|
|
1
|
+
declare const roles: readonly ["user", "assistant", "system"];
|
|
2
|
+
export type Role = typeof roles[number];
|
|
3
|
+
export declare function is_role(role: any): role is Role;
|
|
4
4
|
export declare class UtilsBedrock {
|
|
5
5
|
private readonly bedrock_runtime;
|
|
6
6
|
private readonly anthropic_bedrock_mantle;
|
|
7
7
|
private readonly text_decoder;
|
|
8
8
|
constructor(region: string);
|
|
9
9
|
claude_converse(model_id: string, messages: {
|
|
10
|
-
role:
|
|
10
|
+
role: Role;
|
|
11
11
|
text: string;
|
|
12
12
|
}[], options?: {
|
|
13
13
|
system_prompt?: string;
|
|
14
14
|
max_tokens?: number;
|
|
15
15
|
print_usage?: boolean;
|
|
16
|
+
print_content?: boolean;
|
|
16
17
|
json_format?: Record<string, any>;
|
|
17
18
|
web?: boolean;
|
|
18
19
|
cache_period?: "5m" | "1h";
|
package/dist/src/UtilsBedrock.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BedrockRuntime } from "@aws-sdk/client-bedrock-runtime";
|
|
2
2
|
import { AnthropicBedrockMantle } from "@anthropic-ai/bedrock-sdk";
|
|
3
|
-
const
|
|
4
|
-
export function
|
|
5
|
-
return
|
|
3
|
+
const roles = ["user", "assistant", "system"];
|
|
4
|
+
export function is_role(role) {
|
|
5
|
+
return roles.includes(role);
|
|
6
6
|
}
|
|
7
7
|
export class UtilsBedrock {
|
|
8
8
|
bedrock_runtime;
|
|
@@ -44,6 +44,9 @@ export class UtilsBedrock {
|
|
|
44
44
|
if (options.print_usage !== undefined && options.print_usage) {
|
|
45
45
|
console.log(usage);
|
|
46
46
|
}
|
|
47
|
+
if (options.print_content !== undefined && options.print_content) {
|
|
48
|
+
console.log(response.content);
|
|
49
|
+
}
|
|
47
50
|
const text = response.content.filter(content => content.type === "text")[0].text;
|
|
48
51
|
return text;
|
|
49
52
|
}
|
package/package.json
CHANGED
package/src/UtilsBedrock.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BedrockRuntime } from "@aws-sdk/client-bedrock-runtime"
|
|
2
2
|
import { AnthropicBedrockMantle } from "@anthropic-ai/bedrock-sdk"
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const roles = ["user", "assistant", "system"] as const
|
|
5
5
|
|
|
6
|
-
export type
|
|
6
|
+
export type Role = typeof roles[number]
|
|
7
7
|
|
|
8
|
-
export function
|
|
9
|
-
return
|
|
8
|
+
export function is_role(role : any) : role is Role {
|
|
9
|
+
return roles.includes(role)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export class UtilsBedrock {
|
|
@@ -24,11 +24,12 @@ export class UtilsBedrock {
|
|
|
24
24
|
|
|
25
25
|
async claude_converse(
|
|
26
26
|
model_id : string,
|
|
27
|
-
messages : { role :
|
|
27
|
+
messages : { role : Role, text : string }[],
|
|
28
28
|
options : {
|
|
29
29
|
system_prompt? : string,
|
|
30
30
|
max_tokens? : number,
|
|
31
31
|
print_usage? : boolean,
|
|
32
|
+
print_content? : boolean,
|
|
32
33
|
json_format? : Record<string, any>,
|
|
33
34
|
web? : boolean,
|
|
34
35
|
cache_period? : "5m" | "1h"
|
|
@@ -65,6 +66,9 @@ export class UtilsBedrock {
|
|
|
65
66
|
if (options.print_usage !== undefined && options.print_usage) {
|
|
66
67
|
console.log(usage)
|
|
67
68
|
}
|
|
69
|
+
if (options.print_content !== undefined && options.print_content) {
|
|
70
|
+
console.log(response.content)
|
|
71
|
+
}
|
|
68
72
|
const text = response.content.filter(content => content.type === "text")[0].text
|
|
69
73
|
return text
|
|
70
74
|
} catch (error) {
|