@umituz/react-native-ai-pruna-provider 1.0.35 → 1.0.37

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-pruna-provider",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "description": "Pruna AI provider for React Native - implements IAIProvider interface for unified AI generation",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -69,7 +69,7 @@ async function buildImageEditInput(
69
69
  apiKey: string,
70
70
  sessionId: string,
71
71
  ): Promise<Record<string, unknown>> {
72
- // p-image-edit: Like video-studio, use raw base64 (not file upload)
72
+ // p-image-edit: Upload images to file storage and use URLs (required by Pruna API)
73
73
  // Get base64 image(s) from input
74
74
  let rawImages: string[];
75
75
 
@@ -91,18 +91,22 @@ async function buildImageEditInput(
91
91
 
92
92
  generationLogCollector.log(sessionId, TAG, `p-image-edit: processing ${rawImages.length} image(s)...`);
93
93
 
94
- // Strip data URI prefixes (like video-studio does)
95
- const strippedImages = rawImages.map(img => {
96
- if (img.startsWith('http')) {
97
- return img; // Already a URL, pass through
98
- }
99
- // Strip data URI prefix to get raw base64
100
- return img.includes('base64,') ? img.split('base64,')[1] : img;
101
- });
94
+ // Upload images to Pruna file storage and collect URLs
95
+ const imageUrls: string[] = [];
96
+ for (let i = 0; i < rawImages.length; i++) {
97
+ const rawImage = rawImages[i];
98
+ generationLogCollector.log(sessionId, TAG, `p-image-edit: uploading image ${i + 1}/${rawImages.length}...`);
99
+
100
+ // Upload to file storage (if already a URL, it will be returned as-is)
101
+ const fileUrl = await uploadFileToStorage(rawImage, apiKey, sessionId);
102
+ imageUrls.push(fileUrl);
103
+
104
+ generationLogCollector.log(sessionId, TAG, `p-image-edit: image ${i + 1} uploaded → ${fileUrl}`);
105
+ }
102
106
 
103
- // Use first image (like video-studio)
107
+ // Build payload with image URLs (not raw base64)
104
108
  const payload: Record<string, unknown> = {
105
- images: [strippedImages[0]], // Array with first image, raw base64
109
+ images: imageUrls, // Array of HTTPS URLs from file upload
106
110
  prompt,
107
111
  aspect_ratio: aspectRatio,
108
112
  };
@@ -110,10 +114,10 @@ async function buildImageEditInput(
110
114
  // __DEV__ log final payload
111
115
  if (typeof __DEV__ !== 'undefined' && __DEV__) {
112
116
  console.log(`[DEV] [${TAG}] Final p-image-edit payload:`, {
113
- imageCount: strippedImages.length,
117
+ imageCount: imageUrls.length,
114
118
  promptLength: prompt.length,
115
119
  aspectRatio,
116
- base64Preview: strippedImages[0].substring(0, 50) + '...',
120
+ firstImageUrl: imageUrls[0]?.substring(0, 60) + '...',
117
121
  });
118
122
  }
119
123