symposium 2.0.0 → 2.1.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 +6 -6
- package/Models/OpenAIEmbedding.js +18 -0
- package/Summarizer.js +1 -1
- package/Symposium.js +17 -6
- package/package.json +1 -1
- /package/Models/{Gpt4oTranscribe.js → OpenAITranscribe.js} +0 -0
package/Agent.js
CHANGED
|
@@ -58,7 +58,7 @@ export default class Agent {
|
|
|
58
58
|
|
|
59
59
|
async resetState(thread) {
|
|
60
60
|
thread.state = await this.getDefaultState();
|
|
61
|
-
thread.state.model =
|
|
61
|
+
thread.state.model = this.default_model;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
async getDefaultState() {
|
|
@@ -171,7 +171,7 @@ export default class Agent {
|
|
|
171
171
|
if (typeof thread !== 'object')
|
|
172
172
|
thread = await this.getThread(thread);
|
|
173
173
|
|
|
174
|
-
const model = Symposium.
|
|
174
|
+
const model = Symposium.getModel(thread.state.model);
|
|
175
175
|
if (!model.audio && typeof content !== 'string') {
|
|
176
176
|
for (let c of content) {
|
|
177
177
|
if (c.type === 'audio' && !c.content?.transcription) {
|
|
@@ -203,7 +203,7 @@ export default class Agent {
|
|
|
203
203
|
if (counter === 0)
|
|
204
204
|
thread = await this.beforeExecute(thread, emitter);
|
|
205
205
|
|
|
206
|
-
const model = Symposium.
|
|
206
|
+
const model = Symposium.getModel(thread.state.model);
|
|
207
207
|
|
|
208
208
|
const completion_options = {};
|
|
209
209
|
if (this.type === 'utility') {
|
|
@@ -340,7 +340,7 @@ export default class Agent {
|
|
|
340
340
|
|
|
341
341
|
async generateCompletion(thread, options = {}, retry_counter = 1) {
|
|
342
342
|
try {
|
|
343
|
-
const model = Symposium.
|
|
343
|
+
const model = Symposium.getModel(thread.state.model);
|
|
344
344
|
const messages = await model.class.generate(model, thread, await this.getFunctions(), options);
|
|
345
345
|
return model.tools ? messages : messages.map(m => this.parseFunctions(m));
|
|
346
346
|
} catch (error) {
|
|
@@ -391,7 +391,7 @@ export default class Agent {
|
|
|
391
391
|
}
|
|
392
392
|
|
|
393
393
|
async handleCompletion(thread, completion, emitter) {
|
|
394
|
-
const model = Symposium.
|
|
394
|
+
const model = Symposium.getModel(thread.state.model);
|
|
395
395
|
|
|
396
396
|
const functions = [];
|
|
397
397
|
for (let message of completion) {
|
|
@@ -542,7 +542,7 @@ export default class Agent {
|
|
|
542
542
|
}
|
|
543
543
|
|
|
544
544
|
async setModel(thread, label) {
|
|
545
|
-
const model_to_switch = Symposium.
|
|
545
|
+
const model_to_switch = Symposium.getModel(label);
|
|
546
546
|
if (model_to_switch && model_to_switch.type === 'llm')
|
|
547
547
|
await thread.setState({model: model_to_switch.name});
|
|
548
548
|
else
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import OpenAIModel from "./OpenAIModel.js";
|
|
2
|
+
|
|
3
|
+
export default class OpenAIEmbedding extends OpenAIModel {
|
|
4
|
+
type = 'embedding';
|
|
5
|
+
models = new Map([
|
|
6
|
+
['openai-text-embedding-3-large', {name: 'text-embedding-3-large'}],
|
|
7
|
+
['openai-text-embedding-3-small', {name: 'text-embedding-3-small'}],
|
|
8
|
+
]);
|
|
9
|
+
|
|
10
|
+
async embed(input, model) {
|
|
11
|
+
const response = await this.getOpenAi().embeddings.create({
|
|
12
|
+
model: model.name,
|
|
13
|
+
input,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return response.data[0].embedding;
|
|
17
|
+
}
|
|
18
|
+
}
|
package/Summarizer.js
CHANGED
package/Symposium.js
CHANGED
|
@@ -39,6 +39,9 @@ export default class Symposium {
|
|
|
39
39
|
|
|
40
40
|
static loadModel(model_class) {
|
|
41
41
|
for (let [key, model] of model_class.models.entries()) {
|
|
42
|
+
if (this.models.has(key))
|
|
43
|
+
throw new Error(`Duplicate model with key "${key}"`);
|
|
44
|
+
|
|
42
45
|
this.models.set(key, {
|
|
43
46
|
...model,
|
|
44
47
|
type: model_class.type,
|
|
@@ -47,14 +50,10 @@ export default class Symposium {
|
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
|
|
50
|
-
static
|
|
53
|
+
static getModel(name) {
|
|
51
54
|
return this.models.get(name);
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
static getModelByLabel(label) {
|
|
55
|
-
return Array.from(this.models.values()).find(model => model.label === label);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
57
|
static extractFunctionsFromResponse(messages) {
|
|
59
58
|
const functions = [];
|
|
60
59
|
for (let message of messages) {
|
|
@@ -76,7 +75,7 @@ export default class Symposium {
|
|
|
76
75
|
throw new Error('Transcription model not specified');
|
|
77
76
|
|
|
78
77
|
if (!this.transcription_model)
|
|
79
|
-
this.transcription_model = Symposium.
|
|
78
|
+
this.transcription_model = Symposium.getModel(model);
|
|
80
79
|
if (!this.transcription_model.type !== 'stt')
|
|
81
80
|
throw new Error('Specified model is not a transcription model');
|
|
82
81
|
|
|
@@ -107,6 +106,18 @@ export default class Symposium {
|
|
|
107
106
|
return this.transcription_model.transcribe(file, model, prompt);
|
|
108
107
|
}
|
|
109
108
|
|
|
109
|
+
static async embed(input, model = null) {
|
|
110
|
+
model = model || process.env.EMBEDDING_MODEL;
|
|
111
|
+
if (!model)
|
|
112
|
+
throw new Error('Embedding model not specified');
|
|
113
|
+
|
|
114
|
+
const embedding_model = Symposium.getModel(model);
|
|
115
|
+
if (!embedding_model || embedding_model.type !== 'embedding')
|
|
116
|
+
throw new Error('Specified model is not an embedding model');
|
|
117
|
+
|
|
118
|
+
return embedding_model.embed(input, model);
|
|
119
|
+
}
|
|
120
|
+
|
|
110
121
|
static getExtFromMime(mime) {
|
|
111
122
|
const mimeToExt = {
|
|
112
123
|
'audio/mpeg': 'mp3',
|
package/package.json
CHANGED
|
File without changes
|