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

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.34",
3
+ "version": "1.0.35",
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,8 +69,8 @@ async function buildImageEditInput(
69
69
  apiKey: string,
70
70
  sessionId: string,
71
71
  ): Promise<Record<string, unknown>> {
72
- // p-image-edit requires uploaded file URLs, not base64
73
- // First upload all images to Pruna storage, then use the URLs
72
+ // p-image-edit: Like video-studio, use raw base64 (not file upload)
73
+ // Get base64 image(s) from input
74
74
  let rawImages: string[];
75
75
 
76
76
  if (Array.isArray(input.images)) {
@@ -89,55 +89,34 @@ async function buildImageEditInput(
89
89
  throw new Error("Image is required for p-image-edit. Provide 'image', 'images', 'image_url', or 'image_urls'.");
90
90
  }
91
91
 
92
- generationLogCollector.log(sessionId, TAG, `p-image-edit: uploading ${rawImages.length} image(s) to Pruna storage...`);
93
-
94
- // Upload all images and get 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
- // __DEV__ log image details before upload
101
- if (typeof __DEV__ !== 'undefined' && __DEV__) {
102
- console.log(`[DEV] [${TAG}] Image ${i + 1}/${rawImages.length}:`, {
103
- sizeKB: Math.round(rawImage.length / 1024),
104
- isUrl: rawImage.startsWith('http'),
105
- hasDataUri: rawImage.startsWith('data:'),
106
- preview: rawImage.substring(0, 50) + '...',
107
- });
108
- }
109
-
110
- const url = await uploadFileToStorage(rawImage, apiKey, sessionId);
111
- imageUrls.push(url);
92
+ generationLogCollector.log(sessionId, TAG, `p-image-edit: processing ${rawImages.length} image(s)...`);
112
93
 
113
- // __DEV__ log successful upload
114
- if (typeof __DEV__ !== 'undefined' && __DEV__) {
115
- console.log(`[DEV] [${TAG}] Image ${i + 1}/${rawImages.length} uploaded successfully:`, {
116
- url,
117
- urlPrefix: url.substring(0, 50) + '...',
118
- });
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
119
98
  }
120
- }
99
+ // Strip data URI prefix to get raw base64
100
+ return img.includes('base64,') ? img.split('base64,')[1] : img;
101
+ });
121
102
 
122
- generationLogCollector.log(sessionId, TAG, `p-image-edit: image upload completed, using first image`);
103
+ // Use first image (like video-studio)
104
+ const payload: Record<string, unknown> = {
105
+ images: [strippedImages[0]], // Array with first image, raw base64
106
+ prompt,
107
+ aspect_ratio: aspectRatio,
108
+ };
123
109
 
124
110
  // __DEV__ log final payload
125
111
  if (typeof __DEV__ !== 'undefined' && __DEV__) {
126
112
  console.log(`[DEV] [${TAG}] Final p-image-edit payload:`, {
127
- imageCount: imageUrls.length,
113
+ imageCount: strippedImages.length,
128
114
  promptLength: prompt.length,
129
115
  aspectRatio,
130
- imageUrl: imageUrls[0].substring(0, 60) + '...',
116
+ base64Preview: strippedImages[0].substring(0, 50) + '...',
131
117
  });
132
118
  }
133
119
 
134
- // Pruna API expects singular 'image' (not 'images' array)
135
- const payload: Record<string, unknown> = {
136
- image: imageUrls[0], // Use first uploaded image
137
- prompt,
138
- aspect_ratio: aspectRatio,
139
- };
140
-
141
120
  if (input.seed !== undefined) payload.seed = input.seed;
142
121
  if (input.disable_safety_checker !== undefined) payload.disable_safety_checker = input.disable_safety_checker;
143
122
  if (input.width !== undefined) payload.width = input.width;