@umituz/react-native-ai-generation-content 1.72.15 → 1.72.17

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-generation-content",
3
- "version": "1.72.15",
3
+ "version": "1.72.17",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -39,6 +39,7 @@
39
39
  "url": "git+https://github.com/umituz/react-native-ai-generation-content.git"
40
40
  },
41
41
  "dependencies": {
42
+ "@umituz/react-native-ai-generation-content": "file:../../../../../../../../../tmp/package.tgz",
42
43
  "@umituz/react-native-auth": "latest"
43
44
  },
44
45
  "peerDependencies": {
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Video Generation Executor
3
+ * Handles the actual video generation execution
4
+ * Uses direct provider calls for text-to-video and image-to-video generation models
5
+ */
6
+
7
+ import type { WizardVideoInput } from "./video-generation.types";
8
+ import { GENERATION_TIMEOUT_MS, BASE64_IMAGE_PREFIX } from "./wizard-strategy.constants";
9
+
10
+ declare const __DEV__: boolean;
11
+
12
+ interface ExecutionResult {
13
+ success: boolean;
14
+ videoUrl?: string;
15
+ requestId?: string;
16
+ error?: string;
17
+ }
18
+
19
+ interface SubmissionResult {
20
+ success: boolean;
21
+ requestId?: string;
22
+ model?: string;
23
+ error?: string;
24
+ }
25
+
26
+ function formatBase64(base64: string): string {
27
+ return base64.startsWith("data:") ? base64 : `${BASE64_IMAGE_PREFIX}${base64}`;
28
+ }
29
+
30
+ /**
31
+ * Execute video generation using direct provider call
32
+ * For text-to-video and image-to-video generation models (NOT features)
33
+ */
34
+ export async function executeVideoGeneration(
35
+ input: WizardVideoInput,
36
+ model: string,
37
+ onProgress?: (status: string) => void,
38
+ ): Promise<ExecutionResult> {
39
+ const { providerRegistry } = await import("../../../../../infrastructure/services/provider-registry.service");
40
+
41
+ const provider = providerRegistry.getActiveProvider();
42
+ if (!provider?.isInitialized()) {
43
+ return { success: false, error: "AI provider not initialized" };
44
+ }
45
+
46
+ try {
47
+ const sourceImage = formatBase64(input.sourceImageBase64);
48
+
49
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
50
+ console.log("[VideoExecutor] Generation starting", {
51
+ model,
52
+ duration: input.duration,
53
+ aspectRatio: input.aspectRatio,
54
+ resolution: input.resolution,
55
+ });
56
+ }
57
+
58
+ const modelInput: Record<string, unknown> = {
59
+ prompt: input.prompt,
60
+ };
61
+
62
+ // Add image for image-to-video (Sora 2, etc.)
63
+ if (sourceImage) {
64
+ modelInput.image_url = sourceImage;
65
+ }
66
+
67
+ // Add optional parameters
68
+ if (input.duration) {
69
+ modelInput.duration = input.duration;
70
+ }
71
+ if (input.aspectRatio) {
72
+ modelInput.aspect_ratio = input.aspectRatio;
73
+ }
74
+ if (input.resolution) {
75
+ modelInput.resolution = input.resolution;
76
+ }
77
+
78
+ let lastStatus = "";
79
+ const result = await provider.subscribe(model, modelInput, {
80
+ timeoutMs: GENERATION_TIMEOUT_MS,
81
+ onQueueUpdate: (status) => {
82
+ if (status.status !== lastStatus) {
83
+ lastStatus = status.status;
84
+ onProgress?.(status.status);
85
+ }
86
+ },
87
+ });
88
+
89
+ const rawResult = result as Record<string, unknown>;
90
+ const data = (rawResult?.data ?? rawResult) as { video?: { url: string }; video_url?: string };
91
+ const videoUrl = data?.video?.url ?? data?.video_url;
92
+
93
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
94
+ console.log("[VideoExecutor] Generation completed", { success: !!videoUrl });
95
+ }
96
+
97
+ return videoUrl
98
+ ? { success: true, videoUrl, requestId: (rawResult as { requestId?: string })?.requestId }
99
+ : { success: false, error: "No video generated" };
100
+ } catch (error) {
101
+ return { success: false, error: error instanceof Error ? error.message : "Generation failed" };
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Submit video generation to queue
107
+ * For background processing of video generation
108
+ */
109
+ export async function submitVideoGenerationToQueue(
110
+ input: WizardVideoInput,
111
+ model: string,
112
+ ): Promise<SubmissionResult> {
113
+ const { providerRegistry } = await import("../../../../../infrastructure/services/provider-registry.service");
114
+
115
+ const provider = providerRegistry.getActiveProvider();
116
+ if (!provider?.isInitialized()) {
117
+ return { success: false, error: "AI provider not initialized" };
118
+ }
119
+
120
+ try {
121
+ const sourceImage = formatBase64(input.sourceImageBase64);
122
+
123
+ const modelInput: Record<string, unknown> = {
124
+ prompt: input.prompt,
125
+ };
126
+
127
+ // Add image for image-to-video
128
+ if (sourceImage) {
129
+ modelInput.image_url = sourceImage;
130
+ }
131
+
132
+ // Add optional parameters
133
+ if (input.duration) {
134
+ modelInput.duration = input.duration;
135
+ }
136
+ if (input.aspectRatio) {
137
+ modelInput.aspect_ratio = input.aspectRatio;
138
+ }
139
+ if (input.resolution) {
140
+ modelInput.resolution = input.resolution;
141
+ }
142
+
143
+ const submission = await provider.submitJob(model, modelInput);
144
+
145
+ return { success: true, requestId: submission.requestId, model };
146
+ } catch (error) {
147
+ return { success: false, error: error instanceof Error ? error.message : "Queue submission failed" };
148
+ }
149
+ }
@@ -1,21 +1,17 @@
1
1
  /**
2
2
  * Video Generation Strategy
3
3
  * Handles video-specific generation logic (execution only)
4
- * Uses clean prompts for Sora 2 - no complex identity preservation text
4
+ * Uses direct provider calls for generation models (text-to-video, image-to-video)
5
5
  */
6
6
 
7
- import {
8
- executeVideoFeature,
9
- submitVideoFeatureToQueue,
10
- } from "../../../../../infrastructure/services/video-feature-executor.service";
11
7
  import type { WizardScenarioData } from "../../presentation/hooks/useWizardGeneration";
12
8
  import type { WizardStrategy } from "./wizard-strategy.types";
13
9
  import { VIDEO_PROCESSING_PROMPTS } from "./wizard-strategy.constants";
14
10
  import { extractPrompt, extractDuration, extractAspectRatio, extractResolution } from "../utils";
15
11
  import { extractPhotosAsBase64 } from "./shared/photo-extraction.utils";
16
- import { getVideoFeatureType } from "./video-generation.utils";
17
12
  import type { WizardVideoInput, CreateVideoStrategyOptions } from "./video-generation.types";
18
13
  import { validatePhotoCount, validateWizardVideoInput } from "./video-generation.types";
14
+ import { executeVideoGeneration, submitVideoGenerationToQueue } from "./video-generation.executor";
19
15
 
20
16
  declare const __DEV__: boolean;
21
17
 
@@ -51,10 +47,10 @@ export async function buildVideoInput(
51
47
  }
52
48
  }
