triangle-utils 1.4.140 → 1.4.142
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.
|
@@ -12,9 +12,8 @@ export declare class UtilsBedrock {
|
|
|
12
12
|
pdf?: string;
|
|
13
13
|
}[], options?: {
|
|
14
14
|
system_prompt?: string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
print_content?: boolean;
|
|
15
|
+
max_num_tokens?: number;
|
|
16
|
+
verbosity?: number;
|
|
18
17
|
json_format?: Record<string, any>;
|
|
19
18
|
web?: boolean;
|
|
20
19
|
cache_period?: "5m" | "1h";
|
package/dist/src/UtilsBedrock.js
CHANGED
|
@@ -14,6 +14,7 @@ export class UtilsBedrock {
|
|
|
14
14
|
this.anthropic_bedrock_mantle = new AnthropicBedrockMantle({ awsRegion: region, defaultHeaders: { "anthropic-workspace-id": "default" } });
|
|
15
15
|
}
|
|
16
16
|
async claude_converse(model_id, messages, options = {}) {
|
|
17
|
+
const verbosity = options.verbosity || 0;
|
|
17
18
|
try {
|
|
18
19
|
const message_params = [];
|
|
19
20
|
for (const message of messages) {
|
|
@@ -45,8 +46,8 @@ export class UtilsBedrock {
|
|
|
45
46
|
model: model_id,
|
|
46
47
|
messages: message_params,
|
|
47
48
|
system: options.system_prompt,
|
|
48
|
-
tools: options.web === true ? [{ name: "web_search", type: "
|
|
49
|
-
max_tokens: options.
|
|
49
|
+
tools: options.web === true ? [{ name: "web_search", type: "web_search_20250305" }] : undefined,
|
|
50
|
+
max_tokens: options.max_num_tokens || 1000,
|
|
50
51
|
output_config: options.json_format !== undefined ? {
|
|
51
52
|
format: {
|
|
52
53
|
type: "json_schema",
|
|
@@ -59,10 +60,10 @@ export class UtilsBedrock {
|
|
|
59
60
|
// }
|
|
60
61
|
});
|
|
61
62
|
const usage = response.usage;
|
|
62
|
-
if (
|
|
63
|
+
if (verbosity > 0) {
|
|
63
64
|
console.log(usage);
|
|
64
65
|
}
|
|
65
|
-
if (
|
|
66
|
+
if (verbosity > 1) {
|
|
66
67
|
console.log(response.content);
|
|
67
68
|
}
|
|
68
69
|
const text = response.content.filter(content => content.type === "text")[0].text;
|
package/package.json
CHANGED
package/src/UtilsBedrock.ts
CHANGED
|
@@ -28,14 +28,14 @@ export class UtilsBedrock {
|
|
|
28
28
|
messages : { role : Role, text : string, pdf? : string }[],
|
|
29
29
|
options : {
|
|
30
30
|
system_prompt? : string,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
print_content? : boolean,
|
|
31
|
+
max_num_tokens? : number,
|
|
32
|
+
verbosity? : number,
|
|
34
33
|
json_format? : Record<string, any>,
|
|
35
34
|
web? : boolean,
|
|
36
35
|
cache_period? : "5m" | "1h"
|
|
37
36
|
} = {}
|
|
38
37
|
) {
|
|
38
|
+
const verbosity = options.verbosity || 0
|
|
39
39
|
try {
|
|
40
40
|
const message_params : MessageParam[] = []
|
|
41
41
|
for (const message of messages) {
|
|
@@ -62,14 +62,13 @@ export class UtilsBedrock {
|
|
|
62
62
|
role : message.role,
|
|
63
63
|
content : content
|
|
64
64
|
})
|
|
65
|
-
|
|
66
65
|
}
|
|
67
66
|
const response = await this.anthropic_bedrock_mantle.messages.create({
|
|
68
67
|
model : model_id,
|
|
69
68
|
messages : message_params,
|
|
70
69
|
system : options.system_prompt,
|
|
71
|
-
tools : options.web === true ? [{ name : "web_search", type : "
|
|
72
|
-
max_tokens : options.
|
|
70
|
+
tools : options.web === true ? [{ name : "web_search", type : "web_search_20250305" }] : undefined,
|
|
71
|
+
max_tokens : options.max_num_tokens || 1000,
|
|
73
72
|
output_config : options.json_format !== undefined ? {
|
|
74
73
|
format : {
|
|
75
74
|
type : "json_schema",
|
|
@@ -83,10 +82,10 @@ export class UtilsBedrock {
|
|
|
83
82
|
})
|
|
84
83
|
|
|
85
84
|
const usage = response.usage
|
|
86
|
-
if (
|
|
85
|
+
if (verbosity > 0) {
|
|
87
86
|
console.log(usage)
|
|
88
87
|
}
|
|
89
|
-
if (
|
|
88
|
+
if (verbosity > 1) {
|
|
90
89
|
console.log(response.content)
|
|
91
90
|
}
|
|
92
91
|
const text = response.content.filter(content => content.type === "text")[0].text
|