@umituz/react-native-ai-gemini-provider 1.14.3 → 1.14.5

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-gemini-provider",
3
- "version": "1.14.3",
3
+ "version": "1.14.5",
4
4
  "description": "Google Gemini AI provider for React Native applications",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -14,11 +14,15 @@ import type {
14
14
  declare const __DEV__: boolean;
15
15
 
16
16
  interface ImagenApiResponse {
17
- generatedImages?: Array<{
18
- image?: {
19
- imageBytes?: string;
20
- };
17
+ predictions?: Array<{
18
+ bytesBase64Encoded?: string;
19
+ mimeType?: string;
21
20
  }>;
21
+ error?: {
22
+ code?: number;
23
+ message?: string;
24
+ status?: string;
25
+ };
22
26
  }
23
27
 
24
28
  class GeminiImageGenerationService {
@@ -52,6 +56,7 @@ class GeminiImageGenerationService {
52
56
  parameters: {
53
57
  sampleCount: 1,
54
58
  aspectRatio: "1:1",
59
+ personGeneration: "allow_adult",
55
60
  },
56
61
  };
57
62
 
@@ -60,6 +65,7 @@ class GeminiImageGenerationService {
60
65
  console.log("[GeminiClient] Imagen API request", {
61
66
  url,
62
67
  prompt: prompt.substring(0, 100) + "...",
68
+ parameters: requestBody.parameters,
63
69
  });
64
70
  }
65
71
 
@@ -81,6 +87,21 @@ class GeminiImageGenerationService {
81
87
  return res.json() as Promise<ImagenApiResponse>;
82
88
  });
83
89
 
90
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
91
+ // eslint-disable-next-line no-console
92
+ console.log("[GeminiClient] Imagen API raw response", {
93
+ hasPredictions: !!response.predictions,
94
+ predictionsCount: response.predictions?.length ?? 0,
95
+ hasError: !!response.error,
96
+ errorMessage: response.error?.message,
97
+ responseKeys: Object.keys(response),
98
+ });
99
+ }
100
+
101
+ if (response.error) {
102
+ throw new Error(`Imagen API error: ${response.error.message || response.error.status || "Unknown error"}`);
103
+ }
104
+
84
105
  const result: GeminiImageGenerationResult = {
85
106
  text: undefined,
86
107
  imageUrl: undefined,
@@ -88,13 +109,15 @@ class GeminiImageGenerationService {
88
109
  mimeType: "image/png",
89
110
  };
90
111
 
91
- if (response.generatedImages && response.generatedImages.length > 0) {
92
- const generatedImage = response.generatedImages[0];
93
- const imageBytes = generatedImage.image?.imageBytes;
112
+ if (response.predictions && response.predictions.length > 0) {
113
+ const prediction = response.predictions[0];
114
+ const imageBytes = prediction.bytesBase64Encoded;
115
+ const mimeType = prediction.mimeType || "image/png";
94
116
 
95
117
  if (imageBytes) {
96
118
  result.imageBase64 = imageBytes;
97
- result.imageUrl = `data:image/png;base64,${imageBytes}`;
119
+ result.imageUrl = `data:${mimeType};base64,${imageBytes}`;
120
+ result.mimeType = mimeType;
98
121
  }
99
122
  }
100
123
 
@@ -103,6 +126,7 @@ class GeminiImageGenerationService {
103
126
  console.log("[GeminiClient] generateImage() completed (Imagen)", {
104
127
  hasImage: !!result.imageBase64,
105
128
  imageDataLength: result.imageBase64?.length ?? 0,
129
+ mimeType: result.mimeType,
106
130
  });
107
131
  }
108
132