symposium 0.12.6 → 0.12.8
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 +5 -5
- package/Model.js +1 -0
- package/models/AnthropicModel.js +1 -1
- package/models/GptO1.js +1 -0
- package/models/GptO1Mini.js +1 -0
- package/models/OpenAIModel.js +8 -6
- package/package.json +1 -1
package/Agent.js
CHANGED
|
@@ -108,15 +108,15 @@ export default class Agent {
|
|
|
108
108
|
|
|
109
109
|
const completion_options = {};
|
|
110
110
|
if (this.utility) {
|
|
111
|
-
if (!['function', '
|
|
111
|
+
if (!['text', 'function', 'json'].includes(this.utility.type))
|
|
112
112
|
throw new Error('Bad utility definition');
|
|
113
113
|
|
|
114
|
-
if (this.utility.type
|
|
114
|
+
if (['function', 'json'].includes(this.utility.type)) {
|
|
115
115
|
if (!this.utility.function || !this.utility.function.name || !this.utility.function.parameters)
|
|
116
116
|
throw new Error('Bad function definition');
|
|
117
117
|
|
|
118
118
|
let response_format = null;
|
|
119
|
-
if (model.supports_structured_output)
|
|
119
|
+
if (this.utility.type === 'json' && model.supports_structured_output)
|
|
120
120
|
response_format = this.convertFunctionToResponseFormat(this.utility.function.parameters);
|
|
121
121
|
|
|
122
122
|
if (response_format && response_format.count <= 100) { // Se ci sono più di 100 parametri, OpenAI non supporta gli structured output
|
|
@@ -287,7 +287,7 @@ export default class Agent {
|
|
|
287
287
|
if (this.utility) {
|
|
288
288
|
if (this.utility.type === 'text')
|
|
289
289
|
return this.afterHandle(thread, completion, 'return', m.content);
|
|
290
|
-
if (this.utility.type === '
|
|
290
|
+
if (this.utility.type === 'json' && model.supports_structured_output)
|
|
291
291
|
return this.afterHandle(thread, completion, 'return', JSON.parse(m.content));
|
|
292
292
|
}
|
|
293
293
|
await this.output(thread, m.content);
|
|
@@ -303,7 +303,7 @@ export default class Agent {
|
|
|
303
303
|
|
|
304
304
|
if (functions.length) {
|
|
305
305
|
for (let f of functions) {
|
|
306
|
-
if (this.utility && this.utility.type
|
|
306
|
+
if (this.utility && ['function', 'json'].includes(this.utility.type))
|
|
307
307
|
return this.afterHandle(thread, completion, 'return', f.arguments);
|
|
308
308
|
|
|
309
309
|
const response = await this.callFunction(thread, f);
|
package/Model.js
CHANGED
package/models/AnthropicModel.js
CHANGED
|
@@ -154,7 +154,7 @@ export default class AnthropicModel extends Model {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
const parsedMessage = {
|
|
157
|
-
role: ['function', 'tool'].includes(message.role) ? 'user' : message.role,
|
|
157
|
+
role: ['function', 'tool'].includes(message.role) ? 'user' : (message.role === 'system' ? this.system_role_name : message.role),
|
|
158
158
|
content,
|
|
159
159
|
};
|
|
160
160
|
|
package/models/GptO1.js
CHANGED
package/models/GptO1Mini.js
CHANGED
package/models/OpenAIModel.js
CHANGED
|
@@ -110,12 +110,14 @@ export default class OpenAIModel extends Model {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
convertMessage(message) {
|
|
113
|
-
const messages = []
|
|
113
|
+
const messages = [],
|
|
114
|
+
role = message.role === 'system' ? this.system_role_name : message.role;
|
|
115
|
+
|
|
114
116
|
for (let c of message.content) {
|
|
115
117
|
switch (c.type) {
|
|
116
118
|
case 'text':
|
|
117
119
|
messages.push({
|
|
118
|
-
role
|
|
120
|
+
role,
|
|
119
121
|
content: c.content,
|
|
120
122
|
name: message.name,
|
|
121
123
|
});
|
|
@@ -123,7 +125,7 @@ export default class OpenAIModel extends Model {
|
|
|
123
125
|
|
|
124
126
|
case 'image':
|
|
125
127
|
messages.push({
|
|
126
|
-
role
|
|
128
|
+
role,
|
|
127
129
|
content: [
|
|
128
130
|
{
|
|
129
131
|
type: 'image_url',
|
|
@@ -140,7 +142,7 @@ export default class OpenAIModel extends Model {
|
|
|
140
142
|
case 'function':
|
|
141
143
|
if (this.supports_functions) {
|
|
142
144
|
messages.push({
|
|
143
|
-
role
|
|
145
|
+
role,
|
|
144
146
|
name: message.name,
|
|
145
147
|
tool_calls: c.content.map(tool_call => ({
|
|
146
148
|
id: tool_call.id,
|
|
@@ -153,7 +155,7 @@ export default class OpenAIModel extends Model {
|
|
|
153
155
|
});
|
|
154
156
|
} else {
|
|
155
157
|
messages.push({
|
|
156
|
-
role
|
|
158
|
+
role,
|
|
157
159
|
content: c.content.map(f => '```CALL \n' + f.name + '\n' + JSON.stringify(f.arguments || {}) + '\n```').join("\n\n"),
|
|
158
160
|
name: message.name,
|
|
159
161
|
});
|
|
@@ -163,7 +165,7 @@ export default class OpenAIModel extends Model {
|
|
|
163
165
|
case 'function_response':
|
|
164
166
|
if (this.supports_functions) {
|
|
165
167
|
messages.push({
|
|
166
|
-
role
|
|
168
|
+
role,
|
|
167
169
|
tool_call_id: c.content.id,
|
|
168
170
|
content: JSON.stringify(c.content.response),
|
|
169
171
|
name: message.name,
|