@wabot-dev/framework 0.9.26 → 0.9.27

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.
@@ -10,8 +10,27 @@ function stripAnsweredMedia(items) {
10
10
  const humanMessage = { ...item.humanMessage };
11
11
  delete humanMessage.images;
12
12
  delete humanMessage.documents;
13
+ // A media-only message becomes empty once its binaries are stripped, which
14
+ // makes the provider adapters reject it as empty content. Leave a short
15
+ // placeholder so the answered turn stays in the history coherently.
16
+ if (isStrippedMessageEmpty(humanMessage)) {
17
+ humanMessage.text = describeStrippedMedia(item.humanMessage);
18
+ }
13
19
  return { type: 'humanMessage', humanMessage };
14
20
  });
15
21
  }
22
+ function isStrippedMessageEmpty(message) {
23
+ return !message.text && !message.object;
24
+ }
25
+ function describeStrippedMedia(message) {
26
+ const parts = [];
27
+ const images = message.images?.length ?? 0;
28
+ const documents = message.documents?.length ?? 0;
29
+ if (images > 0)
30
+ parts.push(`${images} image${images > 1 ? 's' : ''}`);
31
+ if (documents > 0)
32
+ parts.push(`${documents} document${documents > 1 ? 's' : ''}`);
33
+ return `[sent ${parts.join(' and ')}]`;
34
+ }
16
35
 
17
36
  export { stripAnsweredMedia };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wabot-dev/framework",
3
- "version": "0.9.26",
3
+ "version": "0.9.27",
4
4
  "description": "Framework for IA Chat Bots",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",