-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathgenerate-embeddings.mjs
62 lines (60 loc) · 1.55 KB
/
generate-embeddings.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import app from "../../google_gemini.app.mjs";
import constants from "../../common/constants.mjs";
export default {
key: "google_gemini-generate-embeddings",
name: "Generate Embeddings",
description: "Generate embeddings from text input using Google Gemini. [See the documentation](https://ai.google.dev/gemini-api/docs/embeddings)",
version: "0.0.1",
type: "action",
props: {
app,
model: {
reloadProps: false,
propDefinition: [
app,
"model",
() => ({
filter: ({
description,
supportedGenerationMethods,
}) => ![
"discontinued",
"deprecated",
].some((keyword) => description?.includes(keyword))
&& supportedGenerationMethods?.includes(constants.MODEL_METHODS.EMBED_CONTENT),
}),
],
},
text: {
propDefinition: [
app,
"text",
],
description: "The text to generate embeddings for",
},
taskType: {
type: "string",
label: "Task Type",
description: "The type of task for which the embeddings will be used",
options: Object.values(constants.TASK_TYPE),
optional: true,
},
},
async run({ $ }) {
const response = await this.app.embedContent({
model: this.model,
data: {
taskType: this.taskType,
content: {
parts: [
{
text: this.text,
},
],
},
},
});
$.export("$summary", "Successfully generated embeddings");
return response;
},
};