symposium 2.0.1 → 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.
|
@@ -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
|
@@ -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,
|
|
@@ -103,6 +106,18 @@ export default class Symposium {
|
|
|
103
106
|
return this.transcription_model.transcribe(file, model, prompt);
|
|
104
107
|
}
|
|
105
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
|
+
|
|
106
121
|
static getExtFromMime(mime) {
|
|
107
122
|
const mimeToExt = {
|
|
108
123
|
'audio/mpeg': 'mp3',
|
package/package.json
CHANGED
|
File without changes
|