bedrock-wrapper 2.6.1 → 2.7.0
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/.example.env +12 -13
- package/CHANGELOG.md +64 -24
- package/LICENSE +21 -21
- package/README.md +13 -27
- package/bedrock-models.js +175 -11
- package/bedrock-wrapper.js +27 -84
- package/example-converse-api.js +1 -3
- package/interactive-example.js +0 -2
- package/package.json +3 -3
- package/test-converse-api.js +0 -4
- package/test-deepseek-quick.js +66 -0
- package/test-deepseek.js +64 -0
- package/test-models.js +0 -2
- package/test-stop-sequences.js +0 -1
- package/logs/e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3/notification.json +0 -72
- package/logs/e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3/post_tool_use.json +0 -9083
- package/logs/e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3/pre_tool_use.json +0 -2971
- package/logs/e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3/stop.json +0 -93
- package/logs/e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3/user_prompt_submit.json +0 -93
package/bedrock-wrapper.js
CHANGED
|
@@ -144,10 +144,18 @@ async function convertToConverseFormat(messages) {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
// Only add messages with actual content (Converse API doesn't allow empty content)
|
|
147
|
-
|
|
147
|
+
// Filter out content items with empty text
|
|
148
|
+
const validContent = content.filter(item => {
|
|
149
|
+
if (item.text !== undefined) {
|
|
150
|
+
return item.text !== null && item.text !== '';
|
|
151
|
+
}
|
|
152
|
+
return true; // Keep non-text items (like images)
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
if (validContent.length > 0) {
|
|
148
156
|
converseMessages.push({
|
|
149
157
|
role: msg.role,
|
|
150
|
-
content:
|
|
158
|
+
content: validContent
|
|
151
159
|
});
|
|
152
160
|
}
|
|
153
161
|
}
|
|
@@ -288,59 +296,8 @@ function buildInvokePrompt(message_cleaned, awsModel) {
|
|
|
288
296
|
}
|
|
289
297
|
}
|
|
290
298
|
|
|
291
|
-
// Apply parameter restrictions for models that have them
|
|
292
|
-
function applyParameterRestrictions(params, awsModel) {
|
|
293
|
-
if (!awsModel.parameter_restrictions) {
|
|
294
|
-
return params;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
const restrictions = awsModel.parameter_restrictions;
|
|
298
|
-
|
|
299
|
-
// Handle mutually exclusive parameters
|
|
300
|
-
if (restrictions.mutually_exclusive) {
|
|
301
|
-
for (const exclusiveGroup of restrictions.mutually_exclusive) {
|
|
302
|
-
// Check for both top_p and topP variants
|
|
303
|
-
const presentParams = exclusiveGroup.filter(param => {
|
|
304
|
-
if (param === 'top_p') {
|
|
305
|
-
return (params['top_p'] !== undefined && params['top_p'] !== null) ||
|
|
306
|
-
(params['topP'] !== undefined && params['topP'] !== null);
|
|
307
|
-
}
|
|
308
|
-
return params[param] !== undefined && params[param] !== null;
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
if (presentParams.length > 1) {
|
|
312
|
-
// Keep the first parameter and remove others
|
|
313
|
-
// For temperature/top_p, prioritize temperature as it's more commonly used
|
|
314
|
-
const priorityOrder = ['temperature', 'top_p'];
|
|
315
|
-
const sortedParams = presentParams.sort((a, b) => {
|
|
316
|
-
const aIndex = priorityOrder.indexOf(a);
|
|
317
|
-
const bIndex = priorityOrder.indexOf(b);
|
|
318
|
-
if (aIndex !== -1 && bIndex !== -1) return aIndex - bIndex;
|
|
319
|
-
if (aIndex !== -1) return -1;
|
|
320
|
-
if (bIndex !== -1) return 1;
|
|
321
|
-
return 0;
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
// Keep the first (highest priority) parameter, remove others
|
|
325
|
-
for (let i = 1; i < sortedParams.length; i++) {
|
|
326
|
-
const paramToRemove = sortedParams[i];
|
|
327
|
-
if (paramToRemove === 'top_p') {
|
|
328
|
-
// Remove both variants
|
|
329
|
-
delete params['top_p'];
|
|
330
|
-
delete params['topP'];
|
|
331
|
-
} else {
|
|
332
|
-
delete params[paramToRemove];
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
return params;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
299
|
// Build request object for Invoke API (model-specific)
|
|
343
|
-
function buildInvokeRequest(prompt, awsModel, max_gen_tokens, temperature,
|
|
300
|
+
function buildInvokeRequest(prompt, awsModel, max_gen_tokens, temperature, stop_sequences, stop, system_message) {
|
|
344
301
|
if (awsModel.messages_api) {
|
|
345
302
|
// Check if this is a Nova model (has schemaVersion in special_request_schema)
|
|
346
303
|
if (awsModel.special_request_schema?.schemaVersion === "messages-v1") {
|
|
@@ -384,15 +341,11 @@ function buildInvokeRequest(prompt, awsModel, max_gen_tokens, temperature, top_p
|
|
|
384
341
|
let inferenceConfig = {
|
|
385
342
|
[awsModel.max_tokens_param_name]: max_gen_tokens,
|
|
386
343
|
temperature: temperature,
|
|
387
|
-
topP: top_p,
|
|
388
344
|
...(awsModel.stop_sequences_param_name && stopSequencesValue && {
|
|
389
345
|
[awsModel.stop_sequences_param_name]: Array.isArray(stopSequencesValue) ? stopSequencesValue : [stopSequencesValue]
|
|
390
346
|
})
|
|
391
347
|
};
|
|
392
|
-
|
|
393
|
-
// Apply parameter restrictions
|
|
394
|
-
inferenceConfig = applyParameterRestrictions(inferenceConfig, awsModel);
|
|
395
|
-
|
|
348
|
+
|
|
396
349
|
const novaRequest = {
|
|
397
350
|
...awsModel.special_request_schema,
|
|
398
351
|
messages: novaMessages,
|
|
@@ -415,16 +368,12 @@ function buildInvokeRequest(prompt, awsModel, max_gen_tokens, temperature, top_p
|
|
|
415
368
|
...(awsModel.system_as_separate_field && system_message && { system: system_message }),
|
|
416
369
|
[awsModel.max_tokens_param_name]: max_gen_tokens,
|
|
417
370
|
temperature: temperature,
|
|
418
|
-
top_p: top_p,
|
|
419
371
|
...(awsModel.stop_sequences_param_name && stopSequencesValue && {
|
|
420
372
|
[awsModel.stop_sequences_param_name]: Array.isArray(stopSequencesValue) ? stopSequencesValue : [stopSequencesValue]
|
|
421
373
|
}),
|
|
422
374
|
...awsModel.special_request_schema
|
|
423
375
|
};
|
|
424
|
-
|
|
425
|
-
// Apply parameter restrictions
|
|
426
|
-
request = applyParameterRestrictions(request, awsModel);
|
|
427
|
-
|
|
376
|
+
|
|
428
377
|
return request;
|
|
429
378
|
}
|
|
430
379
|
} else {
|
|
@@ -433,17 +382,16 @@ function buildInvokeRequest(prompt, awsModel, max_gen_tokens, temperature, top_p
|
|
|
433
382
|
prompt: typeof prompt === 'string' ? prompt : {
|
|
434
383
|
messages: prompt.map(msg => ({
|
|
435
384
|
role: msg.role,
|
|
436
|
-
content: Array.isArray(msg.content) ?
|
|
437
|
-
msg.content.map(item =>
|
|
385
|
+
content: Array.isArray(msg.content) ?
|
|
386
|
+
msg.content.map(item =>
|
|
438
387
|
item.type === 'text' ? item.text : item
|
|
439
|
-
).join('\n') :
|
|
388
|
+
).join('\n') :
|
|
440
389
|
msg.content
|
|
441
390
|
}))
|
|
442
391
|
},
|
|
443
392
|
// Optional inference parameters:
|
|
444
393
|
[awsModel.max_tokens_param_name]: max_gen_tokens,
|
|
445
394
|
temperature: temperature,
|
|
446
|
-
top_p: top_p,
|
|
447
395
|
...(() => {
|
|
448
396
|
const stopSequencesValue = stop_sequences || stop;
|
|
449
397
|
return awsModel.stop_sequences_param_name && stopSequencesValue ? {
|
|
@@ -452,10 +400,7 @@ function buildInvokeRequest(prompt, awsModel, max_gen_tokens, temperature, top_p
|
|
|
452
400
|
})(),
|
|
453
401
|
...awsModel.special_request_schema
|
|
454
402
|
};
|
|
455
|
-
|
|
456
|
-
// Apply parameter restrictions
|
|
457
|
-
request = applyParameterRestrictions(request, awsModel);
|
|
458
|
-
|
|
403
|
+
|
|
459
404
|
return request;
|
|
460
405
|
}
|
|
461
406
|
}
|
|
@@ -555,10 +500,15 @@ async function* executeInvokeAPI(client, request, awsModelId, shouldStream, awsM
|
|
|
555
500
|
|
|
556
501
|
export async function* bedrockWrapper(awsCreds, openaiChatCompletionsCreateObject, { logging = false, useConverseAPI = false } = {} ) {
|
|
557
502
|
const { region, accessKeyId, secretAccessKey } = awsCreds;
|
|
558
|
-
let { messages, model, max_tokens, stream, temperature,
|
|
503
|
+
let { messages, model, max_tokens, stream, temperature, include_thinking_data, stop, stop_sequences } = openaiChatCompletionsCreateObject;
|
|
559
504
|
|
|
560
505
|
let {awsModelId, awsModel} = findAwsModelWithId(model);
|
|
561
|
-
|
|
506
|
+
|
|
507
|
+
// Force Converse API for models that only support it
|
|
508
|
+
if (awsModel.converse_api_only) {
|
|
509
|
+
useConverseAPI = true;
|
|
510
|
+
}
|
|
511
|
+
|
|
562
512
|
// Create a Bedrock Runtime client
|
|
563
513
|
const client = new BedrockRuntimeClient({
|
|
564
514
|
region: region,
|
|
@@ -585,19 +535,14 @@ export async function* bedrockWrapper(awsCreds, openaiChatCompletionsCreateObjec
|
|
|
585
535
|
// Build inference configuration (handle thinking mode for Claude models)
|
|
586
536
|
let inferenceConfig = {
|
|
587
537
|
maxTokens: max_gen_tokens,
|
|
588
|
-
temperature: temperature
|
|
589
|
-
...(top_p !== undefined && { topP: top_p })
|
|
538
|
+
temperature: temperature
|
|
590
539
|
};
|
|
591
|
-
|
|
592
|
-
// Apply parameter restrictions for Converse API
|
|
593
|
-
inferenceConfig = applyParameterRestrictions(inferenceConfig, awsModel);
|
|
594
|
-
|
|
540
|
+
|
|
595
541
|
// Handle thinking mode for Claude models
|
|
596
542
|
let budget_tokens;
|
|
597
543
|
if (awsModel.special_request_schema?.thinking?.type === "enabled") {
|
|
598
544
|
// Apply thinking mode constraints for Converse API
|
|
599
545
|
inferenceConfig.temperature = 1; // temperature must be 1 for thinking
|
|
600
|
-
delete inferenceConfig.topP; // top_p must be unset for thinking
|
|
601
546
|
|
|
602
547
|
// Calculate thinking budget configuration
|
|
603
548
|
budget_tokens = awsModel.special_request_schema?.thinking?.budget_tokens;
|
|
@@ -762,8 +707,6 @@ export async function* bedrockWrapper(awsCreds, openaiChatCompletionsCreateObjec
|
|
|
762
707
|
if (awsModel.special_request_schema?.thinking?.type === "enabled") {
|
|
763
708
|
// temperature may only be set to 1 when thinking is enabled
|
|
764
709
|
temperature = 1;
|
|
765
|
-
// top_p must be unset when thinking is enabled
|
|
766
|
-
top_p = undefined;
|
|
767
710
|
// budget_tokens can not be greater than 80% of max_gen_tokens
|
|
768
711
|
let budget_tokens = awsModel.special_request_schema?.thinking?.budget_tokens;
|
|
769
712
|
if (budget_tokens > (max_gen_tokens * 0.8)) {
|
|
@@ -784,7 +727,7 @@ export async function* bedrockWrapper(awsCreds, openaiChatCompletionsCreateObjec
|
|
|
784
727
|
}
|
|
785
728
|
|
|
786
729
|
// Build request for Invoke API (complex, model-specific)
|
|
787
|
-
const request = buildInvokeRequest(prompt, awsModel, max_gen_tokens, temperature,
|
|
730
|
+
const request = buildInvokeRequest(prompt, awsModel, max_gen_tokens, temperature, stop_sequences, stop, system_message);
|
|
788
731
|
|
|
789
732
|
if (logging) {
|
|
790
733
|
console.log("\nFinal request:", JSON.stringify(request, null, 2));
|
package/example-converse-api.js
CHANGED
|
@@ -32,7 +32,6 @@ async function main() {
|
|
|
32
32
|
max_tokens: 500,
|
|
33
33
|
stream: true, // Can be true or false
|
|
34
34
|
temperature: 0.7,
|
|
35
|
-
top_p: 0.9,
|
|
36
35
|
stop: ["END", "STOP"] // Optional stop sequences
|
|
37
36
|
};
|
|
38
37
|
|
|
@@ -80,8 +79,7 @@ async function main() {
|
|
|
80
79
|
model: "Claude-3-Haiku",
|
|
81
80
|
max_tokens: 50,
|
|
82
81
|
stream: false,
|
|
83
|
-
temperature: 0.1
|
|
84
|
-
top_p: 0.9
|
|
82
|
+
temperature: 0.1
|
|
85
83
|
};
|
|
86
84
|
|
|
87
85
|
// Test with Invoke API
|
package/interactive-example.js
CHANGED
|
@@ -15,7 +15,6 @@ const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;
|
|
|
15
15
|
const AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY;
|
|
16
16
|
const LLM_MAX_GEN_TOKENS = parseInt(process.env.LLM_MAX_GEN_TOKENS);
|
|
17
17
|
const LLM_TEMPERATURE = parseFloat(process.env.LLM_TEMPERATURE);
|
|
18
|
-
const LLM_TOP_P = parseFloat(process.env.LLM_TOP_P);
|
|
19
18
|
|
|
20
19
|
// --------------------------------------------
|
|
21
20
|
// -- import functions from bedrock-wrapper --
|
|
@@ -129,7 +128,6 @@ const openaiChatCompletionsCreateObject = {
|
|
|
129
128
|
"max_tokens": LLM_MAX_GEN_TOKENS,
|
|
130
129
|
"stream": shouldStream,
|
|
131
130
|
"temperature": LLM_TEMPERATURE,
|
|
132
|
-
"top_p": LLM_TOP_P,
|
|
133
131
|
"include_thinking_data": true,
|
|
134
132
|
};
|
|
135
133
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bedrock-wrapper",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
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
|
"homepage": "https://www.equilllabs.com/projects/bedrock-wrapper",
|
|
6
6
|
"repository": {
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"author": "",
|
|
42
42
|
"license": "ISC",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@aws-sdk/client-bedrock-runtime": "^3.
|
|
44
|
+
"@aws-sdk/client-bedrock-runtime": "^3.934.0",
|
|
45
45
|
"dotenv": "^17.2.3",
|
|
46
|
-
"sharp": "^0.34.
|
|
46
|
+
"sharp": "^0.34.5"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"chalk": "^5.6.2"
|
package/test-converse-api.js
CHANGED
|
@@ -16,7 +16,6 @@ const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;
|
|
|
16
16
|
const AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY;
|
|
17
17
|
const LLM_MAX_GEN_TOKENS = parseInt(process.env.LLM_MAX_GEN_TOKENS);
|
|
18
18
|
const LLM_TEMPERATURE = parseFloat(process.env.LLM_TEMPERATURE);
|
|
19
|
-
const LLM_TOP_P = parseFloat(process.env.LLM_TOP_P);
|
|
20
19
|
|
|
21
20
|
// --------------------------------------------
|
|
22
21
|
// -- import functions from bedrock-wrapper --
|
|
@@ -60,7 +59,6 @@ async function testModelWithAPI(model, awsCreds, testMessage, isStreaming, useCo
|
|
|
60
59
|
max_tokens: LLM_MAX_GEN_TOKENS,
|
|
61
60
|
stream: isStreaming,
|
|
62
61
|
temperature: LLM_TEMPERATURE,
|
|
63
|
-
top_p: LLM_TOP_P,
|
|
64
62
|
};
|
|
65
63
|
|
|
66
64
|
let completeResponse = "";
|
|
@@ -152,7 +150,6 @@ async function testStopSequences(model, awsCreds) {
|
|
|
152
150
|
max_tokens: 100,
|
|
153
151
|
stream: false,
|
|
154
152
|
temperature: 0.1,
|
|
155
|
-
top_p: 0.9,
|
|
156
153
|
stop: ["6"] // Stop at "6"
|
|
157
154
|
};
|
|
158
155
|
|
|
@@ -208,7 +205,6 @@ async function testSystemPrompt(model, awsCreds) {
|
|
|
208
205
|
max_tokens: 100,
|
|
209
206
|
stream: false,
|
|
210
207
|
temperature: 0.7,
|
|
211
|
-
top_p: 0.9,
|
|
212
208
|
};
|
|
213
209
|
|
|
214
210
|
try {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Quick test for DeepSeek models using interactive example logic
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
5
|
+
import { bedrockWrapper } from "./bedrock-wrapper.js";
|
|
6
|
+
|
|
7
|
+
const AWS_REGION = process.env.AWS_REGION;
|
|
8
|
+
const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;
|
|
9
|
+
const AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY;
|
|
10
|
+
|
|
11
|
+
const awsCreds = {
|
|
12
|
+
region: AWS_REGION,
|
|
13
|
+
accessKeyId: AWS_ACCESS_KEY_ID,
|
|
14
|
+
secretAccessKey: AWS_SECRET_ACCESS_KEY,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
async function quickTest(modelName, useConverseAPI) {
|
|
18
|
+
const apiType = useConverseAPI ? "Converse API" : "Invoke API";
|
|
19
|
+
console.log(`\nTesting ${modelName} with ${apiType}...`);
|
|
20
|
+
|
|
21
|
+
const messages = [
|
|
22
|
+
{ role: "user", content: "What is 2+2? Answer with just the number." }
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const requestObject = {
|
|
26
|
+
messages,
|
|
27
|
+
model: modelName,
|
|
28
|
+
max_tokens: 50,
|
|
29
|
+
stream: false,
|
|
30
|
+
temperature: 0.1,
|
|
31
|
+
include_thinking_data: true,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const response = await bedrockWrapper(awsCreds, requestObject, { logging: false, useConverseAPI });
|
|
36
|
+
let completeResponse = "";
|
|
37
|
+
for await (const data of response) {
|
|
38
|
+
completeResponse += data;
|
|
39
|
+
}
|
|
40
|
+
console.log(`✓ SUCCESS: ${completeResponse.trim().substring(0, 100)}...`);
|
|
41
|
+
return true;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.log(`✗ FAILED: ${error.message}`);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function main() {
|
|
49
|
+
console.log("\n" + "=".repeat(60));
|
|
50
|
+
console.log("QUICK DEEPSEEK MODEL TEST");
|
|
51
|
+
console.log("=".repeat(60));
|
|
52
|
+
|
|
53
|
+
const models = ["DeepSeek-R1", "DeepSeek-V3.1"];
|
|
54
|
+
|
|
55
|
+
for (const model of models) {
|
|
56
|
+
console.log(`\n--- Testing ${model} ---`);
|
|
57
|
+
await quickTest(model, false); // Invoke API
|
|
58
|
+
await quickTest(model, true); // Converse API
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
console.log("\n" + "=".repeat(60));
|
|
62
|
+
console.log("Tests completed!");
|
|
63
|
+
console.log("=".repeat(60) + "\n");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
main().catch(console.error);
|
package/test-deepseek.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Simple test for DeepSeek models
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
5
|
+
import { bedrockWrapper } from "./bedrock-wrapper.js";
|
|
6
|
+
|
|
7
|
+
const AWS_REGION = process.env.AWS_REGION;
|
|
8
|
+
const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;
|
|
9
|
+
const AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY;
|
|
10
|
+
|
|
11
|
+
const awsCreds = {
|
|
12
|
+
region: AWS_REGION,
|
|
13
|
+
accessKeyId: AWS_ACCESS_KEY_ID,
|
|
14
|
+
secretAccessKey: AWS_SECRET_ACCESS_KEY,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
async function testDeepSeekModel(modelName) {
|
|
18
|
+
console.log(`\nTesting ${modelName}...`);
|
|
19
|
+
|
|
20
|
+
const messages = [{ role: "user", content: "What is 2+2? Respond with just the number." }];
|
|
21
|
+
const requestObject = {
|
|
22
|
+
messages,
|
|
23
|
+
model: modelName,
|
|
24
|
+
max_tokens: 100,
|
|
25
|
+
stream: false,
|
|
26
|
+
temperature: 0.1,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const response = await bedrockWrapper(awsCreds, requestObject, { logging: true, useConverseAPI: false });
|
|
31
|
+
let completeResponse = "";
|
|
32
|
+
for await (const data of response) {
|
|
33
|
+
completeResponse += data;
|
|
34
|
+
}
|
|
35
|
+
console.log(`✓ ${modelName} (Invoke API): ${completeResponse.trim()}`);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.log(`✗ ${modelName} (Invoke API): ${error.message}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Test with Converse API
|
|
41
|
+
try {
|
|
42
|
+
const response = await bedrockWrapper(awsCreds, requestObject, { logging: true, useConverseAPI: true });
|
|
43
|
+
let completeResponse = "";
|
|
44
|
+
for await (const data of response) {
|
|
45
|
+
completeResponse += data;
|
|
46
|
+
}
|
|
47
|
+
console.log(`✓ ${modelName} (Converse API): ${completeResponse.trim()}`);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.log(`✗ ${modelName} (Converse API): ${error.message}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function main() {
|
|
54
|
+
console.log("Testing DeepSeek Models\n");
|
|
55
|
+
console.log("=".repeat(50));
|
|
56
|
+
|
|
57
|
+
await testDeepSeekModel("DeepSeek-R1");
|
|
58
|
+
await testDeepSeekModel("DeepSeek-V3.1");
|
|
59
|
+
|
|
60
|
+
console.log("\n" + "=".repeat(50));
|
|
61
|
+
console.log("DeepSeek tests completed!");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
main().catch(console.error);
|
package/test-models.js
CHANGED
|
@@ -16,7 +16,6 @@ const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;
|
|
|
16
16
|
const AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY;
|
|
17
17
|
const LLM_MAX_GEN_TOKENS = parseInt(process.env.LLM_MAX_GEN_TOKENS);
|
|
18
18
|
const LLM_TEMPERATURE = parseFloat(process.env.LLM_TEMPERATURE);
|
|
19
|
-
const LLM_TOP_P = parseFloat(process.env.LLM_TOP_P);
|
|
20
19
|
|
|
21
20
|
// --------------------------------------------
|
|
22
21
|
// -- import functions from bedrock-wrapper --
|
|
@@ -59,7 +58,6 @@ async function testModel(model, awsCreds, testMessage, isStreaming, useConverseA
|
|
|
59
58
|
max_tokens: LLM_MAX_GEN_TOKENS,
|
|
60
59
|
stream: isStreaming,
|
|
61
60
|
temperature: LLM_TEMPERATURE,
|
|
62
|
-
top_p: LLM_TOP_P,
|
|
63
61
|
include_thinking_data: true,
|
|
64
62
|
};
|
|
65
63
|
|
package/test-stop-sequences.js
CHANGED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"session_id": "e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3",
|
|
4
|
-
"transcript_path": "C:\\Users\\Justin.Parker\\.claude\\projects\\C--git-bedrock-wrapper\\e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3.jsonl",
|
|
5
|
-
"cwd": "C:\\git\\bedrock-wrapper",
|
|
6
|
-
"hook_event_name": "Notification",
|
|
7
|
-
"message": "Claude needs your permission to use context7 - resolve-library-id (MCP)"
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"session_id": "e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3",
|
|
11
|
-
"transcript_path": "C:\\Users\\Justin.Parker\\.claude\\projects\\C--git-bedrock-wrapper\\e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3.jsonl",
|
|
12
|
-
"cwd": "C:\\git\\bedrock-wrapper",
|
|
13
|
-
"hook_event_name": "Notification",
|
|
14
|
-
"message": "Claude needs your permission to use context7 - get-library-docs (MCP)"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"session_id": "e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3",
|
|
18
|
-
"transcript_path": "C:\\Users\\Justin.Parker\\.claude\\projects\\C--git-bedrock-wrapper\\e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3.jsonl",
|
|
19
|
-
"cwd": "C:\\git\\bedrock-wrapper",
|
|
20
|
-
"hook_event_name": "Notification",
|
|
21
|
-
"message": "Claude is waiting for your input"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"session_id": "e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3",
|
|
25
|
-
"transcript_path": "C:\\Users\\Justin.Parker\\.claude\\projects\\C--git-bedrock-wrapper\\e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3.jsonl",
|
|
26
|
-
"cwd": "C:\\git\\bedrock-wrapper",
|
|
27
|
-
"hook_event_name": "Notification",
|
|
28
|
-
"message": "Claude is waiting for your input"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"session_id": "e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3",
|
|
32
|
-
"transcript_path": "C:\\Users\\Justin.Parker\\.claude\\projects\\C--git-bedrock-wrapper\\e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3.jsonl",
|
|
33
|
-
"cwd": "C:\\git\\bedrock-wrapper",
|
|
34
|
-
"hook_event_name": "Notification",
|
|
35
|
-
"message": "Claude is waiting for your input"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"session_id": "e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3",
|
|
39
|
-
"transcript_path": "C:\\Users\\Justin.Parker\\.claude\\projects\\C--git-bedrock-wrapper\\e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3.jsonl",
|
|
40
|
-
"cwd": "C:\\git\\bedrock-wrapper",
|
|
41
|
-
"hook_event_name": "Notification",
|
|
42
|
-
"message": "Claude is waiting for your input"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"session_id": "e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3",
|
|
46
|
-
"transcript_path": "C:\\Users\\Justin.Parker\\.claude\\projects\\C--git-bedrock-wrapper\\e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3.jsonl",
|
|
47
|
-
"cwd": "C:\\git\\bedrock-wrapper",
|
|
48
|
-
"hook_event_name": "Notification",
|
|
49
|
-
"message": "Claude is waiting for your input"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"session_id": "e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3",
|
|
53
|
-
"transcript_path": "C:\\Users\\Justin.Parker\\.claude\\projects\\C--git-bedrock-wrapper\\e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3.jsonl",
|
|
54
|
-
"cwd": "C:\\git\\bedrock-wrapper",
|
|
55
|
-
"hook_event_name": "Notification",
|
|
56
|
-
"message": "Claude is waiting for your input"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"session_id": "e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3",
|
|
60
|
-
"transcript_path": "C:\\Users\\Justin.Parker\\.claude\\projects\\C--git-bedrock-wrapper\\e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3.jsonl",
|
|
61
|
-
"cwd": "C:\\git\\bedrock-wrapper",
|
|
62
|
-
"hook_event_name": "Notification",
|
|
63
|
-
"message": "Claude needs your permission to use "
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
"session_id": "e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3",
|
|
67
|
-
"transcript_path": "C:\\Users\\Justin.Parker\\.claude\\projects\\C--git-bedrock-wrapper\\e4cf59ef-9d22-45bf-9c6c-53e3cb9efda3.jsonl",
|
|
68
|
-
"cwd": "C:\\git\\bedrock-wrapper",
|
|
69
|
-
"hook_event_name": "Notification",
|
|
70
|
-
"message": "Claude is waiting for your input"
|
|
71
|
-
}
|
|
72
|
-
]
|