bedrock-wrapper 1.0.12 → 1.0.14
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/README.md +2 -1
- package/bedrock-models.js +24 -0
- package/bedrock-wrapper.js +12 -23
- package/docs/bedrock-proxy-endpoint.jpg +0 -0
- package/example.js +4 -1
- package/package.json +1 -1
- package/utils.js +28 -0
- package/docs/bedrock-tunnel-endpoint.jpg +0 -0
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# 🪨 Bedrock Wrapper
|
|
2
|
-
Bedrock Wrapper is an npm package that simplifies the integration of existing OpenAI-compatible API objects with AWS Bedrock's serverless inference LLMs. Follow the steps below to integrate into your own application, or alternativly use the
|
|
2
|
+
Bedrock Wrapper is an npm package that simplifies the integration of existing OpenAI-compatible API objects with AWS Bedrock's serverless inference LLMs. Follow the steps below to integrate into your own application, or alternativly use the 🔀 [Bedrock Proxy Endpoint](https://github.com/jparkerweb/bedrock-proxy-endpoint) project to spin up your own custom OpenAI server endpoint for even easier inference (using the standard `baseUrl`, and `apiKey` params).
|
|
3
3
|
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -98,6 +98,7 @@ Bedrock Wrapper is an npm package that simplifies the integration of existing Op
|
|
|
98
98
|
|----------------|------------------------------------|
|
|
99
99
|
| Llama-3-8b | meta.llama3-8b-instruct-v1:0 |
|
|
100
100
|
| Llama-3-70b | meta.llama3-70b-instruct-v1:0 |
|
|
101
|
+
| Mistral-7b | mistral.mistral-7b-instruct-v0:2 |
|
|
101
102
|
| Mixtral-8x7b | mistral.mixtral-8x7b-instruct-v0:1 |
|
|
102
103
|
| Mistral-Large | mistral.mistral-large-2402-v1:0 |
|
|
103
104
|
|
package/bedrock-models.js
CHANGED
|
@@ -48,6 +48,30 @@ export const bedrock_models = [
|
|
|
48
48
|
"max_tokens_param_name": "max_gen_len",
|
|
49
49
|
"response_chunk_element": "generation",
|
|
50
50
|
},
|
|
51
|
+
{
|
|
52
|
+
// ================
|
|
53
|
+
// == Mistral-7b ==
|
|
54
|
+
// ================
|
|
55
|
+
"modelName": "Mistral-7b",
|
|
56
|
+
"modelId": "mistral.mistral-7b-instruct-v0:2",
|
|
57
|
+
"bos_text": "<s>",
|
|
58
|
+
"role_system_message_prefix": "",
|
|
59
|
+
"role_system_message_suffix": "",
|
|
60
|
+
"role_system_prefix": "",
|
|
61
|
+
"role_system_suffix": "",
|
|
62
|
+
"role_user_message_prefix": "[INST]",
|
|
63
|
+
"role_user_message_suffix": "[/INST]",
|
|
64
|
+
"role_user_prefix": "",
|
|
65
|
+
"role_user_suffix": "",
|
|
66
|
+
"role_assistant_message_prefix": "",
|
|
67
|
+
"role_assistant_message_suffix": "",
|
|
68
|
+
"role_assistant_prefix": "",
|
|
69
|
+
"role_assistant_suffix": "",
|
|
70
|
+
"eom_text": "</s>",
|
|
71
|
+
"display_role_names": false,
|
|
72
|
+
"max_tokens_param_name": "max_tokens",
|
|
73
|
+
"response_chunk_element": "outputs[0].text",
|
|
74
|
+
},
|
|
51
75
|
{
|
|
52
76
|
// ==================
|
|
53
77
|
// == Mixtral-8x7b ==
|
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
|
-
}
|
|
Binary file
|
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.14",
|
|
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
|
+
}
|
|
Binary file
|