triangle-utils 1.4.84 → 1.4.86

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,10 +1,13 @@
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;
1
4
  export declare class UtilsBedrock {
2
5
  private readonly bedrock_runtime;
3
6
  private readonly anthropic_bedrock_mantle;
4
7
  private readonly text_decoder;
5
8
  constructor(region: string);
6
9
  claude_converse(model_id: string, messages: {
7
- role: "user" | "assistant" | "system";
10
+ role: Role;
8
11
  text: string;
9
12
  }[], options?: {
10
13
  system_prompt?: string;
@@ -23,3 +26,4 @@ export declare class UtilsBedrock {
23
26
  gpt_converse(model_id: string, prompt: string, temperature?: number, max_gen_len?: number, top_p?: number): Promise<string | undefined>;
24
27
  titan_invoke(text: string): Promise<number[] | undefined>;
25
28
  }
29
+ export {};
@@ -1,5 +1,9 @@
1
1
  import { BedrockRuntime } from "@aws-sdk/client-bedrock-runtime";
2
2
  import { AnthropicBedrockMantle } from "@anthropic-ai/bedrock-sdk";
3
+ const roles = ["user", "assistant", "system"];
4
+ export function is_role(role) {
5
+ return roles.includes(role);
6
+ }
3
7
  export class UtilsBedrock {
4
8
  bedrock_runtime;
5
9
  anthropic_bedrock_mantle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.84",
3
+ "version": "1.4.86",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
@@ -1,6 +1,14 @@
1
1
  import { BedrockRuntime } from "@aws-sdk/client-bedrock-runtime"
2
2
  import { AnthropicBedrockMantle } from "@anthropic-ai/bedrock-sdk"
3
3
 
4
+ const roles = ["user", "assistant", "system"] as const
5
+
6
+ export type Role = typeof roles[number]
7
+
8
+ export function is_role(role : any) : role is Role {
9
+ return roles.includes(role)
10
+ }
11
+
4
12
  export class UtilsBedrock {
5
13
 
6
14
  private readonly bedrock_runtime : BedrockRuntime
@@ -16,7 +24,7 @@ export class UtilsBedrock {
16
24
 
17
25
  async claude_converse(
18
26
  model_id : string,
19
- messages : { role : "user" | "assistant" | "system", text : string }[],
27
+ messages : { role : Role, text : string }[],
20
28
  options : {
21
29
  system_prompt? : string,
22
30
  max_tokens? : number,