symposium 0.6.6 → 0.6.7
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 +2 -2
- package/models/AnthropicModel.js +1 -1
- package/models/OpenAIModel.js +38 -15
- package/package.json +1 -1
- package/models/Gpt4Vision.js +0 -9
package/Agent.js
CHANGED
|
@@ -227,7 +227,7 @@ export default class Agent {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
async callFunction(thread, function_call) {
|
|
230
|
-
|
|
230
|
+
const functions = await this.getFunctions(false);
|
|
231
231
|
if (!functions.has(function_call.name))
|
|
232
232
|
throw new Error('Unrecognized function ' + function_call.name);
|
|
233
233
|
|
|
@@ -235,7 +235,7 @@ 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('
|
|
238
|
+
thread.addMessage('tool', [
|
|
239
239
|
{
|
|
240
240
|
type: 'function_response',
|
|
241
241
|
content: {response, id: function_call.id || undefined},
|
package/models/AnthropicModel.js
CHANGED
|
@@ -88,7 +88,7 @@ export default class AnthropicModel extends Model {
|
|
|
88
88
|
system.push(message.content.map(c => c.content).join("\n"));
|
|
89
89
|
} else {
|
|
90
90
|
const parsedMessage = {
|
|
91
|
-
role: message.role
|
|
91
|
+
role: ['function', 'tool'].includes(message.role) ? 'user' : message.role,
|
|
92
92
|
content: message.content.map(c => {
|
|
93
93
|
switch (c.type) {
|
|
94
94
|
case 'text':
|
package/models/OpenAIModel.js
CHANGED
|
@@ -49,11 +49,19 @@ export default class OpenAIModel extends Model {
|
|
|
49
49
|
const completion_payload = {
|
|
50
50
|
model: this.name,
|
|
51
51
|
messages: convertedMessages,
|
|
52
|
-
functions
|
|
52
|
+
tools: functions.map(f => ({
|
|
53
|
+
type: 'function',
|
|
54
|
+
function: f,
|
|
55
|
+
})),
|
|
53
56
|
};
|
|
54
57
|
|
|
55
|
-
if (options.force_function)
|
|
56
|
-
completion_payload.
|
|
58
|
+
if (options.force_function) {
|
|
59
|
+
completion_payload.tool_choice = {
|
|
60
|
+
type: 'function',
|
|
61
|
+
function: {name: options.force_function},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
57
65
|
if (!completion_payload.functions.length)
|
|
58
66
|
delete completion_payload.functions;
|
|
59
67
|
|
|
@@ -63,14 +71,21 @@ export default class OpenAIModel extends Model {
|
|
|
63
71
|
const message_content = [];
|
|
64
72
|
if (completion.content)
|
|
65
73
|
message_content.push({type: 'text', content: completion.content});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
|
|
75
|
+
if (completion.tool_calls) {
|
|
76
|
+
for (let tool_call of completion.tool_calls) {
|
|
77
|
+
if (tool_call.type !== 'function')
|
|
78
|
+
throw new Error('Unsupported tool type ' + tool_call.type);
|
|
79
|
+
|
|
80
|
+
message_content.push({
|
|
81
|
+
type: 'function',
|
|
82
|
+
content: {
|
|
83
|
+
id: tool_call.id,
|
|
84
|
+
name: tool_call.function.name,
|
|
85
|
+
arguments: tool_call.function.arguments ? JSON.parse(tool_call.function.arguments) : {},
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
74
89
|
}
|
|
75
90
|
|
|
76
91
|
return [
|
|
@@ -108,10 +123,16 @@ export default class OpenAIModel extends Model {
|
|
|
108
123
|
messages.push({
|
|
109
124
|
role: message.role,
|
|
110
125
|
name: message.name,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
126
|
+
tool_calls: [
|
|
127
|
+
{
|
|
128
|
+
id: c.content.id,
|
|
129
|
+
type: 'function',
|
|
130
|
+
function: {
|
|
131
|
+
name: c.content.name,
|
|
132
|
+
arguments: c.content.arguments ? JSON.stringify(c.content.arguments) : '{}',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
],
|
|
115
136
|
});
|
|
116
137
|
} else {
|
|
117
138
|
messages.push({
|
|
@@ -126,6 +147,8 @@ export default class OpenAIModel extends Model {
|
|
|
126
147
|
if (this.supports_functions) {
|
|
127
148
|
messages.push({
|
|
128
149
|
role: message.role,
|
|
150
|
+
type: 'tool_result',
|
|
151
|
+
tool_call_id: c.content.id,
|
|
129
152
|
content: JSON.stringify(c.content.response),
|
|
130
153
|
name: message.name,
|
|
131
154
|
});
|
package/package.json
CHANGED
package/models/Gpt4Vision.js
DELETED