@bedrockio/ai 0.7.1 → 0.7.3
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/CHANGELOG.md +8 -0
- package/dist/cjs/BaseClient.js +12 -18
- package/dist/cjs/anthropic.js +2 -2
- package/dist/cjs/openai.js +1 -1
- package/dist/esm/BaseClient.js +12 -18
- package/dist/esm/anthropic.js +2 -2
- package/dist/esm/openai.js +1 -1
- package/package.json +2 -2
- package/types/BaseClient.d.ts +5 -2
- package/types/BaseClient.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -26,7 +26,7 @@ class BaseClient {
|
|
|
26
26
|
const { output, stream, schema } = options;
|
|
27
27
|
const response = await this.runPrompt(options);
|
|
28
28
|
if (!stream) {
|
|
29
|
-
this.debug('Response:', response);
|
|
29
|
+
this.debug('Response:', response, options);
|
|
30
30
|
}
|
|
31
31
|
if (output === 'raw') {
|
|
32
32
|
return response;
|
|
@@ -68,7 +68,7 @@ class BaseClient {
|
|
|
68
68
|
const stream = await this.runStream(options);
|
|
69
69
|
// @ts-ignore
|
|
70
70
|
for await (let event of stream) {
|
|
71
|
-
this.debug('Event:', event);
|
|
71
|
+
this.debug('Event:', event, options);
|
|
72
72
|
event = this.normalizeStreamEvent(event);
|
|
73
73
|
if (event) {
|
|
74
74
|
yield event;
|
|
@@ -91,7 +91,7 @@ class BaseClient {
|
|
|
91
91
|
key,
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
this.debug('Extract:', extractEvent);
|
|
94
|
+
this.debug('Extract:', extractEvent, options);
|
|
95
95
|
yield extractEvent;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -193,19 +193,13 @@ class BaseClient {
|
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
195
|
normalizeInput(options) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
role: 'user',
|
|
204
|
-
content: input,
|
|
205
|
-
},
|
|
206
|
-
];
|
|
207
|
-
}
|
|
208
|
-
return input;
|
|
196
|
+
const { input = '' } = options;
|
|
197
|
+
return [
|
|
198
|
+
{
|
|
199
|
+
role: 'user',
|
|
200
|
+
content: input,
|
|
201
|
+
},
|
|
202
|
+
];
|
|
209
203
|
}
|
|
210
204
|
normalizeSchema(options) {
|
|
211
205
|
let { schema } = options;
|
|
@@ -243,8 +237,8 @@ class BaseClient {
|
|
|
243
237
|
}
|
|
244
238
|
};
|
|
245
239
|
}
|
|
246
|
-
debug(message, arg) {
|
|
247
|
-
if (
|
|
240
|
+
debug(message, arg, options) {
|
|
241
|
+
if (options.debug) {
|
|
248
242
|
// TODO: replace with logger when opentelemetry is removed
|
|
249
243
|
// eslint-disable-next-line
|
|
250
244
|
console.debug(`${message}\n${JSON.stringify(arg, null, 2)}\n`);
|
package/dist/cjs/anthropic.js
CHANGED
|
@@ -33,8 +33,8 @@ class AnthropicClient extends BaseClient_js_1.default {
|
|
|
33
33
|
...this.getToolOptions(options),
|
|
34
34
|
};
|
|
35
35
|
const clientOptions = this.getClientOptions(params);
|
|
36
|
-
this.debug('Params:', params);
|
|
37
|
-
this.debug('Options:', options);
|
|
36
|
+
this.debug('Params:', params, options);
|
|
37
|
+
this.debug('Options:', options, options);
|
|
38
38
|
// @ts-ignore
|
|
39
39
|
return await this.client.messages.create(params, clientOptions);
|
|
40
40
|
}
|
package/dist/cjs/openai.js
CHANGED
package/dist/esm/BaseClient.js
CHANGED
|
@@ -24,7 +24,7 @@ export default class BaseClient {
|
|
|
24
24
|
const { output, stream, schema } = options;
|
|
25
25
|
const response = await this.runPrompt(options);
|
|
26
26
|
if (!stream) {
|
|
27
|
-
this.debug('Response:', response);
|
|
27
|
+
this.debug('Response:', response, options);
|
|
28
28
|
}
|
|
29
29
|
if (output === 'raw') {
|
|
30
30
|
return response;
|
|
@@ -66,7 +66,7 @@ export default class BaseClient {
|
|
|
66
66
|
const stream = await this.runStream(options);
|
|
67
67
|
// @ts-ignore
|
|
68
68
|
for await (let event of stream) {
|
|
69
|
-
this.debug('Event:', event);
|
|
69
|
+
this.debug('Event:', event, options);
|
|
70
70
|
event = this.normalizeStreamEvent(event);
|
|
71
71
|
if (event) {
|
|
72
72
|
yield event;
|
|
@@ -89,7 +89,7 @@ export default class BaseClient {
|
|
|
89
89
|
key,
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
this.debug('Extract:', extractEvent);
|
|
92
|
+
this.debug('Extract:', extractEvent, options);
|
|
93
93
|
yield extractEvent;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -191,19 +191,13 @@ export default class BaseClient {
|
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
193
|
normalizeInput(options) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
role: 'user',
|
|
202
|
-
content: input,
|
|
203
|
-
},
|
|
204
|
-
];
|
|
205
|
-
}
|
|
206
|
-
return input;
|
|
194
|
+
const { input = '' } = options;
|
|
195
|
+
return [
|
|
196
|
+
{
|
|
197
|
+
role: 'user',
|
|
198
|
+
content: input,
|
|
199
|
+
},
|
|
200
|
+
];
|
|
207
201
|
}
|
|
208
202
|
normalizeSchema(options) {
|
|
209
203
|
let { schema } = options;
|
|
@@ -241,8 +235,8 @@ export default class BaseClient {
|
|
|
241
235
|
}
|
|
242
236
|
};
|
|
243
237
|
}
|
|
244
|
-
debug(message, arg) {
|
|
245
|
-
if (
|
|
238
|
+
debug(message, arg, options) {
|
|
239
|
+
if (options.debug) {
|
|
246
240
|
// TODO: replace with logger when opentelemetry is removed
|
|
247
241
|
// eslint-disable-next-line
|
|
248
242
|
console.debug(`${message}\n${JSON.stringify(arg, null, 2)}\n`);
|
package/dist/esm/anthropic.js
CHANGED
|
@@ -27,8 +27,8 @@ export class AnthropicClient extends BaseClient {
|
|
|
27
27
|
...this.getToolOptions(options),
|
|
28
28
|
};
|
|
29
29
|
const clientOptions = this.getClientOptions(params);
|
|
30
|
-
this.debug('Params:', params);
|
|
31
|
-
this.debug('Options:', options);
|
|
30
|
+
this.debug('Params:', params, options);
|
|
31
|
+
this.debug('Options:', options, options);
|
|
32
32
|
// @ts-ignore
|
|
33
33
|
return await this.client.messages.create(params, clientOptions);
|
|
34
34
|
}
|
package/dist/esm/openai.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bedrockio/ai",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Bedrock wrapper for common AI chatbots.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@anthropic-ai/sdk": "^0.66.0",
|
|
39
|
-
"@bedrockio/templates": "^0.3.
|
|
39
|
+
"@bedrockio/templates": "^0.3.1",
|
|
40
40
|
"@google/generative-ai": "^0.21.0",
|
|
41
41
|
"openai": "^6.3.0",
|
|
42
42
|
"partial-json": "^0.1.7"
|
package/types/BaseClient.d.ts
CHANGED
|
@@ -45,13 +45,16 @@ export default class BaseClient {
|
|
|
45
45
|
system: string;
|
|
46
46
|
messages: any[];
|
|
47
47
|
};
|
|
48
|
-
normalizeInput(options: any):
|
|
48
|
+
normalizeInput(options: any): {
|
|
49
|
+
role: string;
|
|
50
|
+
content: any;
|
|
51
|
+
}[];
|
|
49
52
|
normalizeSchema(options: any): {
|
|
50
53
|
schema: any;
|
|
51
54
|
hasWrappedSchema: boolean;
|
|
52
55
|
};
|
|
53
56
|
getMessageExtractor(options: any): (event: any) => any;
|
|
54
|
-
debug(message: any, arg: any): void;
|
|
57
|
+
debug(message: any, arg: any, options: any): void;
|
|
55
58
|
}
|
|
56
59
|
export type PromptOptions = {
|
|
57
60
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseClient.d.ts","sourceRoot":"","sources":["../src/BaseClient.js"],"names":[],"mappings":"AAKA;IACE,0BASC;IARC,aAIC;IACD,2BAEE;IAKJ;;;;;OAKG;IACH,gBAFW,aAAa,gBAuCvB;IAED;;;;;OAKG;IACH,gBAHW,aAAa,GAAG,aAAa,gCAsDvC;IAED;;;;OAIG;IACH,wBAFW,MAAM,OAIhB;IAID,8BAGC;IAED,8BAGC;IAED,qCAGC;IAED;;OAEG;IACH,0CAGC;IAED;;OAEG;IACH,oDAGC;IAED;;OAEG;IACH,sCAGC;IAID;;OAEG;IACH,oCAOC;IAED;;;
|
|
1
|
+
{"version":3,"file":"BaseClient.d.ts","sourceRoot":"","sources":["../src/BaseClient.js"],"names":[],"mappings":"AAKA;IACE,0BASC;IARC,aAIC;IACD,2BAEE;IAKJ;;;;;OAKG;IACH,gBAFW,aAAa,gBAuCvB;IAED;;;;;OAKG;IACH,gBAHW,aAAa,GAAG,aAAa,gCAsDvC;IAED;;;;OAIG;IACH,wBAFW,MAAM,OAIhB;IAID,8BAGC;IAED,8BAGC;IAED,qCAGC;IAED;;OAEG;IACH,0CAGC;IAED;;OAEG;IACH,oDAGC;IAED;;OAEG;IACH,sCAGC;IAID;;OAEG;IACH,oCAOC;IAED;;;MAuCC;IAED;;;QAQC;IAED;;;MA4BC;IAED,uDAWC;IAED,kDAMC;CACF;;;;;WAIa,MAAM,GAAC,aAAa,EAAE;;;;YACtB,MAAM;;;;YACN,OAAO;;;;;;;;aAEP,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU;;;;;;;;;;;sBAOpC,MAAM;;;UAKN,QAAQ,GAAG,MAAM,GAAG,WAAW;aAC/B,MAAM;;iCArTa,sBAAsB"}
|