@caretakerai/agent 0.0.35 → 0.0.36
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/dist/activities/activity.js +16 -1
- package/package.json +1 -1
|
@@ -22,9 +22,24 @@ function stringify(activities, transformers) {
|
|
|
22
22
|
}
|
|
23
23
|
const message = transformer.stringify(activity);
|
|
24
24
|
const lastMessage = messages.at(-1);
|
|
25
|
+
// Convert string content MessageContentComplex array of text messages to allow mixing text and other message types
|
|
26
|
+
if (typeof message.content === 'string') {
|
|
27
|
+
message.content = [{
|
|
28
|
+
type: 'text',
|
|
29
|
+
text: message.content
|
|
30
|
+
}];
|
|
31
|
+
}
|
|
25
32
|
// Combine with previous message if same role
|
|
26
33
|
if (lastMessage?.role === message.role) {
|
|
27
|
-
|
|
34
|
+
const lastMessageContent = lastMessage.content;
|
|
35
|
+
const messageContent = message.content;
|
|
36
|
+
// If both messages are text, combine them with ACTIVITY_SEP
|
|
37
|
+
if (lastMessageContent[0].type === 'text' && messageContent[0].type === 'text') {
|
|
38
|
+
lastMessageContent[0].text = `${lastMessageContent[0].text}${exports.ACTIVITY_SEP}${messageContent[0].text}`;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
lastMessage.content = [...lastMessageContent, ...messageContent];
|
|
42
|
+
}
|
|
28
43
|
return messages;
|
|
29
44
|
}
|
|
30
45
|
// Otherwise add as new message
|