bedrock-wrapper 2.4.4 → 2.5.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.
@@ -72,8 +72,16 @@ const shouldStream = await new Promise((resolve) => {
72
72
  });
73
73
  });
74
74
 
75
+ // Ask for API preference
76
+ const useConverseAPI = await new Promise((resolve) => {
77
+ rl.question('\nUse Converse API instead of Invoke API? (Y/n): ', (answer) => {
78
+ resolve(answer.toLowerCase() !== 'n');
79
+ });
80
+ });
81
+
75
82
  console.log(`\nUsing model: ${selectedModel}`);
76
- console.log(`Streaming: ${shouldStream ? 'enabled' : 'disabled'}\n`);
83
+ console.log(`Streaming: ${shouldStream ? 'enabled' : 'disabled'}`);
84
+ console.log(`API: ${useConverseAPI ? 'Converse API' : 'Invoke API'}\n`);
77
85
 
78
86
  const defaultPrompt = "Describe what the openai api standard used by lots of serverless LLM api providers is and why it has been widely adopted.";
79
87
 
@@ -89,19 +97,19 @@ const userPrompt = await new Promise((resolve) => {
89
97
  // -- example prompt in `messages` array format --
90
98
  // -----------------------------------------------
91
99
  const messages = [
92
- {
93
- role: "system",
94
- content: "You are a helpful AI assistant that follows instructions extremely well. Answer the user questions accurately. Think step by step before answering the question.",
95
- },
96
100
  {
97
101
  role: "user",
98
102
  content: userPrompt,
99
103
  },
100
- {
104
+ ];
105
+
106
+ // Only add empty assistant message for Invoke API (Converse API handles this automatically)
107
+ if (!useConverseAPI) {
108
+ messages.push({
101
109
  role: "assistant",
102
110
  content: "",
103
- },
104
- ];
111
+ });
112
+ }
105
113
 
106
114
 
107
115
  // ---------------------------------------------------
@@ -133,7 +141,7 @@ const openaiChatCompletionsCreateObject = {
133
141
  let completeResponse = "";
134
142
  // streamed call
135
143
  if (openaiChatCompletionsCreateObject.stream) {
136
- for await (const chunk of bedrockWrapper(awsCreds, openaiChatCompletionsCreateObject, { logging:true })) {
144
+ for await (const chunk of bedrockWrapper(awsCreds, openaiChatCompletionsCreateObject, { logging:true, useConverseAPI })) {
137
145
  completeResponse += chunk;
138
146
  // ---------------------------------------------------
139
147
  // -- each chunk is streamed as it is received here --
@@ -141,7 +149,7 @@ if (openaiChatCompletionsCreateObject.stream) {
141
149
  process.stdout.write(chunk); // ⇠ do stuff with the streamed chunk
142
150
  }
143
151
  } else { // unstreamed call
144
- const response = await bedrockWrapper(awsCreds, openaiChatCompletionsCreateObject, { logging:true });
152
+ const response = await bedrockWrapper(awsCreds, openaiChatCompletionsCreateObject, { logging:true, useConverseAPI });
145
153
  for await (const data of response) {
146
154
  completeResponse += data;
147
155
  }
@@ -0,0 +1,58 @@
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
+ ]