@bedrockio/ai 0.7.2 → 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 CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.7.3
2
+
3
+ - Allow debug on individual calls.
4
+
1
5
  ## 0.7.2
2
6
 
3
7
  - Handling long filenames.
@@ -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
  }
@@ -237,8 +237,8 @@ class BaseClient {
237
237
  }
238
238
  };
239
239
  }
240
- debug(message, arg) {
241
- if (this.options.debug) {
240
+ debug(message, arg, options) {
241
+ if (options.debug) {
242
242
  // TODO: replace with logger when opentelemetry is removed
243
243
  // eslint-disable-next-line
244
244
  console.debug(`${message}\n${JSON.stringify(arg, null, 2)}\n`);
@@ -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
  }
@@ -58,7 +58,7 @@ class OpenAiClient extends BaseClient_js_1.default {
58
58
  verbosity,
59
59
  },
60
60
  };
61
- this.debug('Params:', params);
61
+ this.debug('Params:', params, options);
62
62
  // @ts-ignore
63
63
  return await this.client.responses.create(params);
64
64
  }
@@ -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
  }
@@ -235,8 +235,8 @@ export default class BaseClient {
235
235
  }
236
236
  };
237
237
  }
238
- debug(message, arg) {
239
- if (this.options.debug) {
238
+ debug(message, arg, options) {
239
+ if (options.debug) {
240
240
  // TODO: replace with logger when opentelemetry is removed
241
241
  // eslint-disable-next-line
242
242
  console.debug(`${message}\n${JSON.stringify(arg, null, 2)}\n`);
@@ -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
  }
@@ -52,7 +52,7 @@ export class OpenAiClient extends BaseClient {
52
52
  verbosity,
53
53
  },
54
54
  };
55
- this.debug('Params:', params);
55
+ this.debug('Params:', params, options);
56
56
  // @ts-ignore
57
57
  return await this.client.responses.create(params);
58
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/ai",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Bedrock wrapper for common AI chatbots.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -54,7 +54,7 @@ export default class BaseClient {
54
54
  hasWrappedSchema: boolean;
55
55
  };
56
56
  getMessageExtractor(options: any): (event: any) => any;
57
- debug(message: any, arg: any): void;
57
+ debug(message: any, arg: any, options: any): void;
58
58
  }
59
59
  export type PromptOptions = {
60
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;;;MAuCC;IAED;;;QAQC;IAED;;;MA4BC;IAED,uDAWC;IAED,oCAMC;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"}
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"}