@umituz/react-native-ai-gemini-provider 1.14.2 → 1.14.4
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/package.json
CHANGED
|
@@ -17,8 +17,14 @@ interface ImagenApiResponse {
|
|
|
17
17
|
generatedImages?: Array<{
|
|
18
18
|
image?: {
|
|
19
19
|
imageBytes?: string;
|
|
20
|
+
mimeType?: string;
|
|
20
21
|
};
|
|
21
22
|
}>;
|
|
23
|
+
error?: {
|
|
24
|
+
code?: number;
|
|
25
|
+
message?: string;
|
|
26
|
+
status?: string;
|
|
27
|
+
};
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
class GeminiImageGenerationService {
|
|
@@ -52,6 +58,7 @@ class GeminiImageGenerationService {
|
|
|
52
58
|
parameters: {
|
|
53
59
|
sampleCount: 1,
|
|
54
60
|
aspectRatio: "1:1",
|
|
61
|
+
personGeneration: "allow_adult",
|
|
55
62
|
},
|
|
56
63
|
};
|
|
57
64
|
|
|
@@ -60,6 +67,7 @@ class GeminiImageGenerationService {
|
|
|
60
67
|
console.log("[GeminiClient] Imagen API request", {
|
|
61
68
|
url,
|
|
62
69
|
prompt: prompt.substring(0, 100) + "...",
|
|
70
|
+
parameters: requestBody.parameters,
|
|
63
71
|
});
|
|
64
72
|
}
|
|
65
73
|
|
|
@@ -81,6 +89,22 @@ class GeminiImageGenerationService {
|
|
|
81
89
|
return res.json() as Promise<ImagenApiResponse>;
|
|
82
90
|
});
|
|
83
91
|
|
|
92
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
93
|
+
// eslint-disable-next-line no-console
|
|
94
|
+
console.log("[GeminiClient] Imagen API raw response", {
|
|
95
|
+
hasGeneratedImages: !!response.generatedImages,
|
|
96
|
+
generatedImagesCount: response.generatedImages?.length ?? 0,
|
|
97
|
+
hasError: !!response.error,
|
|
98
|
+
errorMessage: response.error?.message,
|
|
99
|
+
responseKeys: Object.keys(response),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Check for API error in response
|
|
104
|
+
if (response.error) {
|
|
105
|
+
throw new Error(`Imagen API error: ${response.error.message || response.error.status || "Unknown error"}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
84
108
|
const result: GeminiImageGenerationResult = {
|
|
85
109
|
text: undefined,
|
|
86
110
|
imageUrl: undefined,
|
|
@@ -91,10 +115,12 @@ class GeminiImageGenerationService {
|
|
|
91
115
|
if (response.generatedImages && response.generatedImages.length > 0) {
|
|
92
116
|
const generatedImage = response.generatedImages[0];
|
|
93
117
|
const imageBytes = generatedImage.image?.imageBytes;
|
|
118
|
+
const mimeType = generatedImage.image?.mimeType || "image/png";
|
|
94
119
|
|
|
95
120
|
if (imageBytes) {
|
|
96
121
|
result.imageBase64 = imageBytes;
|
|
97
|
-
result.imageUrl = `data
|
|
122
|
+
result.imageUrl = `data:${mimeType};base64,${imageBytes}`;
|
|
123
|
+
result.mimeType = mimeType;
|
|
98
124
|
}
|
|
99
125
|
}
|
|
100
126
|
|
|
@@ -103,6 +129,7 @@ class GeminiImageGenerationService {
|
|
|
103
129
|
console.log("[GeminiClient] generateImage() completed (Imagen)", {
|
|
104
130
|
hasImage: !!result.imageBase64,
|
|
105
131
|
imageDataLength: result.imageBase64?.length ?? 0,
|
|
132
|
+
mimeType: result.mimeType,
|
|
106
133
|
});
|
|
107
134
|
}
|
|
108
135
|
|
|
@@ -9,11 +9,7 @@ import { geminiClientCoreService } from "./gemini-client-core.service";
|
|
|
9
9
|
|
|
10
10
|
declare const __DEV__: boolean;
|
|
11
11
|
|
|
12
|
-
export
|
|
13
|
-
textModel?: string;
|
|
14
|
-
textToImageModel?: string;
|
|
15
|
-
imageEditModel?: string;
|
|
16
|
-
}
|
|
12
|
+
export type GeminiProviderConfig = AIProviderConfig;
|
|
17
13
|
|
|
18
14
|
export class ProviderInitializer {
|
|
19
15
|
initialize(config: GeminiProviderConfig): void {
|