pangea-server 3.3.5 → 3.3.6
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.
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
type File = {
|
|
3
|
+
buffer: Buffer;
|
|
4
|
+
mimetype: string;
|
|
4
5
|
};
|
|
6
|
+
type Part = string | File;
|
|
5
7
|
export declare function generateIaText(content: string | Part[]): Promise<string | undefined>;
|
|
6
8
|
export {};
|
|
@@ -8,11 +8,13 @@ async function generateIaText(content) {
|
|
|
8
8
|
const ai = new GoogleGenAI({ apiKey: (0, helpers_1.getEnvStr)('GEMINI_API_KEY') });
|
|
9
9
|
const contents = typeof content === 'string'
|
|
10
10
|
? content
|
|
11
|
-
: content.map((part) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
: await Promise.all(content.map(async (part) => {
|
|
12
|
+
if (typeof part === 'string')
|
|
13
|
+
return { text: part };
|
|
14
|
+
const blob = new Blob([new Uint8Array(part.buffer)], { type: part.mimetype });
|
|
15
|
+
const uploadedFile = await ai.files.upload({ file: blob });
|
|
16
|
+
return { fileData: { fileUri: uploadedFile.uri, mimeType: part.mimetype } };
|
|
17
|
+
}));
|
|
16
18
|
const response = await ai.models.generateContent({ model: 'gemini-2.5-flash-lite', contents });
|
|
17
19
|
return response.text;
|
|
18
20
|
}
|