symposium 0.6.2 → 0.6.4
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 +12 -2
- package/models/AnthropicModel.js +13 -11
- package/models/OpenAIModel.js +16 -0
- package/package.json +1 -1
package/Agent.js
CHANGED
|
@@ -235,10 +235,20 @@ export default class Agent {
|
|
|
235
235
|
|
|
236
236
|
try {
|
|
237
237
|
const response = await functions.get(function_call.name).tool.callFunction(thread, function_call.name, function_call.arguments);
|
|
238
|
-
thread.addMessage('function',
|
|
238
|
+
thread.addMessage('function', [
|
|
239
|
+
{
|
|
240
|
+
type: 'function_response',
|
|
241
|
+
content: {response, id: function_call.id || undefined},
|
|
242
|
+
},
|
|
243
|
+
], function_call.name);
|
|
239
244
|
await this.log('function_response', response);
|
|
240
245
|
} catch (error) {
|
|
241
|
-
thread.addMessage('function',
|
|
246
|
+
thread.addMessage('function', [
|
|
247
|
+
{
|
|
248
|
+
type: 'function_response',
|
|
249
|
+
content: {response: {error}},
|
|
250
|
+
},
|
|
251
|
+
], function_call.name);
|
|
242
252
|
await this.log('function_response', {error});
|
|
243
253
|
}
|
|
244
254
|
|
package/models/AnthropicModel.js
CHANGED
|
@@ -63,6 +63,7 @@ export default class AnthropicModel extends Model {
|
|
|
63
63
|
message_content.push({
|
|
64
64
|
type: 'function',
|
|
65
65
|
content: {
|
|
66
|
+
id: m.id,
|
|
66
67
|
name: m.name,
|
|
67
68
|
arguments: m.input,
|
|
68
69
|
},
|
|
@@ -91,23 +92,24 @@ export default class AnthropicModel extends Model {
|
|
|
91
92
|
content: message.content.map(c => {
|
|
92
93
|
switch (c.type) {
|
|
93
94
|
case 'text':
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
};
|
|
99
|
-
} else {
|
|
100
|
-
return {
|
|
101
|
-
type: 'text',
|
|
102
|
-
text: c.content.trim(),
|
|
103
|
-
};
|
|
104
|
-
}
|
|
95
|
+
return {
|
|
96
|
+
type: 'text',
|
|
97
|
+
text: c.content.trim(),
|
|
98
|
+
};
|
|
105
99
|
|
|
106
100
|
case 'function':
|
|
107
101
|
return {
|
|
108
102
|
type: 'tool_use',
|
|
109
103
|
name: c.content.name,
|
|
110
104
|
input: c.content.arguments,
|
|
105
|
+
id: c.content.id,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
case 'function_response':
|
|
109
|
+
return {
|
|
110
|
+
type: 'tool_result',
|
|
111
|
+
content: JSON.stringify(c.content.response),
|
|
112
|
+
tool_use_id: c.content.id,
|
|
111
113
|
};
|
|
112
114
|
|
|
113
115
|
default:
|
package/models/OpenAIModel.js
CHANGED
|
@@ -122,6 +122,22 @@ export default class OpenAIModel extends Model {
|
|
|
122
122
|
}
|
|
123
123
|
break;
|
|
124
124
|
|
|
125
|
+
case 'function_response':
|
|
126
|
+
if (this.supports_functions) {
|
|
127
|
+
messages.push({
|
|
128
|
+
role: message.role,
|
|
129
|
+
content: JSON.stringify(c.content.response),
|
|
130
|
+
name: message.name,
|
|
131
|
+
});
|
|
132
|
+
} else {
|
|
133
|
+
messages.push({
|
|
134
|
+
role: 'user',
|
|
135
|
+
content: 'FUNCTION RESPONSE:\n' + JSON.stringify(c.content.response),
|
|
136
|
+
name: message.name,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
|
|
125
141
|
default:
|
|
126
142
|
throw new Error('Message type unsupported by this model');
|
|
127
143
|
}
|