@umituz/react-native-ai-pruna-provider 1.0.3 → 1.0.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-pruna-provider",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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",
|
|
@@ -79,12 +79,16 @@ export interface PrunaPredictionInput {
|
|
|
79
79
|
readonly aspect_ratio?: PrunaAspectRatio;
|
|
80
80
|
readonly image?: string;
|
|
81
81
|
readonly images?: readonly string[];
|
|
82
|
+
readonly reference_image?: string;
|
|
82
83
|
readonly duration?: number;
|
|
83
84
|
readonly resolution?: PrunaResolution;
|
|
84
85
|
readonly fps?: number;
|
|
85
86
|
readonly draft?: boolean;
|
|
86
87
|
readonly prompt_upsampling?: boolean;
|
|
87
88
|
readonly seed?: number;
|
|
89
|
+
readonly disable_safety_checker?: boolean;
|
|
90
|
+
readonly width?: number;
|
|
91
|
+
readonly height?: number;
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
/**
|
|
@@ -54,9 +54,10 @@ function buildImageInput(
|
|
|
54
54
|
): Record<string, unknown> {
|
|
55
55
|
const payload: Record<string, unknown> = { prompt, aspect_ratio: aspectRatio };
|
|
56
56
|
|
|
57
|
-
if (input.seed !== undefined)
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
if (input.seed !== undefined) payload.seed = input.seed;
|
|
58
|
+
if (input.disable_safety_checker !== undefined) payload.disable_safety_checker = input.disable_safety_checker;
|
|
59
|
+
if (input.width !== undefined) payload.width = input.width;
|
|
60
|
+
if (input.height !== undefined) payload.height = input.height;
|
|
60
61
|
|
|
61
62
|
return payload;
|
|
62
63
|
}
|
|
@@ -86,8 +87,14 @@ function buildImageEditInput(
|
|
|
86
87
|
|
|
87
88
|
const payload: Record<string, unknown> = { images, prompt, aspect_ratio: aspectRatio };
|
|
88
89
|
|
|
89
|
-
if (input.seed !== undefined)
|
|
90
|
-
|
|
90
|
+
if (input.seed !== undefined) payload.seed = input.seed;
|
|
91
|
+
if (input.disable_safety_checker !== undefined) payload.disable_safety_checker = input.disable_safety_checker;
|
|
92
|
+
if (input.width !== undefined) payload.width = input.width;
|
|
93
|
+
if (input.height !== undefined) payload.height = input.height;
|
|
94
|
+
|
|
95
|
+
// reference_image: designates the primary/main image in multi-image edits
|
|
96
|
+
if (typeof input.reference_image === 'string') {
|
|
97
|
+
payload.reference_image = stripBase64Prefix(input.reference_image);
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
return payload;
|
|
@@ -114,14 +121,21 @@ async function buildVideoInput(
|
|
|
114
121
|
const resolution = (input.resolution as PrunaResolution) ?? P_VIDEO_DEFAULTS.resolution;
|
|
115
122
|
const draft = (input.draft as boolean) ?? P_VIDEO_DEFAULTS.draft;
|
|
116
123
|
|
|
117
|
-
|
|
124
|
+
const fps = (input.fps as number) ?? P_VIDEO_DEFAULTS.fps;
|
|
125
|
+
const promptUpsampling = (input.prompt_upsampling as boolean) ?? P_VIDEO_DEFAULTS.promptUpsampling;
|
|
126
|
+
|
|
127
|
+
const payload: Record<string, unknown> = {
|
|
118
128
|
image: fileUrl,
|
|
119
129
|
prompt,
|
|
120
130
|
duration,
|
|
121
131
|
resolution,
|
|
122
|
-
fps
|
|
132
|
+
fps,
|
|
123
133
|
draft,
|
|
124
134
|
aspect_ratio: aspectRatio,
|
|
125
|
-
prompt_upsampling:
|
|
135
|
+
prompt_upsampling: promptUpsampling,
|
|
126
136
|
};
|
|
137
|
+
|
|
138
|
+
if (input.disable_safety_checker !== undefined) payload.disable_safety_checker = input.disable_safety_checker;
|
|
139
|
+
|
|
140
|
+
return payload;
|
|
127
141
|
}
|
|
@@ -12,9 +12,11 @@ import { prunaProvider } from '../infrastructure/services';
|
|
|
12
12
|
*/
|
|
13
13
|
export function initializePrunaProvider(config: {
|
|
14
14
|
apiKey: string | undefined;
|
|
15
|
+
/** When true (default), sets this provider as the active/default provider */
|
|
16
|
+
setAsActive?: boolean;
|
|
15
17
|
}): boolean {
|
|
16
18
|
try {
|
|
17
|
-
const { apiKey } = config;
|
|
19
|
+
const { apiKey, setAsActive = true } = config;
|
|
18
20
|
|
|
19
21
|
if (!apiKey) {
|
|
20
22
|
return false;
|
|
@@ -25,7 +27,9 @@ export function initializePrunaProvider(config: {
|
|
|
25
27
|
if (!providerRegistry.hasProvider(prunaProvider.providerId)) {
|
|
26
28
|
providerRegistry.register(prunaProvider);
|
|
27
29
|
}
|
|
28
|
-
|
|
30
|
+
if (setAsActive) {
|
|
31
|
+
providerRegistry.setActiveProvider(prunaProvider.providerId);
|
|
32
|
+
}
|
|
29
33
|
|
|
30
34
|
return true;
|
|
31
35
|
} catch (error) {
|