symposium 0.6.2 → 0.6.3

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 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', JSON.stringify(response), function_call.name);
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', JSON.stringify({error}), function_call.name);
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
 
@@ -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
- if (message.role === 'function') {
95
- return {
96
- type: 'text',
97
- content: c.content,
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: c.content.response,
112
+ tool_use_id: c.content.id,
111
113
  };
112
114
 
113
115
  default:
@@ -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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "symposium",
4
- "version": "0.6.2",
4
+ "version": "0.6.3",
5
5
  "description": "Agents",
6
6
  "main": "index.js",
7
7
  "author": "Domenico Giambra",