@bedrockio/ai 0.9.5 → 0.9.7

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.
@@ -118,7 +118,8 @@ class BaseClient {
118
118
  getFilteredMessages(options) {
119
119
  const { messages = [] } = options;
120
120
  return messages.filter((message) => {
121
- return message.content.trim();
121
+ const trimmed = message.content.trim();
122
+ return trimmed && trimmed !== '.';
122
123
  });
123
124
  }
124
125
  // Protected
@@ -244,12 +245,14 @@ class BaseClient {
244
245
  }
245
246
  if (result.length === 1 && !result[0].content) {
246
247
  // If a single user input is passed and is nullish, coerce it to a
247
- // single space. Combined with getFilteredMessages below this allows
248
+ // single period. Combined with getFilteredMessages below this allows
248
249
  // a chatbot the ability to "speak first" by prompting it with empty
249
250
  // content. The empty message will be filtered out of the final result
250
- // appearing as if the chatbot went first. Note empty string will also
251
- // fail here hence the single space.
252
- result[0].content = ' ';
251
+ // appearing as if the chatbot went first.
252
+ // Note that:
253
+ // GPT will fail on an empty string but on whitespace
254
+ // Anthropic will fail on all whitespace
255
+ result[0].content = '.';
253
256
  }
254
257
  return result;
255
258
  }
