triangle-utils 1.4.50 → 1.4.51

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.
@@ -2,8 +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, options?: {
5
+ claude_invoke(model_id: string, prompt: string, attachment_pdf?: string, options?: {
6
6
  max_tokens?: number;
7
+ print_usage?: boolean;
7
8
  }): Promise<string | undefined>;
8
9
  nova_invoke(model_id: string, prompt: string): Promise<string | undefined>;
9
10
  llama_invoke(model_id: string, prompt: string, temperature?: number, max_gen_len?: number, top_p?: number): Promise<string | undefined>;
@@ -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, options = {}) {
9
+ async claude_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({
@@ -38,6 +38,9 @@ export class UtilsBedrock {
38
38
  })
39
39
  });
40
40
  const body = JSON.parse(this.text_decoder.decode(response.body));
41
+ if (options.print_usage !== undefined && options.print_usage) {
42
+ console.log(body.usage);
43
+ }
41
44
  return body.content[0].text;
42
45
  }
43
46
  catch (error) {
package/dist/src/f.js CHANGED
@@ -16,5 +16,5 @@ const config = {
16
16
  const utils = new TriangleUtils(config);
17
17
  // const foods = await utils.dynamodb.query("triage_docket_documents:register_document_id", { register_document_id : "E6-17065" })
18
18
  // console.log(foods)
19
- const text = await utils.bedrock.claude_sonnet_invoke("global.anthropic.claude-sonnet-4-5-20250929-v1:0", "hi");
19
+ const text = await utils.bedrock.claude_invoke("global.anthropic.claude-opus-4-6-v1", "hi", undefined, { print_usage: true });
20
20
  console.log(text);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.50",
3
+ "version": "1.4.51",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
@@ -10,12 +10,13 @@ export class UtilsBedrock {
10
10
  this.text_decoder = new TextDecoder()
11
11
  }
12
12
 
13
- async claude_sonnet_invoke(
13
+ async claude_invoke(
14
14
  model_id : string,
15
15
  prompt : string,
16
16
  attachment_pdf? : string,
17
17
  options : {
18
- max_tokens? : number
18
+ max_tokens? : number,
19
+ print_usage? : boolean
19
20
  } = {}
20
21
  ) : Promise<string | undefined> {
21
22
  for (let i = 0; i < 3; i++) {
@@ -49,6 +50,9 @@ export class UtilsBedrock {
49
50
  })
50
51
  })
51
52
  const body = JSON.parse(this.text_decoder.decode(response.body))
53
+ if (options.print_usage !== undefined && options.print_usage) {
54
+ console.log(body.usage)
55
+ }
52
56
  return body.content[0].text
53
57
  } catch (error) {
54
58
  if (error instanceof Error) {
package/src/f.ts CHANGED
@@ -27,5 +27,5 @@ const utils = new TriangleUtils(config)
27
27
  // console.log(foods)
28
28
 
29
29
 
30
- const text = await utils.bedrock.claude_sonnet_invoke("global.anthropic.claude-sonnet-4-5-20250929-v1:0", "hi")
30
+ const text = await utils.bedrock.claude_invoke("global.anthropic.claude-opus-4-6-v1", "hi", undefined, { print_usage : true })
31
31
  console.log(text)