@kaels/casileys 0.4.6 → 0.4.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.
- package/README.md +332 -1
- package/lib/MessageBuilder/AIRich.js +3235 -0
- package/lib/Socket/index.js +8 -1
- package/lib/Utils/rich-message-utils.js +57 -2
- package/package.json +1 -1
package/lib/Socket/index.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { DEFAULT_CONNECTION_CONFIG } from '../Defaults/index.js';
|
|
2
2
|
import { makeCommunitiesSocket } from './communities.js';
|
|
3
|
+
import { AIRich } from '../MessageBuilder/AIRich.js';
|
|
3
4
|
// export the last socket layer
|
|
4
5
|
const makeWASocket = (config) => {
|
|
5
6
|
const newConfig = {
|
|
6
7
|
...DEFAULT_CONNECTION_CONFIG,
|
|
7
8
|
...config
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
+
const sock = makeCommunitiesSocket(newConfig);
|
|
11
|
+
|
|
12
|
+
sock.createAIRich = (options = {}) => {
|
|
13
|
+
return new AIRich(sock, options);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return sock;
|
|
10
17
|
};
|
|
11
18
|
export default makeWASocket;
|
|
12
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -61,10 +61,44 @@ export const toUnified = (submessages, uuid) => ({
|
|
|
61
61
|
__typename: 'GenAISingleLayoutViewModel'
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
+
case RichSubMessageType.GRID_IMAGE: {
|
|
65
|
+
const imageMetadata = submessage.gridImageMetadata;
|
|
66
|
+
const image = imageMetadata?.imageUrls?.[0] || imageMetadata?.gridImageUrl;
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
view_model: {
|
|
70
|
+
primitive: {
|
|
71
|
+
media: {
|
|
72
|
+
url: image?.imagePreviewUrl || image?.imageHighResUrl || '',
|
|
73
|
+
mime_type: 'image/png'
|
|
74
|
+
},
|
|
75
|
+
imagine_type: 'IMAGE',
|
|
76
|
+
status: { status: 'READY' },
|
|
77
|
+
__typename: 'GenAIImaginePrimitive'
|
|
78
|
+
},
|
|
79
|
+
__typename: 'GenAISingleLayoutViewModel'
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
64
83
|
case RichSubMessageType.CONTENT_ITEMS:
|
|
65
84
|
return {};
|
|
66
|
-
case RichSubMessageType.INLINE_IMAGE:
|
|
67
|
-
|
|
85
|
+
case RichSubMessageType.INLINE_IMAGE: {
|
|
86
|
+
const imageMetadata = submessage.imageMetadata;
|
|
87
|
+
return {
|
|
88
|
+
view_model: {
|
|
89
|
+
primitive: {
|
|
90
|
+
media: {
|
|
91
|
+
url: imageMetadata?.imageUrl || imageMetadata?.imagePreviewUrl || '',
|
|
92
|
+
mime_type: 'image/png'
|
|
93
|
+
},
|
|
94
|
+
imagine_type: 'IMAGE',
|
|
95
|
+
status: { status: 'READY' },
|
|
96
|
+
__typename: 'GenAIImaginePrimitive'
|
|
97
|
+
},
|
|
98
|
+
__typename: 'GenAISingleLayoutViewModel'
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
68
102
|
case RichSubMessageType.LATEX:
|
|
69
103
|
return {};
|
|
70
104
|
case RichSubMessageType.TABLE:
|
|
@@ -128,6 +162,25 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
128
162
|
}
|
|
129
163
|
};
|
|
130
164
|
}
|
|
165
|
+
else if (submessage.image) {
|
|
166
|
+
const images = Array.isArray(submessage.image)
|
|
167
|
+
? submessage.image
|
|
168
|
+
: [submessage.image];
|
|
169
|
+
|
|
170
|
+
const imageUrls = images.map((url) => ({
|
|
171
|
+
imagePreviewUrl: url,
|
|
172
|
+
imageHighResUrl: url,
|
|
173
|
+
sourceUrl: url
|
|
174
|
+
}));
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
messageType: RichSubMessageType.GRID_IMAGE,
|
|
178
|
+
gridImageMetadata: {
|
|
179
|
+
gridImageUrl: imageUrls[0],
|
|
180
|
+
imageUrls
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
131
184
|
else if (submessage.inlineImage) {
|
|
132
185
|
return {
|
|
133
186
|
messageType: RichSubMessageType.INLINE_IMAGE,
|
|
@@ -307,7 +360,9 @@ export const prepareRichResponseMessage = (content) => {
|
|
|
307
360
|
}
|
|
308
361
|
}
|
|
309
362
|
const uuid = randomUUID();
|
|
363
|
+
console.log('[RICH DEBUG]', JSON.stringify(submessages, null, 2));
|
|
310
364
|
const unified = toUnified(submessages, uuid);
|
|
365
|
+
console.log('[UNIFIED DEBUG]', JSON.stringify(unified, null, 2));
|
|
311
366
|
const richResponseMessage = proto.AIRichResponseMessage.create({
|
|
312
367
|
submessages,
|
|
313
368
|
messageType: proto.AIRichResponseMessageType.AI_RICH_RESPONSE_TYPE_STANDARD,
|