@@ -111,6 +111,7 @@ class AnthropicClient extends BaseClient_js_1.default {
111
111
  else if (type === 'message_delta') {
112
112
  return {
113
113
  type: 'stop',
114
+ instructions: options.instructions,
114
115
  messages: [
115
116
  ...this.getFilteredMessages(options),
116
117
  {
@@ -116,7 +116,8 @@ export default class BaseClient {
116
116
  getFilteredMessages(options) {
117
117
  const { messages = [] } = options;
118
118
  return messages.filter((message) => {
119
- return message.content.trim();
119
+ const trimmed = message.content.trim();
120
+ return trimmed && trimmed !== '.';
120
121
  });
121
122
  }
122
123
  // Protected
@@ -242,12 +243,14 @@ export default class BaseClient {
242
243
  }
243
244
  if (result.length === 1 && !result[0].content) {
244
245
  // If a single user input is passed and is nullish, coerce it to a
245
- // single space. Combined with getFilteredMessages below this allows
246
+ // single period. Combined with getFilteredMessages below this allows
246
247
  // a chatbot the ability to "speak first" by prompting it with empty
247
248
  // content. The empty message will be filtered out of the final result
248
- // appearing as if the chatbot went first. Note empty string will also
249
- // fail here hence the single space.
250
- result[0].content = ' ';
249
+ // appearing as if the chatbot went first.
250
+ // Note that:
251
+ // GPT will fail on an empty string but on whitespace
252
+ // Anthropic will fail on all whitespace
253
+ result[0].content = '.';
251
254
  }
252
255
  return result;
253
256
  }
@@ -105,6 +105,7 @@ export class AnthropicClient extends BaseClient {
105
105
  else if (type === 'message_delta') {
106
106
  return {
107
107
  type: 'stop',
108
+ instructions: options.instructions,
108
109
  messages: [
109
110
  ...this.getFilteredMessages(options),
110
111
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/ai",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
4
4
  "description": "Bedrock wrapper for common AI chatbots.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1 +1 @@
1
- {"version":3,"file":"BaseClient.d.ts","sourceRoot":"","sources":["../src/BaseClient.js"],"names":[],"mappings":"AAOA;IACE,0BAUC;IATC,aAIC;IACD,2BAEE;IAIJ,2BAKC;IAID;;;;;OAKG;IACH,gBAFW,aAAa,gBAiCvB;IAED;;;;;OAKG;IACH,gBAHW,aAAa,GAAG,aAAa,gCAsDvC;IAED;;;;OAIG;IACH,wBAFW,MAAM,OAIhB;IAED,uCAKC;IAID,8BAGC;IAED,8BAGC;IAED,qCAGC;IAED;;OAEG;IACH,0CAGC;IAED;;OAEG;IACH,oDAIC;IAED;;OAEG;IACH,oDAIC;IAID;;OAEG;IACH,oCAOC;IAED;;;MAeC;IAED,4CAiDC;IAED,uCAkCC;IAED;;;MA4BC;IAED,uDAWC;IAED,kDAMC;CACF;;;;;WAIa,MAAM;kBACN,MAAM;;;;cACN,aAAa,EAAE;;;;YACf,MAAM;;;;YACN,OAAO;;;;;;;;aAEP,MAAM,GAAG,MAAM;;;;;;;;;;;sBAOf,MAAM;;;UAKN,QAAQ,GAAG,MAAM,GAAG,WAAW;aAC/B,MAAM;;iCAvXa,sBAAsB"}
1
+ {"version":3,"file":"BaseClient.d.ts","sourceRoot":"","sources":["../src/BaseClient.js"],"names":[],"mappings":"AAOA;IACE,0BAUC;IATC,aAIC;IACD,2BAEE;IAIJ,2BAKC;IAID;;;;;OAKG;IACH,gBAFW,aAAa,gBAiCvB;IAED;;;;;OAKG;IACH,gBAHW,aAAa,GAAG,aAAa,gCAsDvC;IAED;;;;OAIG;IACH,wBAFW,MAAM,OAIhB;IAED,uCAMC;IAID,8BAGC;IAED,8BAGC;IAED,qCAGC;IAED;;OAEG;IACH,0CAGC;IAED;;OAEG;IACH,oDAIC;IAED;;OAEG;IACH,oDAIC;IAID;;OAEG;IACH,oCAOC;IAED;;;MAeC;IAED,4CAiDC;IAED,uCAoCC;IAED;;;MA4BC;IAED,uDAWC;IAED,kDAMC;CACF;;;;;WAIa,MAAM;kBACN,MAAM;;;;cACN,aAAa,EAAE;;;;YACf,MAAM;;;;YACN,OAAO;;;;;;;;aAEP,MAAM,GAAG,MAAM;;;;;;;;;;;sBAOf,MAAM;;;UAKN,QAAQ,GAAG,MAAM,GAAG,WAAW;aAC/B,MAAM;;iCA1Xa,sBAAsB"}
@@ -30,6 +30,7 @@ export class AnthropicClient extends BaseClient {
30
30
  name: any;
31
31
  arguments: any;
32
32
  delta?: undefined;
33
+ instructions?: undefined;
33
34
  messages?: undefined;
34
35
  usage?: undefined;
35
36
  } | {
@@ -38,6 +39,7 @@ export class AnthropicClient extends BaseClient {
38
39
  name?: undefined;
39
40
  arguments?: undefined;
40
41
  delta?: undefined;
42
+ instructions?: undefined;
41
43
  messages?: undefined;
42
44
  usage?: undefined;
43
45
  } | {
@@ -46,10 +48,12 @@ export class AnthropicClient extends BaseClient {
46
48
  id?: undefined;
47
49
  name?: undefined;
48
50
  arguments?: undefined;
51
+ instructions?: undefined;
49
52
  messages?: undefined;
50
53
  usage?: undefined;
51
54
  } | {
52
55
  type: string;
56
+ instructions: any;
53
57
  messages: any[];
54
58
  usage: {
55
59
  input_tokens: any;
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../src/anthropic.js"],"names":[],"mappings":"AAMA;IACE,6BAA2C;IAIzC,kBAAoC;IAGtC;;;OAGG;IACH,4BAGC;IAED;;wGA2BC;IAED;;wGAKC;IAED,oCAKC;IASD;;;;;;MAiBC;IAED;;;MAKC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAsCC;IAID;;;;;;;;;;MA0CC;IAED,oCAKC;IAUD;;;;MAOC;IAID;;;;MAOC;IAED;;;;MAQC;CACF;uBAnOsB,iBAAiB;sBAFlB,mBAAmB"}
1
+ {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../src/anthropic.js"],"names":[],"mappings":"AAMA;IACE,6BAA2C;IAIzC,kBAAoC;IAGtC;;;OAGG;IACH,4BAGC;IAED;;wGA2BC;IAED;;wGAKC;IAED,oCAKC;IASD;;;;;;MAiBC;IAED;;;MAKC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAuCC;IAID;;;;;;;;;;MA0CC;IAED,oCAKC;IAUD;;;;MAOC;IAID;;;;MAOC;IAED;;;;MAQC;CACF;uBApOsB,iBAAiB;sBAFlB,mBAAmB"}