symposium 2.0.1 → 2.1.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.
@@ -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/Symposium.js CHANGED
@@ -8,6 +8,7 @@ export default class Symposium {
8
8
  static models = new Map();
9
9
  static storage = null;
10
10
  static transcription_model = null;
11
+ static embedding_model = null;
11
12
 
12
13
  /*
13
14
  * Storage must expose the following methods:
@@ -39,6 +40,9 @@ export default class Symposium {
39
40
 
40
41
  static loadModel(model_class) {
41
42
  for (let [key, model] of model_class.models.entries()) {
43
+ if (this.models.has(key))
44
+ throw new Error(`Duplicate model with key "${key}"`);
45
+
42
46
  this.models.set(key, {
43
47
  ...model,
44
48
  type: model_class.type,
@@ -73,7 +77,7 @@ export default class Symposium {
73
77
 
74
78
  if (!this.transcription_model)
75
79
  this.transcription_model = Symposium.getModel(model);
76
- if (!this.transcription_model.type !== 'stt')
80
+ if (!!this.transcription_model || !this.transcription_model.type !== 'stt')
77
81
  throw new Error('Specified model is not a transcription model');
78
82
 
79
83
  let file;
@@ -100,7 +104,20 @@ export default class Symposium {
100
104
  break;
101
105
  }
102
106
 
103
- return this.transcription_model.transcribe(file, model, prompt);
107
+ return this.transcription_model.class.transcribe(file, model, prompt);
108
+ }
109
+
110
+ static async embed(input, model = null) {
111
+ model = model || process.env.EMBEDDING_MODEL;
112
+ if (!model)
113
+ throw new Error('Embedding model not specified');
114
+
115
+ if (!this.embedding_model)
116
+ this.embedding_model = Symposium.getModel(model);
117
+ if (!this.embedding_model || this.embedding_model.type !== 'embedding')
118
+ throw new Error('Specified model is not an embedding model');
119
+
120
+ return embedding_model.class.embed(input, model);
104
121
  }
105
122
 
106
123
  static getExtFromMime(mime) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "symposium",
4
- "version": "2.0.1",
4
+ "version": "2.1.1",
5
5
  "description": "Agents",
6
6
  "main": "index.js",
7
7
  "author": "Domenico Giambra",