53
49
 
54
- // For video generation with Sora 2, use clean prompt directly
55
- // No need for complex identity preservation text - Sora 2 handles this natively
50
+ // For video generation, use clean prompt directly
51
+ // Modern models handle context natively
56
52
  if (typeof __DEV__ !== "undefined" && __DEV__) {
57
- console.log("[VideoStrategy] Using clean prompt for Sora 2", {
53
+ console.log("[VideoStrategy] Using clean prompt for video generation", {
58
54
  promptLength: finalPrompt.length,
59
55
  photoCount: photos.length,
60
56
  });
@@ -72,23 +68,20 @@ export async function buildVideoInput(
72
68
 
73
69
  export function createVideoStrategy(options: CreateVideoStrategyOptions): WizardStrategy {
74
70
  const { scenario, creditCost } = options;
75
- const videoFeatureType = getVideoFeatureType(scenario);
71
+
72
+ // Validate model early - fail fast
73
+ if (!scenario.model) {
74
+ throw new Error("Model is required for video generation");
75
+ }
76
+
77
+ const model = scenario.model;
76
78
 
77
79
  return {
78
80
  execute: async (input: unknown) => {
79
81
  // Runtime validation with descriptive errors
80
82
  const videoInput = validateWizardVideoInput(input);
81
83
 
82
- const result = await executeVideoFeature(videoFeatureType, {
83
- sourceImageBase64: videoInput.sourceImageBase64,
84
- targetImageBase64: videoInput.targetImageBase64,
85
- prompt: videoInput.prompt,
86
- options: {
87
- duration: videoInput.duration,
88
- aspect_ratio: videoInput.aspectRatio,
89
- resolution: videoInput.resolution,
90
- },
91
- });
84
+ const result = await executeVideoGeneration(videoInput, model);
92
85
 
93
86
  if (!result.success || !result.videoUrl) {
94
87
  throw new Error(result.error || "Video generation failed");
@@ -101,16 +94,7 @@ export function createVideoStrategy(options: CreateVideoStrategyOptions): Wizard
101
94
  // Runtime validation with descriptive errors
102
95
  const videoInput = validateWizardVideoInput(input);
103
96
 
104
- const result = await submitVideoFeatureToQueue(videoFeatureType, {
105
- sourceImageBase64: videoInput.sourceImageBase64,
106
- targetImageBase64: videoInput.targetImageBase64,
107
- prompt: videoInput.prompt,
108
- options: {
109
- duration: videoInput.duration,
110
- aspect_ratio: videoInput.aspectRatio,
111
- resolution: videoInput.resolution,
112
- },
113
- });
97
+ const result = await submitVideoGenerationToQueue(videoInput, model);
114
98
 
115
99
  return {
116
100
  success: result.success,