triangle-utils 1.4.48 → 1.4.50
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.d.ts +3 -1
- package/dist/src/UtilsBedrock.js +11 -13
- package/package.json +1 -1
- package/src/UtilsBedrock.ts +18 -13
|
@@ -2,7 +2,9 @@ export declare class UtilsBedrock {
|
|
|
2
2
|
private readonly bedrock;
|
|
3
3
|
private readonly text_decoder;
|
|
4
4
|
constructor(region: string);
|
|
5
|
-
claude_sonnet_invoke(model_id: string, prompt: string, attachment_pdf?: string
|
|
5
|
+
claude_sonnet_invoke(model_id: string, prompt: string, attachment_pdf?: string, options?: {
|
|
6
|
+
max_tokens?: number;
|
|
7
|
+
}): Promise<string | undefined>;
|
|
6
8
|
nova_invoke(model_id: string, prompt: string): Promise<string | undefined>;
|
|
7
9
|
llama_invoke(model_id: string, prompt: string, temperature?: number, max_gen_len?: number, top_p?: number): Promise<string | undefined>;
|
|
8
10
|
gpt_converse(model_id: string, prompt: string, temperature?: number, max_gen_len?: number, top_p?: number): Promise<string | undefined>;
|
package/dist/src/UtilsBedrock.js
CHANGED
|
@@ -6,7 +6,7 @@ export class UtilsBedrock {
|
|
|
6
6
|
this.bedrock = new BedrockRuntime({ region: region });
|
|
7
7
|
this.text_decoder = new TextDecoder();
|
|
8
8
|
}
|
|
9
|
-
async claude_sonnet_invoke(model_id, prompt, attachment_pdf) {
|
|
9
|
+
async claude_sonnet_invoke(model_id, prompt, attachment_pdf, options = {}) {
|
|
10
10
|
for (let i = 0; i < 3; i++) {
|
|
11
11
|
try {
|
|
12
12
|
const response = await this.bedrock.invokeModel({
|
|
@@ -20,21 +20,19 @@ export class UtilsBedrock {
|
|
|
20
20
|
text: prompt
|
|
21
21
|
},
|
|
22
22
|
...(attachment_pdf !== undefined ? [{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
cache_control: { "type": "ephemeral" }
|
|
33
|
-
}
|
|
23
|
+
type: "document",
|
|
24
|
+
source: {
|
|
25
|
+
type: "base64",
|
|
26
|
+
media_type: "application/pdf",
|
|
27
|
+
data: attachment_pdf
|
|
28
|
+
},
|
|
29
|
+
title: "Attachment",
|
|
30
|
+
citations: { "enabled": false },
|
|
31
|
+
cache_control: { "type": "ephemeral" }
|
|
34
32
|
}] : [])
|
|
35
33
|
]
|
|
36
34
|
}],
|
|
37
|
-
max_tokens:
|
|
35
|
+
max_tokens: options.max_tokens || 1000,
|
|
38
36
|
temperature: 0,
|
|
39
37
|
anthropic_version: "bedrock-2023-05-31"
|
|
40
38
|
})
|
package/package.json
CHANGED
package/src/UtilsBedrock.ts
CHANGED
|
@@ -10,7 +10,14 @@ export class UtilsBedrock {
|
|
|
10
10
|
this.text_decoder = new TextDecoder()
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
async claude_sonnet_invoke(
|
|
13
|
+
async claude_sonnet_invoke(
|
|
14
|
+
model_id : string,
|
|
15
|
+
prompt : string,
|
|
16
|
+
attachment_pdf? : string,
|
|
17
|
+
options : {
|
|
18
|
+
max_tokens? : number
|
|
19
|
+
} = {}
|
|
20
|
+
) : Promise<string | undefined> {
|
|
14
21
|
for (let i = 0; i < 3; i++) {
|
|
15
22
|
try {
|
|
16
23
|
const response = await this.bedrock.invokeModel({
|
|
@@ -24,21 +31,19 @@ export class UtilsBedrock {
|
|
|
24
31
|
text : prompt
|
|
25
32
|
},
|
|
26
33
|
...(attachment_pdf !== undefined ? [{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
cache_control: {"type": "ephemeral"}
|
|
37
|
-
}
|
|
34
|
+
type: "document",
|
|
35
|
+
source: {
|
|
36
|
+
type: "base64",
|
|
37
|
+
media_type: "application/pdf",
|
|
38
|
+
data: attachment_pdf
|
|
39
|
+
},
|
|
40
|
+
title: "Attachment",
|
|
41
|
+
citations: { "enabled": false },
|
|
42
|
+
cache_control: {"type": "ephemeral"}
|
|
38
43
|
}] : [])
|
|
39
44
|
]
|
|
40
45
|
}],
|
|
41
|
-
max_tokens:
|
|
46
|
+
max_tokens: options.max_tokens || 1000,
|
|
42
47
|
temperature: 0,
|
|
43
48
|
anthropic_version: "bedrock-2023-05-31"
|
|
44
49
|
})
|