symposium 0.12.3 → 0.12.5
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 +26 -7
- package/Model.js +1 -0
- package/Symposium.js +9 -0
- package/models/DeepSeekChat.js +7 -0
- package/models/DeepSeekModel.js +15 -0
- package/models/DeepSeekReasoner.js +7 -0
- package/models/Gpt4O.js +1 -0
- package/models/GptO1.js +9 -0
- package/models/GptO1Mini.js +9 -0
- package/package.json +1 -1
package/Agent.js
CHANGED
|
@@ -104,6 +104,8 @@ export default class Agent {
|
|
|
104
104
|
if (counter === 0)
|
|
105
105
|
thread = await this.beforeExecute(thread);
|
|
106
106
|
|
|
107
|
+
const model = Symposium.getModelByName(thread.state.model);
|
|
108
|
+
|
|
107
109
|
const completion_options = {};
|
|
108
110
|
if (this.utility) {
|
|
109
111
|
if (!['function', 'text'].includes(this.utility.type))
|
|
@@ -113,10 +115,22 @@ export default class Agent {
|
|
|
113
115
|
if (!this.utility.function || !this.utility.function.name || !this.utility.function.parameters)
|
|
114
116
|
throw new Error('Bad function definition');
|
|
115
117
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
if (model.supports_structured_output) {
|
|
119
|
+
// TODO: se ci sono più di 100 parametri, OpenAI non supporta gli structured output
|
|
120
|
+
completion_options.response_format = {
|
|
121
|
+
type: 'json_schema',
|
|
122
|
+
json_schema: {
|
|
123
|
+
name: this.utility.function.name,
|
|
124
|
+
schema: this.utility.function.parameters,
|
|
125
|
+
strict: true,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
} else {
|
|
129
|
+
completion_options.functions = [
|
|
130
|
+
this.utility.function,
|
|
131
|
+
];
|
|
132
|
+
completion_options.force_function = this.utility.function.name;
|
|
133
|
+
}
|
|
120
134
|
}
|
|
121
135
|
}
|
|
122
136
|
|
|
@@ -223,6 +237,8 @@ export default class Agent {
|
|
|
223
237
|
}
|
|
224
238
|
|
|
225
239
|
async handleCompletion(thread, completion) {
|
|
240
|
+
const model = Symposium.getModelByName(thread.state.model);
|
|
241
|
+
|
|
226
242
|
const functions = [];
|
|
227
243
|
for (let message of completion) {
|
|
228
244
|
thread.addDirectMessage(message);
|
|
@@ -231,9 +247,12 @@ export default class Agent {
|
|
|
231
247
|
for (let m of message.content) {
|
|
232
248
|
switch (m.type) {
|
|
233
249
|
case 'text':
|
|
234
|
-
if (this.utility
|
|
235
|
-
|
|
236
|
-
|
|
250
|
+
if (this.utility) {
|
|
251
|
+
if (this.utility.type === 'text')
|
|
252
|
+
return this.afterHandle(thread, completion, 'return', m.content);
|
|
253
|
+
if (this.utility.type === 'function' && model.supports_structured_output)
|
|
254
|
+
return this.afterHandle(thread, completion, 'return', JSON.parse(m.content));
|
|
255
|
+
}
|
|
237
256
|
await this.output(thread, m.content);
|
|
238
257
|
break;
|
|
239
258
|
|
package/Model.js
CHANGED
package/Symposium.js
CHANGED
|
@@ -2,6 +2,8 @@ import Gpt35 from "./models/Gpt35.js";
|
|
|
2
2
|
import Gpt4 from "./models/Gpt4.js";
|
|
3
3
|
import Gpt4Turbo from "./models/Gpt4Turbo.js";
|
|
4
4
|
import Gpt4O from "./models/Gpt4O.js";
|
|
5
|
+
import GptO1 from "./models/GptO1.js";
|
|
6
|
+
import GptO1Mini from "./models/GptO1Mini.js";
|
|
5
7
|
import Whisper from "./models/Whisper.js";
|
|
6
8
|
import Claude3Haiku from "./models/Claude3Haiku.js";
|
|
7
9
|
import Claude3Sonnet from "./models/Claude3Sonnet.js";
|
|
@@ -9,6 +11,8 @@ import Claude3Opus from "./models/Claude3Opus.js";
|
|
|
9
11
|
import Claude35Sonnet from "./models/Claude35Sonnet.js";
|
|
10
12
|
import Llama3 from "./models/Llama3.js";
|
|
11
13
|
import Mixtral8 from "./models/Mixtral8.js";
|
|
14
|
+
import DeepSeekChat from "./models/DeepSeekChat.js";
|
|
15
|
+
import DeepSeekReasoner from "./models/DeepSeekReasoner.js";
|
|
12
16
|
|
|
13
17
|
export default class Symposium {
|
|
14
18
|
static models = new Map();
|
|
@@ -25,6 +29,8 @@ export default class Symposium {
|
|
|
25
29
|
this.loadModel(new Gpt4());
|
|
26
30
|
this.loadModel(new Gpt4Turbo());
|
|
27
31
|
this.loadModel(new Gpt4O());
|
|
32
|
+
this.loadModel(new GptO1());
|
|
33
|
+
this.loadModel(new GptO1Mini());
|
|
28
34
|
this.loadModel(new Whisper());
|
|
29
35
|
|
|
30
36
|
this.loadModel(new Claude3Haiku());
|
|
@@ -36,6 +42,9 @@ export default class Symposium {
|
|
|
36
42
|
this.loadModel(new Llama3());
|
|
37
43
|
this.loadModel(new Mixtral8());
|
|
38
44
|
|
|
45
|
+
this.loadModel(new DeepSeekChat());
|
|
46
|
+
this.loadModel(new DeepSeekReasoner());
|
|
47
|
+
|
|
39
48
|
this.storage = storage;
|
|
40
49
|
await this.storage.init();
|
|
41
50
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import OpenAIModel from "./OpenAIModel.js";
|
|
2
|
+
import OpenAI from "openai";
|
|
3
|
+
|
|
4
|
+
export default class DeepSeekModel extends OpenAIModel {
|
|
5
|
+
getOpenAi() {
|
|
6
|
+
if (!this.openai) {
|
|
7
|
+
this.openai = new OpenAI({
|
|
8
|
+
baseURL: 'https://api.deepseek.com',
|
|
9
|
+
apiKey: process.env.DEEPSEEK_API_KEY,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return this.openai;
|
|
14
|
+
}
|
|
15
|
+
}
|
package/models/Gpt4O.js
CHANGED
package/models/GptO1.js
ADDED