bedrock-wrapper 1.0.12 → 1.0.13
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/bedrock-wrapper.js +12 -23
- package/example.js +4 -1
- package/package.json +1 -1
- package/utils.js +28 -0
package/bedrock-wrapper.js
CHANGED
|
@@ -5,16 +5,27 @@
|
|
|
5
5
|
// == of existing OpenAI-compatible API objects AWS Bedrock's ==
|
|
6
6
|
// == serverless inference LLMs. ==
|
|
7
7
|
// ======================================================================
|
|
8
|
-
writeAsciiArt();
|
|
9
8
|
|
|
10
9
|
// -------------
|
|
11
10
|
// -- imports --
|
|
12
11
|
// -------------
|
|
12
|
+
// Bedrock model configurations
|
|
13
13
|
import { bedrock_models } from "./bedrock-models.js";
|
|
14
|
+
// AWS SDK
|
|
14
15
|
import {
|
|
15
16
|
BedrockRuntimeClient,
|
|
16
17
|
InvokeModelCommand, InvokeModelWithResponseStreamCommand,
|
|
17
18
|
} from "@aws-sdk/client-bedrock-runtime";
|
|
19
|
+
// helper functions
|
|
20
|
+
import {
|
|
21
|
+
getValueByPath,
|
|
22
|
+
writeAsciiArt
|
|
23
|
+
} from "./utils.js";
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// write the ascii art logo on initial load
|
|
27
|
+
writeAsciiArt();
|
|
28
|
+
|
|
18
29
|
|
|
19
30
|
// -------------------
|
|
20
31
|
// -- main function --
|
|
@@ -141,25 +152,3 @@ export async function listBedrockWrapperSupportedModels() {
|
|
|
141
152
|
}
|
|
142
153
|
return supported_models;
|
|
143
154
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
// ----------------------
|
|
147
|
-
// -- helper functions --
|
|
148
|
-
// ----------------------
|
|
149
|
-
// helper function to get a value from an object using a path string
|
|
150
|
-
function getValueByPath(obj, path) {
|
|
151
|
-
// Split the path into an array of keys
|
|
152
|
-
let keys = path.replace(/\[(\w+)\]/g, '.$1').split('.'); // Convert indexes into properties
|
|
153
|
-
// Reduce the keys array to the final value
|
|
154
|
-
return keys.reduce((acc, key) => acc && acc[key], obj);
|
|
155
|
-
}
|
|
156
|
-
// helper function to write ascii art
|
|
157
|
-
function writeAsciiArt() {
|
|
158
|
-
console.log(`
|
|
159
|
-
___ _ _ _ _ _
|
|
160
|
-
| . > ___ _| | _ _ ___ ___ | |__ | | | | _ _ ___ ___ ___ ___ _ _
|
|
161
|
-
| . \/ ._>/ . || '_>/ . \/ | '| / / | | | || '_><_> || . \| . \/ ._>| '_>
|
|
162
|
-
|___/\___.\___||_| \___/\_|_.|_\_\ |__/_/ |_| <___|| _/| _/\___.|_|
|
|
163
|
-
|_| |_|
|
|
164
|
-
`);
|
|
165
|
-
}
|
package/example.js
CHANGED
|
@@ -19,7 +19,10 @@ const LLM_TOP_P = parseFloat(process.env.LLM_TOP_P);
|
|
|
19
19
|
// -- - bedrockWrapper --
|
|
20
20
|
// -- - listBedrockWrapperSupportedModels --
|
|
21
21
|
// --------------------------------------------
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
bedrockWrapper,
|
|
24
|
+
listBedrockWrapperSupportedModels
|
|
25
|
+
} from "bedrock-wrapper";
|
|
23
26
|
|
|
24
27
|
// ----------------------------------------------
|
|
25
28
|
// -- example call to list of supported models --
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bedrock-wrapper",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "🪨 Bedrock Wrapper is an npm package that simplifies the integration of existing OpenAI-compatible API objects with AWS Bedrock's serverless inference LLMs.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
package/utils.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// **********************
|
|
2
|
+
// ** HELPER FUNCTIONS **
|
|
3
|
+
// **********************
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// ----------------------------------------------------
|
|
7
|
+
// -- get a value from an object using a path string --
|
|
8
|
+
// ----------------------------------------------------
|
|
9
|
+
export function getValueByPath(obj, path) {
|
|
10
|
+
// Split the path into an array of keys
|
|
11
|
+
let keys = path.replace(/\[(\w+)\]/g, '.$1').split('.'); // Convert indexes into properties
|
|
12
|
+
// Reduce the keys array to the final value
|
|
13
|
+
return keys.reduce((acc, key) => acc && acc[key], obj);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
// --------------------------
|
|
18
|
+
// -- write ascii art logo --
|
|
19
|
+
// --------------------------
|
|
20
|
+
export async function writeAsciiArt() {
|
|
21
|
+
console.log(`
|
|
22
|
+
___ _ _ _ _ _
|
|
23
|
+
| . > ___ _| | _ _ ___ ___ | |__ | | | | _ _ ___ ___ ___ ___ _ _
|
|
24
|
+
| . \\/ ._>/ . || '_>/ . \\/ | '| / / | | | || '_><_> || . \\| . \\/ ._>| '_>
|
|
25
|
+
|___/\\___.\\___||_| \\___/\\_|_.|_\\_\\ |__/_/ |_| <___|| _/| _/\\___.|_|
|
|
26
|
+
|_| |_|
|
|
27
|
+
`);
|
|
28
|
+
}
|