Skip to content

Commit c363327

Browse files
committed
Improved AI functinoality.
1 parent 0e6570b commit c363327

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

aimodel.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,27 @@ AI.prototype.message = function(role, content, merge) {
3030
if (merge) {
3131
for (let m of t.payload.messages) {
3232
if (m.role === role) {
33-
m.content += merge + content;
33+
34+
if (typeof(content) === 'object') {
35+
for (let key in content)
36+
m[key] = content[key];
37+
} else
38+
m.content += merge + content;
39+
3440
return this;
3541
}
3642
}
3743
}
3844

39-
t.payload.messages.push({ role: role, content: content });
45+
const msg = { role: role };
46+
47+
if (typeof(content) === 'object') {
48+
for (let key in content)
49+
msg[key] = content[key];
50+
} else
51+
msg.content = content;
52+
53+
t.payload.messages.push(msg);
4054
return t;
4155
};
4256

0 commit comments

Comments
 (0)