@divyacon/piece-google-gemini 0.0.0-stage → 0.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/LICENSE.MIT-AP +24 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actions/chat-gemini.action.d.ts +6 -0
- package/dist/lib/actions/chat-gemini.action.d.ts.map +1 -0
- package/dist/lib/actions/chat-gemini.action.js +74 -0
- package/dist/lib/actions/chat-gemini.action.js.map +1 -0
- package/dist/lib/actions/create-video.action.d.ts +11 -0
- package/dist/lib/actions/create-video.action.d.ts.map +1 -0
- package/dist/lib/actions/create-video.action.js +183 -0
- package/dist/lib/actions/create-video.action.js.map +1 -0
- package/dist/lib/actions/generate-content-from-image.action.d.ts +6 -0
- package/dist/lib/actions/generate-content-from-image.action.d.ts.map +1 -0
- package/dist/lib/actions/generate-content-from-image.action.js +66 -0
- package/dist/lib/actions/generate-content-from-image.action.js.map +1 -0
- package/dist/lib/actions/generate-content-with-file-search.d.ts +7 -0
- package/dist/lib/actions/generate-content-with-file-search.d.ts.map +1 -0
- package/dist/lib/actions/generate-content-with-file-search.js +83 -0
- package/dist/lib/actions/generate-content-with-file-search.js.map +1 -0
- package/dist/lib/actions/generate-content.action.d.ts +7 -0
- package/dist/lib/actions/generate-content.action.d.ts.map +1 -0
- package/dist/lib/actions/generate-content.action.js +192 -0
- package/dist/lib/actions/generate-content.action.js.map +1 -0
- package/dist/lib/actions/text-to-speech.action.d.ts +7 -0
- package/dist/lib/actions/text-to-speech.action.d.ts.map +1 -0
- package/dist/lib/actions/text-to-speech.action.js +137 -0
- package/dist/lib/actions/text-to-speech.action.js.map +1 -0
- package/dist/lib/auth.d.ts +2 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +42 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/common/common.d.ts +49 -0
- package/dist/lib/common/common.d.ts.map +1 -0
- package/dist/lib/common/common.js +84 -0
- package/dist/lib/common/common.js.map +1 -0
- package/dist/lib/output-schemas.d.ts +7 -0
- package/dist/lib/output-schemas.d.ts.map +1 -0
- package/dist/lib/output-schemas.js +129 -0
- package/dist/lib/output-schemas.js.map +1 -0
- package/package.json +50 -3
- package/src/index.ts +35 -0
- package/src/lib/actions/chat-gemini.action.ts +78 -0
- package/src/lib/actions/create-video.action.ts +206 -0
- package/src/lib/actions/generate-content-from-image.action.ts +67 -0
- package/src/lib/actions/generate-content-with-file-search.ts +82 -0
- package/src/lib/actions/generate-content.action.ts +199 -0
- package/src/lib/actions/text-to-speech.action.ts +143 -0
- package/src/lib/auth.ts +38 -0
- package/src/lib/common/common.ts +121 -0
- package/src/lib/output-schemas.ts +131 -0
- package/README.md +0 -3
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateContentAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/google-gemini/src/lib/actions/generate-content.action.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
9
|
+
const common_1 = require("../common/common");
|
|
10
|
+
const genai_1 = require("@google/genai");
|
|
11
|
+
const pieces_framework_2 = require("@agnocon/pieces-framework");
|
|
12
|
+
const pieces_framework_3 = require("@agnocon/pieces-framework");
|
|
13
|
+
const mime_types_1 = tslib_1.__importDefault(require("mime-types"));
|
|
14
|
+
const output_schemas_1 = require("../output-schemas");
|
|
15
|
+
exports.generateContentAction = (0, pieces_framework_1.createAction)({
|
|
16
|
+
audience: 'both',
|
|
17
|
+
description: 'Generate content using Google Gemini using the "gemini-pro" model',
|
|
18
|
+
aiMetadata: { description: 'Runs a single stateless prompt through a Gemini text model and returns the generated text, optionally grounded by one built-in tool: Google Search for live web results, URL Context to fetch pages named in the prompt, Google Maps scoped to a latitude/longitude, or File Search over an uploaded file. Use this as the default Gemini text-generation call; prefer chat_gemini when the exchange needs conversation memory, generate_content_from_image when the input includes an image, and create_video or text-to-speech for non-text output. Not idempotent: each call produces a fresh completion, and the File Search mode additionally creates a new file search store.', idempotent: false },
|
|
19
|
+
displayName: 'Generate Content',
|
|
20
|
+
name: 'generate_content',
|
|
21
|
+
auth: auth_1.googleGeminiAuth,
|
|
22
|
+
props: {
|
|
23
|
+
prompt: pieces_framework_1.Property.LongText({
|
|
24
|
+
displayName: 'Prompt',
|
|
25
|
+
required: true,
|
|
26
|
+
description: 'The prompt to generate content from.',
|
|
27
|
+
}),
|
|
28
|
+
model: pieces_framework_1.Property.Dropdown({
|
|
29
|
+
displayName: 'Model',
|
|
30
|
+
required: true,
|
|
31
|
+
description: 'The model which will generate the completion',
|
|
32
|
+
refreshers: [],
|
|
33
|
+
defaultValue: common_1.defaultLLM,
|
|
34
|
+
auth: auth_1.googleGeminiAuth,
|
|
35
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) { return (0, common_1.getGeminiModelOptions)({ auth }); }),
|
|
36
|
+
}),
|
|
37
|
+
toolType: pieces_framework_1.Property.StaticDropdown({
|
|
38
|
+
displayName: 'Tool Type',
|
|
39
|
+
description: 'Select built-in tool to use with Gemini model.',
|
|
40
|
+
required: false,
|
|
41
|
+
options: {
|
|
42
|
+
disabled: false,
|
|
43
|
+
options: [
|
|
44
|
+
{ label: 'Google Search', value: 'google-search' },
|
|
45
|
+
{ label: 'File Search', value: 'file-search' },
|
|
46
|
+
{ label: 'Google Maps', value: 'google-maps' },
|
|
47
|
+
{ label: 'URL Context', value: 'url-context' },
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
toolProperties: pieces_framework_1.Property.DynamicProperties({
|
|
52
|
+
displayName: 'Tool Config',
|
|
53
|
+
auth: auth_1.googleGeminiAuth,
|
|
54
|
+
refreshers: ['toolType'],
|
|
55
|
+
required: false,
|
|
56
|
+
props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, toolType }) {
|
|
57
|
+
if (!auth || !toolType)
|
|
58
|
+
return {};
|
|
59
|
+
let props = {};
|
|
60
|
+
switch (toolType) {
|
|
61
|
+
case 'file-search':
|
|
62
|
+
props = {
|
|
63
|
+
file: pieces_framework_1.Property.File({
|
|
64
|
+
displayName: 'File',
|
|
65
|
+
required: true,
|
|
66
|
+
description: 'File to use for search tool.',
|
|
67
|
+
}),
|
|
68
|
+
fileStoreName: pieces_framework_1.Property.ShortText({
|
|
69
|
+
displayName: 'File Store Name',
|
|
70
|
+
required: true,
|
|
71
|
+
}),
|
|
72
|
+
};
|
|
73
|
+
break;
|
|
74
|
+
case 'url-context':
|
|
75
|
+
props = {
|
|
76
|
+
mrkdown: pieces_framework_1.Property.MarkDown({
|
|
77
|
+
variant: pieces_framework_3.MarkdownVariant.INFO,
|
|
78
|
+
value: 'To use URL context tool, include one or more URLs directly in the prompt. Gemini will fetch and use the page content as additional context.',
|
|
79
|
+
}),
|
|
80
|
+
};
|
|
81
|
+
break;
|
|
82
|
+
case 'google-search':
|
|
83
|
+
props = {
|
|
84
|
+
mrkdown: pieces_framework_1.Property.MarkDown({
|
|
85
|
+
variant: pieces_framework_3.MarkdownVariant.INFO,
|
|
86
|
+
value: 'To use Google Search tool, include a clear search query in the prompt. Gemini will use Google Search to retrieve up-to-date web information.',
|
|
87
|
+
}),
|
|
88
|
+
};
|
|
89
|
+
break;
|
|
90
|
+
case 'google-maps':
|
|
91
|
+
props = {
|
|
92
|
+
latitude: pieces_framework_1.Property.Number({
|
|
93
|
+
displayName: 'Latitude',
|
|
94
|
+
required: true,
|
|
95
|
+
description: 'Provide the relevant location latitude.',
|
|
96
|
+
}),
|
|
97
|
+
longitude: pieces_framework_1.Property.Number({
|
|
98
|
+
displayName: 'Longitude',
|
|
99
|
+
required: true,
|
|
100
|
+
description: 'Provide the relevant location longitude.',
|
|
101
|
+
}),
|
|
102
|
+
};
|
|
103
|
+
break;
|
|
104
|
+
default:
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
return props;
|
|
108
|
+
}),
|
|
109
|
+
}),
|
|
110
|
+
},
|
|
111
|
+
outputSchema: output_schemas_1.generateContentActionOutputSchema,
|
|
112
|
+
run(_a) {
|
|
113
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
114
|
+
var _b;
|
|
115
|
+
const { model, prompt, toolType } = propsValue;
|
|
116
|
+
const toolProperties = (_b = propsValue.toolProperties) !== null && _b !== void 0 ? _b : {};
|
|
117
|
+
const genAI = new genai_1.GoogleGenAI({ apiKey: auth.secret_text });
|
|
118
|
+
const params = {
|
|
119
|
+
model,
|
|
120
|
+
contents: prompt,
|
|
121
|
+
};
|
|
122
|
+
const generate = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
const response = yield genAI.models.generateContent(params);
|
|
124
|
+
return response.text;
|
|
125
|
+
});
|
|
126
|
+
if ((0, pieces_framework_2.isEmpty)(toolType)) {
|
|
127
|
+
return generate();
|
|
128
|
+
}
|
|
129
|
+
switch (toolType) {
|
|
130
|
+
case 'file-search': {
|
|
131
|
+
const { file, fileStoreName } = toolProperties;
|
|
132
|
+
const fileBlob = new Blob([Buffer.from(file.base64, 'base64')], {
|
|
133
|
+
type: mime_types_1.default.lookup(file.extension || file.filename) || undefined,
|
|
134
|
+
});
|
|
135
|
+
const fileSearchStore = yield genAI.fileSearchStores.create({
|
|
136
|
+
config: { displayName: fileStoreName },
|
|
137
|
+
});
|
|
138
|
+
let operation = yield genAI.fileSearchStores.uploadToFileSearchStore({
|
|
139
|
+
file: fileBlob,
|
|
140
|
+
fileSearchStoreName: fileSearchStore.name,
|
|
141
|
+
config: {
|
|
142
|
+
displayName: file.filename,
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
while (!operation.done) {
|
|
146
|
+
yield new Promise((resolve) => setTimeout(resolve, 5000));
|
|
147
|
+
operation = yield genAI.operations.get({ operation });
|
|
148
|
+
}
|
|
149
|
+
params.config = {
|
|
150
|
+
tools: [
|
|
151
|
+
{
|
|
152
|
+
fileSearch: {
|
|
153
|
+
fileSearchStoreNames: [fileSearchStore.name],
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
};
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
case 'url-context': {
|
|
161
|
+
params.config = {
|
|
162
|
+
tools: [{ urlContext: {} }],
|
|
163
|
+
};
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
case 'google-search': {
|
|
167
|
+
params.config = {
|
|
168
|
+
tools: [{ googleSearch: {} }],
|
|
169
|
+
};
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
case 'google-maps': {
|
|
173
|
+
const { latitude, longitude } = toolProperties;
|
|
174
|
+
params.config = {
|
|
175
|
+
tools: [{ googleMaps: {} }],
|
|
176
|
+
toolConfig: {
|
|
177
|
+
retrievalConfig: {
|
|
178
|
+
latLng: {
|
|
179
|
+
latitude,
|
|
180
|
+
longitude,
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return generate();
|
|
189
|
+
});
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
//# sourceMappingURL=generate-content.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-content.action.js","sourceRoot":"","sources":["../../../src/lib/actions/generate-content.action.ts"],"names":[],"mappings":";;;;AAAA,uHAAuH;AACvH,qEAAqE;AACrE,kCAA2C;AAC3C,gEAA8F;AAC9F,6CAAqE;AACrE,yCAAuE;AACvE,gEAAoD;AACpD,gEAA4D;AAC5D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a,CAAC,CAAC,CAAC;oBACpB,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,cAAyD,CAAC;oBAE1F,MAAM,CAAC,MAAM,GAAG;wBACf,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;wBAC3B,UAAU,EAAE;4BACX,eAAe,EAAE;gCAChB,MAAM,EAAE;oCACP,QAAQ;oCACR,SAAS;iCACT;6BACD;yBACD;qBACD,CAAC;oBAEF,MAAM;gBACP,CAAC;YACF,CAAC;YAED,OAAO,QAAQ,EAAE,CAAC;QACnB,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const textToSpeechAction: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
model: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
|
|
3
|
+
text: import("@agnocon/pieces-framework").LongTextProperty<true>;
|
|
4
|
+
voice: import("@agnocon/pieces-framework").StaticDropdownProperty<string, true>;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function pcmToWavBuffer(pcmBuffer: Buffer, channels?: number, rate?: number, sampleWidth?: number): Promise<Buffer>;
|
|
7
|
+
//# sourceMappingURL=text-to-speech.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-to-speech.action.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/text-to-speech.action.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,kBAAkB;;;;EAmG7B,CAAC;AAEH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,QAAQ,SAAI,EACZ,IAAI,SAAQ,EACZ,WAAW,SAAI,GACd,OAAO,CAAC,MAAM,CAAC,CA4BjB"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textToSpeechAction = void 0;
|
|
4
|
+
exports.pcmToWavBuffer = pcmToWavBuffer;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
// Vendored from Activepieces packages/pieces/community/google-gemini/src/lib/actions/text-to-speech.action.ts (MIT).
|
|
7
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
8
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
9
|
+
const auth_1 = require("../auth");
|
|
10
|
+
const common_1 = require("../common/common");
|
|
11
|
+
const genai_1 = require("@google/genai");
|
|
12
|
+
const wav_1 = tslib_1.__importDefault(require("wav"));
|
|
13
|
+
const stream_1 = require("stream");
|
|
14
|
+
const output_schemas_1 = require("../output-schemas");
|
|
15
|
+
exports.textToSpeechAction = (0, pieces_framework_1.createAction)({
|
|
16
|
+
audience: 'both',
|
|
17
|
+
name: 'text-to-speech',
|
|
18
|
+
auth: auth_1.googleGeminiAuth,
|
|
19
|
+
displayName: 'Text to Speech',
|
|
20
|
+
description: 'Converts text to audio file.',
|
|
21
|
+
aiMetadata: { description: 'Synthesizes spoken audio from input text using a Gemini TTS model and one of roughly thirty prebuilt named voices, returning a WAV file. This is the audio-output sibling of generate_content: use it when the flow needs speech instead of text, and create_video when it needs video. Requires a TTS-capable model, which the model dropdown restricts to. Not idempotent: each call renders a new audio file.', idempotent: false },
|
|
22
|
+
props: {
|
|
23
|
+
model: pieces_framework_1.Property.Dropdown({
|
|
24
|
+
displayName: 'Model',
|
|
25
|
+
required: true,
|
|
26
|
+
auth: auth_1.googleGeminiAuth,
|
|
27
|
+
refreshers: [],
|
|
28
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) { return (0, common_1.getGeminiTtsModelOptions)({ auth }); }),
|
|
29
|
+
}),
|
|
30
|
+
text: pieces_framework_1.Property.LongText({
|
|
31
|
+
displayName: 'Input Text',
|
|
32
|
+
required: true,
|
|
33
|
+
}),
|
|
34
|
+
voice: pieces_framework_1.Property.StaticDropdown({
|
|
35
|
+
displayName: 'Voice',
|
|
36
|
+
required: true,
|
|
37
|
+
options: {
|
|
38
|
+
disabled: false,
|
|
39
|
+
options: [
|
|
40
|
+
{ label: 'Zephyr (Bright)', value: 'Zephyr' },
|
|
41
|
+
{ label: 'Puck (Upbeat)', value: 'Puck' },
|
|
42
|
+
{ label: 'Charon (Informative)', value: 'Charon' },
|
|
43
|
+
{ label: 'Kore (Firm)', value: 'Kore' },
|
|
44
|
+
{ label: 'Fenrir (Excitable)', value: 'Fenrir' },
|
|
45
|
+
{ label: 'Leda (Youthful)', value: 'Leda' },
|
|
46
|
+
{ label: 'Orus (Firm)', value: 'Orus' },
|
|
47
|
+
{ label: 'Aoede (Breezy)', value: 'Aoede' },
|
|
48
|
+
{ label: 'Callirrhoe (Easy-going)', value: 'Callirrhoe' },
|
|
49
|
+
{ label: 'Autonoe (Bright)', value: 'Autonoe' },
|
|
50
|
+
{ label: 'Enceladus (Breathy)', value: 'Enceladus' },
|
|
51
|
+
{ label: 'Iapetus (Clear)', value: 'Iapetus' },
|
|
52
|
+
{ label: 'Umbriel (Easy-going)', value: 'Umbriel' },
|
|
53
|
+
{ label: 'Algieba (Smooth)', value: 'Algieba' },
|
|
54
|
+
{ label: 'Despina (Smooth)', value: 'Despina' },
|
|
55
|
+
{ label: 'Erinome (Clear)', value: 'Erinome' },
|
|
56
|
+
{ label: 'Algenib (Gravelly)', value: 'Algenib' },
|
|
57
|
+
{ label: 'Rasalgethi (Informative)', value: 'Rasalgethi' },
|
|
58
|
+
{ label: 'Laomedeia (Upbeat)', value: 'Laomedeia' },
|
|
59
|
+
{ label: 'Achernar (Soft)', value: 'Achernar' },
|
|
60
|
+
{ label: 'Alnilam (Firm)', value: 'Alnilam' },
|
|
61
|
+
{ label: 'Schedar (Even)', value: 'Schedar' },
|
|
62
|
+
{ label: 'Gacrux (Mature)', value: 'Gacrux' },
|
|
63
|
+
{ label: 'Pulcherrima (Forward)', value: 'Pulcherrima' },
|
|
64
|
+
{ label: 'Achird (Friendly)', value: 'Achird' },
|
|
65
|
+
{ label: 'Zubenelgenubi (Casual)', value: 'Zubenelgenubi' },
|
|
66
|
+
{ label: 'Vindemiatrix (Gentle)', value: 'Vindemiatrix' },
|
|
67
|
+
{ label: 'Sadachbia (Lively)', value: 'Sadachbia' },
|
|
68
|
+
{ label: 'Sadaltager (Knowledgeable)', value: 'Sadaltager' },
|
|
69
|
+
{ label: 'Sulafat (Warm)', value: 'Sulafat' },
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
},
|
|
74
|
+
outputSchema: output_schemas_1.textToSpeechActionOutputSchema,
|
|
75
|
+
run(context) {
|
|
76
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
var _a, _b, _c, _d, _e, _f;
|
|
78
|
+
const { text, model, voice } = context.propsValue;
|
|
79
|
+
try {
|
|
80
|
+
const genAI = new genai_1.GoogleGenAI({ apiKey: context.auth.secret_text });
|
|
81
|
+
const response = yield genAI.models.generateContent({
|
|
82
|
+
model,
|
|
83
|
+
contents: [{ parts: [{ text }] }],
|
|
84
|
+
config: {
|
|
85
|
+
responseModalities: ['AUDIO'],
|
|
86
|
+
speechConfig: {
|
|
87
|
+
voiceConfig: {
|
|
88
|
+
prebuiltVoiceConfig: { voiceName: voice },
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
const data = (_f = (_e = (_d = (_c = (_b = (_a = response.candidates) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.parts) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.inlineData) === null || _f === void 0 ? void 0 : _f.data;
|
|
94
|
+
if (!data) {
|
|
95
|
+
throw new Error('No audio data returned from model response.');
|
|
96
|
+
}
|
|
97
|
+
const pcmBuffer = Buffer.from(data, 'base64');
|
|
98
|
+
const wavBuffer = yield pcmToWavBuffer(pcmBuffer, 1, 24000, 2);
|
|
99
|
+
return yield context.files.write({
|
|
100
|
+
data: wavBuffer,
|
|
101
|
+
fileName: 'audio.wav',
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
console.error('Error in generate content from image:', error);
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
function pcmToWavBuffer(pcmBuffer_1) {
|
|
112
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (pcmBuffer, channels = 1, rate = 24000, sampleWidth = 2) {
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
const wavBuffers = [];
|
|
115
|
+
const writer = new wav_1.default.Writer({
|
|
116
|
+
channels,
|
|
117
|
+
sampleRate: rate,
|
|
118
|
+
bitDepth: sampleWidth * 8,
|
|
119
|
+
});
|
|
120
|
+
const writable = new stream_1.Writable({
|
|
121
|
+
write(chunk, _encoding, callback) {
|
|
122
|
+
wavBuffers.push(chunk);
|
|
123
|
+
callback();
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
writer.pipe(writable);
|
|
127
|
+
writer.write(pcmBuffer);
|
|
128
|
+
writer.end();
|
|
129
|
+
writer.on('finish', () => {
|
|
130
|
+
const fullWavBuffer = Buffer.concat(wavBuffers);
|
|
131
|
+
resolve(fullWavBuffer);
|
|
132
|
+
});
|
|
133
|
+
writer.on('error', (err) => reject(err));
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=text-to-speech.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-to-speech.action.js","sourceRoot":"","sources":["../../../src/lib/actions/text-to-speech.action.ts"],"names":[],"mappings":";;;AA+GA,wCAiCC;;AAhJD,qHAAqH;AACrH,qEAAqE;AACrE,gEAAmE;AACnE,kCAA2C;AAC3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AM,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;gBACvB,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;gBAChD,OAAO,CAAC,aAAa,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,gBAAgB,8DA2B3B,CAAC"}
|
package/dist/lib/auth.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.googleGeminiAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/google-gemini/src/lib/auth.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
9
|
+
const markdownDescription = `
|
|
10
|
+
Follow these instructions to get your API Key:
|
|
11
|
+
1. Visit the following website: https://makersuite.google.com/app/apikey
|
|
12
|
+
2. Once on the website, locate and click on the option to obtain your API Key.
|
|
13
|
+
Please note this piece uses a API in the beta phase that may change at any time.
|
|
14
|
+
`;
|
|
15
|
+
exports.googleGeminiAuth = pieces_framework_1.PieceAuth.SecretText({
|
|
16
|
+
description: markdownDescription,
|
|
17
|
+
displayName: 'API Key',
|
|
18
|
+
required: true,
|
|
19
|
+
validate: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
21
|
+
try {
|
|
22
|
+
yield pieces_common_1.httpClient.sendRequest({
|
|
23
|
+
url: 'https://generativelanguage.googleapis.com/v1beta/models?key=' +
|
|
24
|
+
auth.auth,
|
|
25
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
valid: true,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
const extraErrorInfo = ((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message)
|
|
33
|
+
? `${(_f = (_e = (_d = e.response) === null || _d === void 0 ? void 0 : _d.body) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.message} status:${(_j = (_h = (_g = e.response) === null || _g === void 0 ? void 0 : _g.body) === null || _h === void 0 ? void 0 : _h.error) === null || _j === void 0 ? void 0 : _j.code}`
|
|
34
|
+
: e;
|
|
35
|
+
return {
|
|
36
|
+
valid: false,
|
|
37
|
+
error: `${extraErrorInfo}`,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":";;;;AAAA,4FAA4F;AAC5F,qEAAqE;AACrE,gEAAsD;AACtD,0DAAgE;AAEhE,MAAM,mBAAmB,GAAG;;;;;CAK3B,CAAC;AAEW,QAAA,gBAAgB,GAAG,4BAAS,CAAC,UAAU,CAAC;IACnD,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,SAAS;IACtB,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,CAAO,IAAI,EAAE,EAAE;;QACvB,IAAI,CAAC;YACH,MAAM,0BAAU,CAAC,WAAW,CAEzB;gBACD,GAAG,EACD,8DAA8D;oBAC9D,IAAI,CAAC,IAAI;gBACX,MAAM,EAAE,0BAAU,CAAC,GAAG;aACvB,CAAC,CAAC;YACH,OAAO;gBACL,KAAK,EAAE,IAAI;aACZ,CAAC;QACJ,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,cAAc,GAAG,CAAA,MAAA,MAAA,MAAA,CAAC,CAAC,QAAQ,0CAAE,IAAI,0CAAE,KAAK,0CAAE,OAAO;gBACrD,CAAC,CAAC,GAAG,MAAA,MAAA,MAAA,CAAC,CAAC,QAAQ,0CAAE,IAAI,0CAAE,KAAK,0CAAE,OAAO,WAAW,MAAA,MAAA,MAAA,CAAC,CAAC,QAAQ,0CAAE,IAAI,0CAAE,KAAK,0CAAE,IAAI,EAAE;gBAC/E,CAAC,CAAC,CAAC,CAAC;YACN,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,GAAG,cAAc,EAAE;aAC3B,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { AppConnectionValueForAuthProperty } from '@agnocon/pieces-framework';
|
|
2
|
+
import { googleGeminiAuth } from '../auth';
|
|
3
|
+
export declare const defaultLLM = "gemini-1.5-flash";
|
|
4
|
+
export declare const allowedLLMs: string[];
|
|
5
|
+
export declare const getGeminiModelOptions: ({ auth }: {
|
|
6
|
+
auth?: GeminiAuth;
|
|
7
|
+
}) => Promise<{
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
placeholder: string;
|
|
10
|
+
options: never[];
|
|
11
|
+
} | {
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
options: {
|
|
14
|
+
label: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}[];
|
|
17
|
+
placeholder?: undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const getGeminiTtsModelOptions: ({ auth }: {
|
|
20
|
+
auth?: GeminiAuth;
|
|
21
|
+
}) => Promise<{
|
|
22
|
+
disabled: boolean;
|
|
23
|
+
placeholder: string;
|
|
24
|
+
options: never[];
|
|
25
|
+
} | {
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
options: {
|
|
28
|
+
label: string;
|
|
29
|
+
value: string;
|
|
30
|
+
}[];
|
|
31
|
+
placeholder?: undefined;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const getGeminiVideoModelOptions: ({ auth, }: {
|
|
34
|
+
auth?: GeminiAuth;
|
|
35
|
+
}) => Promise<{
|
|
36
|
+
disabled: boolean;
|
|
37
|
+
placeholder: string;
|
|
38
|
+
options: never[];
|
|
39
|
+
} | {
|
|
40
|
+
disabled: boolean;
|
|
41
|
+
options: {
|
|
42
|
+
label: string;
|
|
43
|
+
value: string;
|
|
44
|
+
}[];
|
|
45
|
+
placeholder?: undefined;
|
|
46
|
+
}>;
|
|
47
|
+
type GeminiAuth = AppConnectionValueForAuthProperty<typeof googleGeminiAuth>;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/lib/common/common.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,UAAU,qBAAqB,CAAC;AAE7C,eAAO,MAAM,WAAW,UASvB,CAAC;AA6EF,eAAO,MAAM,qBAAqB,aAAoB;IAAE,IAAI,CAAC,EAAE,UAAU,CAAA;CAAE;;;;;;;;;;;EACxB,CAAC;AAEpD,eAAO,MAAM,wBAAwB,aAAoB;IAAE,IAAI,CAAC,EAAE,UAAU,CAAA;CAAE;;;;;;;;;;;EAC7B,CAAC;AAElD,eAAO,MAAM,0BAA0B,cAEpC;IACD,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;;;;;;;;;;;EAAoD,CAAC;AAEtD,KAAK,UAAU,GAAG,iCAAiC,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGeminiVideoModelOptions = exports.getGeminiTtsModelOptions = exports.getGeminiModelOptions = exports.allowedLLMs = exports.defaultLLM = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/google-gemini/src/lib/common/common.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
8
|
+
exports.defaultLLM = 'gemini-1.5-flash';
|
|
9
|
+
exports.allowedLLMs = [
|
|
10
|
+
'gemini-1.5-flash',
|
|
11
|
+
'gemini-1.5-flash-8b',
|
|
12
|
+
'gemini-1.5-pro',
|
|
13
|
+
'gemini-2.0-flash',
|
|
14
|
+
'gemini-2.0-flash-lite',
|
|
15
|
+
'gemini-2.5-flash',
|
|
16
|
+
'gemini-2.5-pro',
|
|
17
|
+
'gemini-3-pro'
|
|
18
|
+
];
|
|
19
|
+
const isAllowedLLM = (model) => exports.allowedLLMs.some((allowed) => model.name.startsWith(`models/${allowed}`));
|
|
20
|
+
const isTtsModel = (model) => {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
return model.name.toLowerCase().includes('tts') ||
|
|
23
|
+
((_b = (_a = model.displayName) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('tts')) !== null && _b !== void 0 ? _b : false);
|
|
24
|
+
};
|
|
25
|
+
const isVeoModel = (model) => model.name.toLowerCase().includes('veo');
|
|
26
|
+
const listAllModels = (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, }) {
|
|
27
|
+
var _b;
|
|
28
|
+
const models = [];
|
|
29
|
+
let pageToken = undefined;
|
|
30
|
+
do {
|
|
31
|
+
const queryParams = {
|
|
32
|
+
key: auth.secret_text,
|
|
33
|
+
pageSize: '1000',
|
|
34
|
+
};
|
|
35
|
+
if (pageToken) {
|
|
36
|
+
queryParams['pageToken'] = pageToken;
|
|
37
|
+
}
|
|
38
|
+
const { body } = yield pieces_common_1.httpClient.sendRequest({
|
|
39
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
40
|
+
url: 'https://generativelanguage.googleapis.com/v1beta/models',
|
|
41
|
+
queryParams,
|
|
42
|
+
});
|
|
43
|
+
models.push(...((_b = body.models) !== null && _b !== void 0 ? _b : []));
|
|
44
|
+
pageToken = body.nextPageToken;
|
|
45
|
+
} while (pageToken);
|
|
46
|
+
return models;
|
|
47
|
+
});
|
|
48
|
+
const fetchModelOptions = (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, filter, }) {
|
|
49
|
+
if (!auth) {
|
|
50
|
+
return {
|
|
51
|
+
disabled: true,
|
|
52
|
+
placeholder: 'Enter your API key first',
|
|
53
|
+
options: [],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const models = yield listAllModels({ auth });
|
|
58
|
+
const options = models.filter(filter).map((model) => {
|
|
59
|
+
var _a;
|
|
60
|
+
return ({
|
|
61
|
+
label: (_a = model.displayName) !== null && _a !== void 0 ? _a : model.name.replace('models/', ''),
|
|
62
|
+
value: model.name.replace('models/', ''),
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
disabled: false,
|
|
67
|
+
options,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (_b) {
|
|
71
|
+
return {
|
|
72
|
+
disabled: true,
|
|
73
|
+
options: [],
|
|
74
|
+
placeholder: "Couldn't load models, check your API key or try again.",
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const getGeminiModelOptions = (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) { return fetchModelOptions({ auth, filter: isAllowedLLM }); });
|
|
79
|
+
exports.getGeminiModelOptions = getGeminiModelOptions;
|
|
80
|
+
const getGeminiTtsModelOptions = (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) { return fetchModelOptions({ auth, filter: isTtsModel }); });
|
|
81
|
+
exports.getGeminiTtsModelOptions = getGeminiTtsModelOptions;
|
|
82
|
+
const getGeminiVideoModelOptions = (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, }) { return fetchModelOptions({ auth, filter: isVeoModel }); });
|
|
83
|
+
exports.getGeminiVideoModelOptions = getGeminiVideoModelOptions;
|
|
84
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/lib/common/common.ts"],"names":[],"mappings":";;;;AAAA,qGAAqG;AACrG,qEAAqE;AACrE,0DAKgC;AAInB,QAAA,UAAU,GAAG,kBAAkB,CAAC;AAEhC,QAAA,WAAW,GAAG;IACzB,kBAAkB;IAClB,qBAAqB;IACrB,gBAAgB;IAChB,kBAAkB;IAClB,uBAAuB;IACvB,kBAAkB;IAClB,gBAAgB;IAChB,cAAc;CACf,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,KAAkB,EAAW,EAAE,CACnD,mBAAW,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC,CAAC;AAE5E,MAAM,UAAU,GAAG,CAAC,KAAkB,EAAW,EAAE;;IACjD,OAAA,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;QACxC,CAAC,MAAA,MAAA,KAAK,CAAC,WAAW,0CAAE,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,mCAAI,KAAK,CAAC,CAAA;CAAA,CAAC;AAE9D,MAAM,UAA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C,KAAK,EAAE,EAAE;;YAAC,OAAA,CAAC;gBACpD,KAAK,EAAE,MAAA,KAAK,CAAC,WAAW,mCAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;gBAC7D,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;aACzC,CAAC,CAAA;SAAA,CAAC,CAAC;QAEJ,OAAO;YACL,QAAQ,EAAE,KAAK;YACf,OAAO;SACR,CAAC;IACJ,CAAC;IAAC,WAAM,CAAC;QACP,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,wDAAwD;SACtE,CAAC;IACJ,CAAC;AACH,CAAC,CAAA,CAAC;AAEK,MAAM,qBAAqB,GAAG,KAAwC,EAAE,oDAAnC,EAAE,IAAI,EAAyB,IACzE,OAAA,iBAAiB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAA,GAAA,CAAC;AADvC,QAAA,qBAAqB,yBACkB;AAE7C,MAAM,wBAAwB,GAAG,KAAwC,EAAE,oDAAnC,EAAE,IAAI,EAAyB,IAC5E,OAAA,iBAAiB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA,GAAA,CAAC;AADrC,QAAA,wBAAwB,4BACa;AAE3C,MAAM,0BAA0B,GAAG,KAIvC,EAAE,oDAJ4C,EAC/C,IAAI,GAGL,IAAK,OAAA,iBAAiB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA,GAAA,CAAC;AAJzC,QAAA,0BAA0B,8BAIe"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OutputSchema } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const generateContentActionOutputSchema: OutputSchema;
|
|
3
|
+
export declare const chatGeminiActionOutputSchema: OutputSchema;
|
|
4
|
+
export declare const generateContentFromImageActionOutputSchema: OutputSchema;
|
|
5
|
+
export declare const generateContentWithFilesearchActionOutputSchema: OutputSchema;
|
|
6
|
+
export declare const textToSpeechActionOutputSchema: OutputSchema;
|
|
7
|
+
//# sourceMappingURL=output-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-schemas.d.ts","sourceRoot":"","sources":["../../src/lib/output-schemas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,eAAO,MAAM,iCAAiC,EAAE,YAQ/C,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,YAyB1C,CAAC;AAEF,eAAO,MAAM,0CAA0C,EAAE,YAsExD,CAAC;AAEF,eAAO,MAAM,+CAA+C,EAAE,YAQ7D,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,YAS5C,CAAC"}
|