symposium 0.11.4 → 0.12.0
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 +35 -4
- package/package.json +3 -3
package/Agent.js
CHANGED
|
@@ -11,6 +11,7 @@ export default class Agent {
|
|
|
11
11
|
default_model = 'gpt-4o';
|
|
12
12
|
max_retries = 5;
|
|
13
13
|
callbacks = {};
|
|
14
|
+
utility = null;
|
|
14
15
|
|
|
15
16
|
constructor(options) {
|
|
16
17
|
this.options = {
|
|
@@ -105,13 +106,37 @@ export default class Agent {
|
|
|
105
106
|
if (counter === 0)
|
|
106
107
|
thread = await this.beforeExecute(thread);
|
|
107
108
|
|
|
108
|
-
const
|
|
109
|
+
const completion_options = {};
|
|
110
|
+
if (this.utility) {
|
|
111
|
+
if (!['function', 'text'].includes(this.utility.type))
|
|
112
|
+
throw new Error('Bad utility definition');
|
|
113
|
+
|
|
114
|
+
if (this.utility.type === 'function') {
|
|
115
|
+
if (!this.utility.function || !this.utility.function.name || !this.utility.function.parameters)
|
|
116
|
+
throw new Error('Bad function definition');
|
|
117
|
+
|
|
118
|
+
completion_options.functions = [
|
|
119
|
+
this.utility.function,
|
|
120
|
+
];
|
|
121
|
+
completion_options.force_function = this.utility.function.name;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const completion = await this.generateCompletion(thread, completion_options);
|
|
109
126
|
if (completion) {
|
|
110
127
|
try {
|
|
111
128
|
thread = await this.afterExecute(thread, completion);
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
129
|
+
const response = await this.handleCompletion(thread, completion);
|
|
130
|
+
switch (response.type) {
|
|
131
|
+
case 'return':
|
|
132
|
+
return response.value;
|
|
133
|
+
|
|
134
|
+
case 'continue':
|
|
135
|
+
return await this.execute(thread);
|
|
136
|
+
|
|
137
|
+
default:
|
|
138
|
+
throw new Error('Unknown response type');
|
|
139
|
+
}
|
|
115
140
|
} catch (e) {
|
|
116
141
|
console.error(e);
|
|
117
142
|
|
|
@@ -205,6 +230,9 @@ export default class Agent {
|
|
|
205
230
|
for (let m of message.content) {
|
|
206
231
|
switch (m.type) {
|
|
207
232
|
case 'text':
|
|
233
|
+
if (this.utility && this.utility.type === 'text')
|
|
234
|
+
return m.content;
|
|
235
|
+
|
|
208
236
|
await this.output(thread, m.content);
|
|
209
237
|
break;
|
|
210
238
|
|
|
@@ -220,6 +248,9 @@ export default class Agent {
|
|
|
220
248
|
for (let f of functions) {
|
|
221
249
|
const response = await this.callFunction(thread, f);
|
|
222
250
|
|
|
251
|
+
if (this.utility && this.utility.type === 'function')
|
|
252
|
+
return response;
|
|
253
|
+
|
|
223
254
|
thread.addMessage('tool', [
|
|
224
255
|
{
|
|
225
256
|
type: 'function_response',
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "symposium",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.12.0",
|
|
5
5
|
"description": "Agents",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"author": "Domenico Giambra",
|
|
8
8
|
"license": "ISC",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@anthropic-ai/sdk": "^0.
|
|
11
|
-
"groq-sdk": "^0.
|
|
10
|
+
"@anthropic-ai/sdk": "^0.36.0",
|
|
11
|
+
"groq-sdk": "^0.13.0",
|
|
12
12
|
"openai": "^4.12.1",
|
|
13
13
|
"tiktoken": "^1.0.10"
|
|
14
14
|
}
|