symposium 0.5.1 → 0.5.2
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/Agent.js +7 -3
- package/Model.js +1 -1
- package/models/AnthropicModel.js +3 -3
- package/package.json +1 -1
package/Agent.js
CHANGED
|
@@ -153,14 +153,18 @@ export default class Agent {
|
|
|
153
153
|
parseFunctions(message) {
|
|
154
154
|
const newContent = [];
|
|
155
155
|
for (let m of message.content) {
|
|
156
|
-
if (m.type === 'text' && m.content.match(/```\nCALL [A-Za-z0-9_]+\n
|
|
156
|
+
if (m.type === 'text' && m.content.match(/```\nCALL [A-Za-z0-9_]+\n[\s\S]*```/)) {
|
|
157
157
|
const splitted = m.content.split('```');
|
|
158
158
|
for (let text of splitted) {
|
|
159
|
+
text = text.trim();
|
|
160
|
+
if (!text)
|
|
161
|
+
continue;
|
|
162
|
+
|
|
159
163
|
const match = text.match(/^CALL ([A-Za-z0-9_]+)\n([\s\S]*)$/);
|
|
160
164
|
if (match)
|
|
161
|
-
|
|
165
|
+
newContent.push({type: 'function', content: {name: match[1], arguments: JSON.parse(match[2] || '{}')}});
|
|
162
166
|
else
|
|
163
|
-
|
|
167
|
+
newContent.push({type: 'text', content: text});
|
|
164
168
|
}
|
|
165
169
|
} else {
|
|
166
170
|
newContent.push(m);
|
package/Model.js
CHANGED
|
@@ -23,7 +23,7 @@ export default class Model {
|
|
|
23
23
|
if (!functions.length)
|
|
24
24
|
return '';
|
|
25
25
|
|
|
26
|
-
let message = "Hai a disposizione alcune funzioni che puoi chiamare per ottenere risposte o compiere azioni. Per chiamare una funzione scrivi un messaggio che inizia con CALL nome_funzione e a capo inserisci il JSON con gli argomenti; delimitando il tutto da 3 caratteri ``` - ad esempio:\n" +
|
|
26
|
+
let message = "Hai a disposizione alcune funzioni che puoi chiamare per ottenere risposte o compiere azioni. Ricorda che devi attendere la risposta dalla funzione per sapere se ha avuto successo. Per chiamare una funzione scrivi un messaggio che inizia con CALL nome_funzione e a capo inserisci il JSON con gli argomenti; delimitando il tutto da 3 caratteri ``` - ad esempio:\n" +
|
|
27
27
|
"```\n" +
|
|
28
28
|
"CALL create_user\n" +
|
|
29
29
|
'{"name":"test"}' + "\n" +
|
package/models/AnthropicModel.js
CHANGED
|
@@ -56,16 +56,16 @@ export default class AnthropicModel extends Model {
|
|
|
56
56
|
let system = [], messages = [];
|
|
57
57
|
for (let message of thread.messages) {
|
|
58
58
|
if (message.role === 'system') {
|
|
59
|
-
system.push(message.content);
|
|
59
|
+
system.push(message.content.map(c => c.content).join("\n"));
|
|
60
60
|
} else {
|
|
61
61
|
messages.push({
|
|
62
|
-
role: message.role,
|
|
62
|
+
role: message.role === 'function' ? 'user' : message.role,
|
|
63
63
|
content: message.content.map(c => {
|
|
64
64
|
switch (c.type) {
|
|
65
65
|
case 'text':
|
|
66
66
|
return {
|
|
67
67
|
type: 'text',
|
|
68
|
-
text: c.content,
|
|
68
|
+
text: (message.role === 'function' ? 'FUNCTION RESPONSE: ' : '') + c.content,
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
case 'function':
|