symposium 0.9.7 → 0.10.1
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 +18 -9
- package/Interface.js +10 -0
- package/index.js +2 -0
- package/package.json +2 -2
package/Agent.js
CHANGED
|
@@ -14,6 +14,7 @@ export default class Agent {
|
|
|
14
14
|
constructor(options) {
|
|
15
15
|
this.options = {
|
|
16
16
|
memory_handler: null,
|
|
17
|
+
interfaces: [],
|
|
17
18
|
...options,
|
|
18
19
|
};
|
|
19
20
|
|
|
@@ -51,7 +52,7 @@ export default class Agent {
|
|
|
51
52
|
async doInitThread(thread) {
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
async getThread(id
|
|
55
|
+
async getThread(id) {
|
|
55
56
|
let thread = this.threads.get(id);
|
|
56
57
|
if (!thread) {
|
|
57
58
|
thread = new Thread(this.name + '-' + id, this);
|
|
@@ -64,9 +65,6 @@ export default class Agent {
|
|
|
64
65
|
this.threads.set(id, thread);
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
if (reply)
|
|
68
|
-
thread.reply = reply;
|
|
69
|
-
|
|
70
68
|
return thread;
|
|
71
69
|
}
|
|
72
70
|
|
|
@@ -82,7 +80,8 @@ export default class Agent {
|
|
|
82
80
|
return null;
|
|
83
81
|
}
|
|
84
82
|
|
|
85
|
-
async message(
|
|
83
|
+
async message(thread_id, content) {
|
|
84
|
+
const thread = await this.getThread(thread_id);
|
|
86
85
|
await this.log('user_message', content);
|
|
87
86
|
thread.addMessage('user', content);
|
|
88
87
|
|
|
@@ -137,17 +136,27 @@ export default class Agent {
|
|
|
137
136
|
return this.generateCompletion(thread, options, retry_counter + 1);
|
|
138
137
|
}
|
|
139
138
|
|
|
140
|
-
await
|
|
139
|
+
await this.error(thread, error.response.status + ': ' + JSON.stringify(error.response.data));
|
|
141
140
|
} else if (error.message) {
|
|
142
141
|
console.error(error.message);
|
|
143
|
-
await
|
|
142
|
+
await this.error(thread, error.message);
|
|
144
143
|
} else {
|
|
145
144
|
console.error(error);
|
|
146
|
-
await
|
|
145
|
+
await this.error(thread, 'Errore interno');
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
148
|
}
|
|
150
149
|
|
|
150
|
+
async error(thread, error) {
|
|
151
|
+
for (let i of this.options.interfaces)
|
|
152
|
+
await i.error(thread, error);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async output(thread, msg) {
|
|
156
|
+
for (let i of this.options.interfaces)
|
|
157
|
+
await i.output(thread, msg);
|
|
158
|
+
}
|
|
159
|
+
|
|
151
160
|
parseFunctions(message) {
|
|
152
161
|
const newContent = [];
|
|
153
162
|
for (let m of message.content) {
|
|
@@ -182,7 +191,7 @@ export default class Agent {
|
|
|
182
191
|
for (let m of message.content) {
|
|
183
192
|
switch (m.type) {
|
|
184
193
|
case 'text':
|
|
185
|
-
await
|
|
194
|
+
await this.output(thread, m.content);
|
|
186
195
|
break;
|
|
187
196
|
|
|
188
197
|
case 'function':
|
package/Interface.js
ADDED
package/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import Tool from "./Tool.js";
|
|
|
7
7
|
import Logger from "./Logger.js";
|
|
8
8
|
import MemoryHandler from "./MemoryHandler.js";
|
|
9
9
|
import Summarizer from "./Summarizer.js";
|
|
10
|
+
import Interface from "./Interface.js";
|
|
10
11
|
|
|
11
12
|
export {
|
|
12
13
|
Symposium,
|
|
@@ -16,4 +17,5 @@ export {
|
|
|
16
17
|
Logger,
|
|
17
18
|
MemoryHandler,
|
|
18
19
|
Summarizer,
|
|
20
|
+
Interface,
|
|
19
21
|
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "symposium",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.10.1",
|
|
5
5
|
"description": "Agents",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"author": "Domenico Giambra",
|
|
8
8
|
"license": "ISC",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@anthropic-ai/sdk": "^0.33.0",
|
|
11
|
-
"groq-sdk": "^0.
|
|
11
|
+
"groq-sdk": "^0.12.0",
|
|
12
12
|
"openai": "^4.12.1",
|
|
13
13
|
"tiktoken": "^1.0.10"
|
|
14
14
|
}
|