@umituz/react-native-ai-generation-content 1.90.2 → 1.90.3
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 +1 -1
- package/src/domain/interfaces/app-services-auth.interface.ts +27 -0
- package/src/domain/interfaces/app-services-composite.interface.ts +29 -0
- package/src/domain/interfaces/app-services-optional.interface.ts +42 -0
- package/src/domain/interfaces/app-services.interface.ts +0 -79
- package/src/domains/background/infrastructure/services/job-poller-index.ts +7 -0
- package/src/domains/background/infrastructure/services/job-poller-utils.ts +130 -0
- package/src/domains/background/infrastructure/utils/polling-interval.util.ts +1 -1
- package/src/domains/background/presentation/hooks/use-background-generation.ts +1 -1
- package/src/domains/content-moderation/infrastructure/services/content-moderation.service.ts +1 -1
- package/src/domains/content-moderation/infrastructure/services/moderators/image.moderator.ts +34 -8
- package/src/domains/content-moderation/infrastructure/services/moderators/text.moderator.ts +15 -4
- package/src/domains/content-moderation/infrastructure/services/moderators/video.moderator.ts +34 -8
- package/src/domains/content-moderation/infrastructure/services/moderators/voice.moderator.ts +19 -8
- package/src/domains/creations/domain/types/creation-categories.constants.ts +57 -0
- package/src/domains/creations/domain/types/creation-categories.helpers.ts +67 -0
- package/src/domains/creations/domain/types/creation-categories.ts +5 -111
- package/src/domains/creations/presentation/hooks/creation-validators.ts +31 -29
- package/src/domains/creations/presentation/hooks/job-poller-index.ts +10 -0
- package/src/domains/creations/presentation/hooks/job-poller-utils.filters.ts +34 -0
- package/src/domains/creations/presentation/hooks/job-poller-utils.logger.ts +76 -0
- package/src/domains/creations/presentation/hooks/job-poller-utils.stale-handlers.ts +52 -0
- package/src/domains/creations/presentation/hooks/job-poller-utils.ts +8 -0
- package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +1 -1
- package/src/domains/creations/presentation-exports.ts +2 -2
- package/src/domains/face-detection/domain/entities/FaceDetection.ts +4 -3
- package/src/domains/face-detection/presentation/hooks/useFaceDetection.ts +24 -21
- package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple-preparation.ts +58 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple-prompt.ts +69 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple-resolution.ts +77 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple.ts +54 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/builder-index.ts +8 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/builder-scenario.ts +113 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/builder.ts +7 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/index.ts +20 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/types.ts +44 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/utils/builder-end-logger.ts +18 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/utils/builder-start-logger.ts +57 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/utils/builder-step-logger.ts +106 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/utils/index.ts +8 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/utils/types.ts +49 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/utils.ts +8 -0
- package/src/domains/generation/infrastructure/flow/flow-store-actions.ts +105 -0
- package/src/domains/generation/infrastructure/flow/flow-store-initial-state.ts +26 -0
- package/src/domains/generation/infrastructure/flow/useFlowStore.ts +4 -116
- package/src/domains/generation/presentation/useAIGeneration.hook.ts +1 -1
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation-strategy-index.ts +7 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.ts +2 -12
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.types.ts +11 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.utils.ts +12 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.strategy.ts +1 -220
- package/src/domains/generation/wizard/infrastructure/strategies/image-input-builder.ts +66 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-input-extraction.ts +88 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-input-prompt-builder.ts +75 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-input-style-enhancements.ts +35 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-strategy-factory.ts +42 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation-executor-index.ts +11 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation-executor.ts +76 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation-input-builder.ts +46 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation-result-types.ts +17 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation-submission.ts +62 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.audio-extractor.ts +27 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.executor.ts +2 -175
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.input-builder.ts +90 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts +3 -108
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.types.ts +0 -129
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.validation.ts +136 -0
- package/src/domains/generation/wizard/presentation/hooks/photo-upload/index.ts +39 -0
- package/src/domains/generation/wizard/presentation/hooks/photo-upload/types.ts +37 -0
- package/src/domains/generation/wizard/presentation/hooks/photo-upload/usePhotoUploadStateLogic.ts +142 -0
- package/src/domains/generation/wizard/presentation/hooks/use-video-queue-utils.ts +103 -0
- package/src/domains/generation/wizard/presentation/hooks/usePhotoBlockingGeneration.handlers.ts +97 -0
- package/src/domains/generation/wizard/presentation/hooks/usePhotoBlockingGeneration.saver.ts +54 -0
- package/src/domains/generation/wizard/presentation/hooks/usePhotoBlockingGeneration.ts +22 -87
- package/src/domains/generation/wizard/presentation/hooks/usePhotoUploadState.ts +8 -177
- package/src/domains/generation/wizard/presentation/hooks/useVideoQueueGeneration.ts +1 -295
- package/src/domains/generation/wizard/presentation/hooks/useWizardGeneration.ts +1 -1
- package/src/domains/generation/wizard/presentation/hooks/video-queue/index.ts +82 -0
- package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationCallbacks.ts +120 -0
- package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationPolling.ts +76 -0
- package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationRefs.ts +65 -0
- package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationStart.ts +123 -0
- package/src/domains/generation/wizard/presentation/hooks/video-queue-index.ts +9 -0
- package/src/domains/image-to-video/domain/types/image-to-video-state.types.ts +11 -4
- package/src/domains/text-to-image/domain/types/text-to-image.types.ts +44 -22
- package/src/domains/text-to-video/domain/types/request.types.ts +33 -9
- package/src/domains/text-to-video/domain/types/state.types.ts +29 -9
- package/src/domains/text-to-video/presentation/hooks/useTextToVideoForm.handlers.ts +44 -0
- package/src/domains/text-to-video/presentation/hooks/useTextToVideoForm.ts +5 -51
- package/src/domains/text-to-video/presentation/hooks/useTextToVideoForm.types.ts +33 -0
- package/src/infrastructure/services/generation-orchestrator.service.ts +2 -2
- package/src/infrastructure/utils/couple-input-context.ts +13 -0
- package/src/infrastructure/utils/couple-input-index.ts +8 -0
- package/src/infrastructure/utils/couple-input-refiner.ts +101 -0
- package/src/infrastructure/utils/couple-input-resolver.ts +71 -0
- package/src/infrastructure/utils/couple-input-types.ts +14 -0
- package/src/infrastructure/utils/couple-input.util.ts +3 -176
- package/src/infrastructure/utils/photo-generation/photo-preparation.util.ts +1 -1
- package/src/infrastructure/validation/base-validator.ts +1 -27
- package/src/infrastructure/validation/base-validator.types.ts +32 -0
- package/src/presentation/hooks/generation/index.ts +1 -1
- package/src/presentation/hooks/generation/orchestrator-abort-logs.ts +48 -0
- package/src/presentation/hooks/generation/orchestrator-execution-logs.ts +67 -0
- package/src/presentation/hooks/generation/orchestrator-index.ts +14 -0
- package/src/presentation/hooks/generation/orchestrator-start-logs.ts +65 -0
- package/src/presentation/hooks/generation/orchestrator-state-utils.ts +17 -0
- package/src/presentation/hooks/generation/orchestrator-types.ts +55 -0
- package/src/presentation/hooks/generation/orchestrator-utils-index.ts +29 -0
- package/src/presentation/hooks/generation/orchestrator-utils.ts +25 -0
- package/src/presentation/hooks/generation/useDualImageGeneration.ts +1 -1
- package/src/presentation/hooks/generation/useImageGeneration.ts +1 -1
- package/src/presentation/hooks/generation/useVideoGeneration.ts +1 -1
- package/src/shared/hooks/factories/generation-hook-index.ts +12 -0
- package/src/shared/hooks/factories/generation-hook-types.ts +47 -0
- package/src/shared/hooks/factories/generation-hook-utils.ts +94 -0
- package/src/shared/hooks/factories/index.ts +1 -1
- package/src/shared/index.ts +1 -1
- package/src/shared/utils/calculations/aspect-ratio-calculations.ts +30 -0
- package/src/shared/utils/calculations/base64-calculations.ts +26 -0
- package/src/shared/utils/calculations/confidence-calculations.ts +21 -0
- package/src/shared/utils/calculations/cost-calculations-index.ts +43 -0
- package/src/shared/utils/calculations/cost-calculations.ts +25 -0
- package/src/shared/utils/calculations/credit-calculations.ts +37 -0
- package/src/shared/utils/calculations/index.ts +46 -0
- package/src/shared/utils/calculations/math-utilities.ts +32 -0
- package/src/shared/utils/calculations/memory-calculations.ts +33 -0
- package/src/shared/utils/calculations/pagination-calculations.ts +38 -0
- package/src/shared/utils/calculations/percentage-calculations.ts +33 -0
- package/src/shared/utils/calculations/time-calculations.ts +99 -0
- package/src/shared/utils/credit.ts +1 -1
- package/src/shared-kernel/application/hooks/index.ts +8 -0
- package/src/shared-kernel/application/hooks/use-feature-state.ts +107 -0
- package/src/shared-kernel/application/hooks/use-generation-handler.ts +110 -0
- package/src/shared-kernel/base-types/base-callbacks.types.ts +73 -0
- package/src/shared-kernel/base-types/base-feature-state.types.ts +77 -0
- package/src/shared-kernel/base-types/base-generation.types.ts +69 -0
- package/src/shared-kernel/base-types/index.ts +30 -0
- package/src/shared-kernel/domain/base-generation-strategy.ts +146 -0
- package/src/shared-kernel/domain/index.ts +7 -0
- package/src/shared-kernel/index.ts +17 -0
- package/src/shared-kernel/infrastructure/validation/common-validators.ts +126 -0
- package/src/shared-kernel/infrastructure/validation/common-validators.types.ts +33 -0
- package/src/shared-kernel/infrastructure/validation/error-handler.ts +52 -0
- package/src/shared-kernel/infrastructure/validation/error-handler.types.ts +38 -0
- package/src/shared-kernel/infrastructure/validation/error-handler.utils.ts +79 -0
- package/src/shared-kernel/infrastructure/validation/index.ts +28 -0
- package/src/domains/background/infrastructure/services/job-poller.service.ts +0 -234
- package/src/domains/creations/presentation/hooks/useProcessingJobsPoller.ts +0 -256
- package/src/domains/generation/infrastructure/couple-generation-builder.ts +0 -374
- package/src/presentation/hooks/generation/orchestrator.ts +0 -276
- package/src/shared/hooks/factories/createGenerationHook.ts +0 -253
- package/src/shared/utils/calculations.util.ts +0 -366
package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple-prompt.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Couple Image Generation Builder - Prompt Processing
|
|
3
|
+
*
|
|
4
|
+
* Handles prompt refinement and final prompt creation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
prependContext,
|
|
9
|
+
refinePromptForCouple,
|
|
10
|
+
} from "../../../infrastructure/utils/couple-input.util";
|
|
11
|
+
import { createPhotorealisticPrompt } from "../../prompts";
|
|
12
|
+
import { logBuilderStep } from "./utils";
|
|
13
|
+
import type { CoupleGenerationInputParams } from "./types";
|
|
14
|
+
|
|
15
|
+
export interface CouplePromptResult {
|
|
16
|
+
prompt: string;
|
|
17
|
+
refinedPrompt: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Process and refine prompt for couple generation
|
|
22
|
+
*/
|
|
23
|
+
export function processCouplePrompt(
|
|
24
|
+
params: CoupleGenerationInputParams,
|
|
25
|
+
appearanceContext: string,
|
|
26
|
+
prefix: string = "[CoupleBuilder]",
|
|
27
|
+
): CouplePromptResult {
|
|
28
|
+
const {
|
|
29
|
+
basePrompt,
|
|
30
|
+
customInstructions,
|
|
31
|
+
isCoupleMode,
|
|
32
|
+
} = params;
|
|
33
|
+
|
|
34
|
+
// 3. REFINE FOR COUPLE + PREPEND CONTEXT - Wardrobe mantığı
|
|
35
|
+
logBuilderStep(prefix, "STEP 3: REFINE & PREPEND CONTEXT", {
|
|
36
|
+
basePromptLength: basePrompt.length,
|
|
37
|
+
isCoupleMode
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const refinedPrompt = prependContext(
|
|
41
|
+
refinePromptForCouple(basePrompt, isCoupleMode),
|
|
42
|
+
appearanceContext,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
logBuilderStep(prefix, "Refined Prompt Result", {
|
|
46
|
+
refinedPromptLength: refinedPrompt.length,
|
|
47
|
+
refinedPromptPreview: refinedPrompt.substring(0, 300),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// 4. CREATE FINAL PROMPT - Photorealistic
|
|
51
|
+
logBuilderStep(prefix, "STEP 4: CREATE PHOTOREALISTIC PROMPT", {
|
|
52
|
+
isCouple: isCoupleMode,
|
|
53
|
+
hasCustomInstructions: !!customInstructions
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const prompt = createPhotorealisticPrompt(refinedPrompt, {
|
|
57
|
+
isCouple: isCoupleMode,
|
|
58
|
+
customInstructions,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
logBuilderStep(prefix, "Final Prompt Result", {
|
|
62
|
+
promptLength: prompt.length,
|
|
63
|
+
promptPreview: prompt.substring(0, 500),
|
|
64
|
+
hasCustomInstructions: !!customInstructions,
|
|
65
|
+
customInstructions,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return { prompt, refinedPrompt };
|
|
69
|
+
}
|
package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple-resolution.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Couple Image Generation Builder - Input Resolution
|
|
3
|
+
*
|
|
4
|
+
* Handles target resolution and final input building
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
resolveCoupleInput,
|
|
9
|
+
} from "../../../infrastructure/utils/couple-input.util";
|
|
10
|
+
import { logBuilderStep, logBuilderEnd, logBuilderStart } from "./utils";
|
|
11
|
+
import type {
|
|
12
|
+
CoupleGenerationInputParams,
|
|
13
|
+
CoupleGenerationInput,
|
|
14
|
+
} from "./types";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Build final couple generation input with resolved target and parameters
|
|
18
|
+
*/
|
|
19
|
+
export function buildCoupleGenerationResult(
|
|
20
|
+
params: CoupleGenerationInputParams,
|
|
21
|
+
prompt: string,
|
|
22
|
+
prefix: string = "[CoupleBuilder]",
|
|
23
|
+
): CoupleGenerationInput {
|
|
24
|
+
const {
|
|
25
|
+
partner1PhotoUri,
|
|
26
|
+
partner2PhotoUri,
|
|
27
|
+
isCoupleMode,
|
|
28
|
+
aspectRatio = "3:4",
|
|
29
|
+
strength,
|
|
30
|
+
} = params;
|
|
31
|
+
|
|
32
|
+
// 5. RESOLVE COUPLE INPUT - Doğru target ve image'lar
|
|
33
|
+
logBuilderStep(prefix, "STEP 5: RESOLVE COUPLE INPUT", {
|
|
34
|
+
partner1Uri: partner1PhotoUri,
|
|
35
|
+
partner2Uri: partner2PhotoUri,
|
|
36
|
+
isCoupleMode,
|
|
37
|
+
singleTarget: "p-image-edit/pruna",
|
|
38
|
+
coupleTarget: "p-image-edit/pruna"
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const { target, imageUrls } = resolveCoupleInput(
|
|
42
|
+
partner1PhotoUri,
|
|
43
|
+
partner2PhotoUri,
|
|
44
|
+
isCoupleMode,
|
|
45
|
+
{ model: "p-image-edit", providerId: "pruna" }, // Single target
|
|
46
|
+
{ model: "p-image-edit", providerId: "pruna" }, // Couple target
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
logBuilderStep(prefix, "Target Resolution Result", {
|
|
50
|
+
targetModel: target.model,
|
|
51
|
+
targetProvider: target.providerId,
|
|
52
|
+
imageUrlsCount: imageUrls.length,
|
|
53
|
+
image1: imageUrls[0],
|
|
54
|
+
image2: imageUrls[1],
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// 6. BUILD PARAMS - Wardrobe formatında
|
|
58
|
+
logBuilderStep(prefix, "STEP 6: BUILD PARAMS", {
|
|
59
|
+
prompt,
|
|
60
|
+
imageUrls,
|
|
61
|
+
aspectRatio,
|
|
62
|
+
strength,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
logBuilderEnd(prefix);
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
target,
|
|
69
|
+
prompt,
|
|
70
|
+
params: {
|
|
71
|
+
prompt,
|
|
72
|
+
image_urls: imageUrls,
|
|
73
|
+
aspect_ratio: aspectRatio,
|
|
74
|
+
...(strength !== undefined && { strength }),
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Couple Image Generation Builder - Couple Generation
|
|
3
|
+
*
|
|
4
|
+
* Merkezi couple generation input builder
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
CoupleGenerationInputParams,
|
|
9
|
+
CoupleGenerationInput,
|
|
10
|
+
} from "./types";
|
|
11
|
+
import { logBuilderStart } from "./utils";
|
|
12
|
+
import { prepareCoupleGeneration } from "./builder-couple-preparation";
|
|
13
|
+
import { processCouplePrompt } from "./builder-couple-prompt";
|
|
14
|
+
import { buildCoupleGenerationResult } from "./builder-couple-resolution";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Merkezi couple generation input builder
|
|
18
|
+
*
|
|
19
|
+
* Wardrobe mantığını tüm couple generation için paylaştırır:
|
|
20
|
+
* 1. Appearance analysis (fotoğrafları analiz et)
|
|
21
|
+
* 2. Couple refinement (çift modu için iyileştir)
|
|
22
|
+
* 3. Context prepending (context'i prompt'a ekle)
|
|
23
|
+
* 4. Photorealistic prompt creation
|
|
24
|
+
* 5. Couple input resolution (doğru target ve image'lar)
|
|
25
|
+
*
|
|
26
|
+
* @param params - Generation parameters
|
|
27
|
+
* @returns Generation input with target, prompt, and params
|
|
28
|
+
*/
|
|
29
|
+
export async function buildCoupleGenerationInput(
|
|
30
|
+
params: CoupleGenerationInputParams,
|
|
31
|
+
): Promise<CoupleGenerationInput> {
|
|
32
|
+
const prefix = "[CoupleBuilder]";
|
|
33
|
+
|
|
34
|
+
logBuilderStart(prefix, {
|
|
35
|
+
isCoupleMode: params.isCoupleMode,
|
|
36
|
+
basePromptLength: params.basePrompt.length,
|
|
37
|
+
aspectRatio: params.aspectRatio,
|
|
38
|
+
hasPartner2: !!params.partner2PhotoUri,
|
|
39
|
+
hasCustomInstructions: !!params.customInstructions,
|
|
40
|
+
hasStrength: params.strength !== undefined,
|
|
41
|
+
strength: params.strength,
|
|
42
|
+
partner1Uri: params.partner1PhotoUri,
|
|
43
|
+
partner2Uri: params.partner2PhotoUri,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Phase 1: Prepare photo URIs and analyze appearance
|
|
47
|
+
const { photoUris, appearanceContext } = await prepareCoupleGeneration(params, prefix);
|
|
48
|
+
|
|
49
|
+
// Phase 2: Process and refine prompt
|
|
50
|
+
const { prompt } = processCouplePrompt(params, appearanceContext, prefix);
|
|
51
|
+
|
|
52
|
+
// Phase 3: Build final result with resolved target
|
|
53
|
+
return buildCoupleGenerationResult(params, prompt, prefix);
|
|
54
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Couple Image Generation Builder - Scenario Generation
|
|
3
|
+
*
|
|
4
|
+
* Scenario generation için özel wrapper
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
resolveCoupleInput,
|
|
9
|
+
refinePromptForCouple,
|
|
10
|
+
prependContext,
|
|
11
|
+
} from "../../../infrastructure/utils/couple-input.util";
|
|
12
|
+
import { getAppearanceContext } from "./appearance-analysis";
|
|
13
|
+
import type {
|
|
14
|
+
ScenarioGenerationInputParams,
|
|
15
|
+
CoupleGenerationInput,
|
|
16
|
+
} from "./types";
|
|
17
|
+
import { logBuilderStart, logBuilderStep, logBuilderEnd } from "./utils";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Scenario generation için özel wrapper
|
|
21
|
+
*
|
|
22
|
+
* Senaryo aiPrompt'larını (zaten createPhotorealisticPrompt ile oluşturulmuş)
|
|
23
|
+
* Wardrobe mantığı ile birleştirir.
|
|
24
|
+
*/
|
|
25
|
+
export async function buildScenarioGenerationInput(
|
|
26
|
+
params: ScenarioGenerationInputParams,
|
|
27
|
+
): Promise<CoupleGenerationInput> {
|
|
28
|
+
const DEV = typeof __DEV__ !== "undefined" && __DEV__;
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
partner1PhotoUri,
|
|
32
|
+
partner2PhotoUri,
|
|
33
|
+
isCoupleMode,
|
|
34
|
+
scenarioPrompt,
|
|
35
|
+
} = params;
|
|
36
|
+
|
|
37
|
+
logBuilderStart("[ScenarioBuilder]", {
|
|
38
|
+
isCoupleMode,
|
|
39
|
+
scenarioPromptLength: scenarioPrompt.length,
|
|
40
|
+
scenarioPromptPreview: scenarioPrompt.substring(0, 200),
|
|
41
|
+
partner1Uri: partner1PhotoUri,
|
|
42
|
+
partner2Uri: partner2PhotoUri,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// 1. GET PHOTO URIs
|
|
46
|
+
const photoUris =
|
|
47
|
+
isCoupleMode && partner2PhotoUri
|
|
48
|
+
? [partner1PhotoUri, partner2PhotoUri]
|
|
49
|
+
: [partner1PhotoUri];
|
|
50
|
+
|
|
51
|
+
logBuilderStep("[ScenarioBuilder]", "STEP 1: PHOTO URIs", {
|
|
52
|
+
photoUrisCount: photoUris.length,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// 2. ANALYZE APPEARANCE
|
|
56
|
+
logBuilderStep("[ScenarioBuilder]", "STEP 2: APPEARANCE ANALYSIS");
|
|
57
|
+
|
|
58
|
+
const appearanceContext = await getAppearanceContext(
|
|
59
|
+
photoUris,
|
|
60
|
+
isCoupleMode,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
logBuilderStep("[ScenarioBuilder]", "Appearance Analysis Result", {
|
|
64
|
+
contextLength: appearanceContext.length,
|
|
65
|
+
contextPreview: appearanceContext.length > 0 ? appearanceContext.substring(0, 150) : "No context (vision disabled)",
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// 3. REFINE FOR COUPLE + PREPEND CONTEXT
|
|
69
|
+
logBuilderStep("[ScenarioBuilder]", "STEP 3: REFINE & PREPEND CONTEXT");
|
|
70
|
+
|
|
71
|
+
const refinedPrompt = refinePromptForCouple(scenarioPrompt, isCoupleMode);
|
|
72
|
+
const finalPrompt = prependContext(refinedPrompt, appearanceContext);
|
|
73
|
+
|
|
74
|
+
logBuilderStep("[ScenarioBuilder]", "Refined Prompt Result", {
|
|
75
|
+
refinedPromptLength: refinedPrompt.length,
|
|
76
|
+
finalPromptLength: finalPrompt.length,
|
|
77
|
+
finalPromptPreview: finalPrompt.substring(0, 300),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// 4. RESOLVE COUPLE INPUT
|
|
81
|
+
logBuilderStep("[ScenarioBuilder]", "STEP 4: RESOLVE COUPLE INPUT");
|
|
82
|
+
|
|
83
|
+
const { target, imageUrls } = resolveCoupleInput(
|
|
84
|
+
partner1PhotoUri,
|
|
85
|
+
partner2PhotoUri,
|
|
86
|
+
isCoupleMode,
|
|
87
|
+
{ model: "p-image-edit", providerId: "pruna" }, // Single target
|
|
88
|
+
{ model: "p-image-edit", providerId: "pruna" }, // Couple target
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
logBuilderStep("[ScenarioBuilder]", "Target Resolution Result", {
|
|
92
|
+
targetModel: target.model,
|
|
93
|
+
targetProvider: target.providerId,
|
|
94
|
+
imageUrlsCount: imageUrls.length,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// 5. BUILD PARAMS - Scenario formatında
|
|
98
|
+
logBuilderStep("[ScenarioBuilder]", "STEP 5: BUILD PARAMS", {
|
|
99
|
+
aspectRatio: "3:4"
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
logBuilderEnd("[ScenarioBuilder]");
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
target,
|
|
106
|
+
prompt: finalPrompt,
|
|
107
|
+
params: {
|
|
108
|
+
prompt: finalPrompt,
|
|
109
|
+
image_urls: imageUrls,
|
|
110
|
+
aspect_ratio: "3:4",
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Couple Image Generation Builder
|
|
3
|
+
*
|
|
4
|
+
* Wardrobe'da kusursuz çalışan mantığı tüm couple generation için paylaştırır.
|
|
5
|
+
* Bu utility'yi tüm çift görüntü oluşturma işlemleri kullanır.
|
|
6
|
+
*
|
|
7
|
+
* Kullanım alanları:
|
|
8
|
+
* - Senaryo generation (Home couple images)
|
|
9
|
+
* - Wardrobe generation
|
|
10
|
+
* - Background generation
|
|
11
|
+
* - Art style generation
|
|
12
|
+
* - Mood filter generation
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export type {
|
|
16
|
+
CoupleGenerationInputParams,
|
|
17
|
+
CoupleGenerationInput,
|
|
18
|
+
ScenarioGenerationInputParams,
|
|
19
|
+
} from "./types";
|
|
20
|
+
export { buildCoupleGenerationInput, buildScenarioGenerationInput } from "./builder";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Couple Image Generation Builder - Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Wardrobe'da kusursuz çalışan mantığı tüm couple generation için paylaştırır.
|
|
5
|
+
* Bu utility'yi tüm çift görüntü oluşturma işlemleri kullanır.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { GenerationTargetLike } from "../../../infrastructure/utils/couple-input.util";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Couple generation input parameters
|
|
12
|
+
*/
|
|
13
|
+
export interface CoupleGenerationInputParams {
|
|
14
|
+
// Required params
|
|
15
|
+
partner1PhotoUri: string;
|
|
16
|
+
partner2PhotoUri: string | null;
|
|
17
|
+
isCoupleMode: boolean;
|
|
18
|
+
basePrompt: string; // Scenario prompt, wardrobe prompt, background prompt, etc.
|
|
19
|
+
|
|
20
|
+
// Optional params
|
|
21
|
+
customInstructions?: string;
|
|
22
|
+
aspectRatio?: string; // Default: "3:4"
|
|
23
|
+
strength?: number; // Optional strength for some operations
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Couple generation result
|
|
28
|
+
*/
|
|
29
|
+
export interface CoupleGenerationInput {
|
|
30
|
+
target: GenerationTargetLike;
|
|
31
|
+
prompt: string;
|
|
32
|
+
params: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Scenario generation input parameters
|
|
37
|
+
*/
|
|
38
|
+
export interface ScenarioGenerationInputParams {
|
|
39
|
+
partner1PhotoUri: string;
|
|
40
|
+
partner2PhotoUri: string | null;
|
|
41
|
+
isCoupleMode: boolean;
|
|
42
|
+
scenarioPrompt: string; // Senaryo prompt'u (aiPrompt)
|
|
43
|
+
customInstructions?: string;
|
|
44
|
+
}
|
package/src/domains/generation/infrastructure/couple-generation-builder/utils/builder-end-logger.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Couple Image Generation Builder - End Logger
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const DEV = typeof __DEV__ !== "undefined" && __DEV__;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Log builder end
|
|
9
|
+
*/
|
|
10
|
+
export function logBuilderEnd(prefix: string): void {
|
|
11
|
+
if (!DEV) return;
|
|
12
|
+
|
|
13
|
+
console.log(`${prefix} ========================================`);
|
|
14
|
+
console.log(`${prefix} ===== BUILD COUPLE GENERATION END =====`);
|
|
15
|
+
console.log(`${prefix} ========================================`);
|
|
16
|
+
console.log(`${prefix} Returning: { target, prompt, params }`);
|
|
17
|
+
console.log("");
|
|
18
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Couple Image Generation Builder - Start Logger
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { BuilderStartParams } from "./types";
|
|
6
|
+
|
|
7
|
+
const DEV = typeof __DEV__ !== "undefined" && __DEV__;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Log builder start with parameters
|
|
11
|
+
*/
|
|
12
|
+
export function logBuilderStart(
|
|
13
|
+
prefix: string,
|
|
14
|
+
params: BuilderStartParams
|
|
15
|
+
): void {
|
|
16
|
+
if (!DEV) return;
|
|
17
|
+
|
|
18
|
+
console.log(`${prefix} ========================================`);
|
|
19
|
+
console.log(`${prefix} ===== BUILD COUPLE GENERATION START =====`);
|
|
20
|
+
console.log(`${prefix} ========================================`);
|
|
21
|
+
console.log(`${prefix} ===== INPUT PARAMS =====`);
|
|
22
|
+
|
|
23
|
+
if (params.isCoupleMode !== undefined) {
|
|
24
|
+
console.log(`${prefix} Is couple mode:`, params.isCoupleMode);
|
|
25
|
+
}
|
|
26
|
+
if (params.basePromptLength !== undefined) {
|
|
27
|
+
console.log(`${prefix} Base prompt length:`, params.basePromptLength);
|
|
28
|
+
console.log(`${prefix} Base prompt preview:`, params.basePromptLength.toString().substring(0, 200) + "...");
|
|
29
|
+
}
|
|
30
|
+
if (params.scenarioPromptLength !== undefined) {
|
|
31
|
+
console.log(`${prefix} Scenario prompt length:`, params.scenarioPromptLength);
|
|
32
|
+
}
|
|
33
|
+
if (params.scenarioPromptPreview !== undefined) {
|
|
34
|
+
console.log(`${prefix} Scenario prompt preview:`, params.scenarioPromptPreview);
|
|
35
|
+
}
|
|
36
|
+
if (params.aspectRatio !== undefined) {
|
|
37
|
+
console.log(`${prefix} Aspect ratio:`, params.aspectRatio);
|
|
38
|
+
}
|
|
39
|
+
if (params.hasPartner2 !== undefined) {
|
|
40
|
+
console.log(`${prefix} Has partner 2:`, params.hasPartner2);
|
|
41
|
+
}
|
|
42
|
+
if (params.hasCustomInstructions !== undefined) {
|
|
43
|
+
console.log(`${prefix} Has custom instructions:`, params.hasCustomInstructions);
|
|
44
|
+
}
|
|
45
|
+
if (params.hasStrength !== undefined) {
|
|
46
|
+
console.log(`${prefix} Has strength:`, params.hasStrength);
|
|
47
|
+
}
|
|
48
|
+
if (params.strength !== undefined) {
|
|
49
|
+
console.log(`${prefix} Strength value:`, params.strength);
|
|
50
|
+
}
|
|
51
|
+
if (params.partner1Uri !== undefined) {
|
|
52
|
+
console.log(`${prefix} Partner 1 URI:`, params.partner1Uri.substring(0, 80) + "...");
|
|
53
|
+
}
|
|
54
|
+
if (params.partner2Uri !== undefined) {
|
|
55
|
+
console.log(`${prefix} Partner 2 URI:`, params.partner2Uri.substring(0, 80) + "...");
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/domains/generation/infrastructure/couple-generation-builder/utils/builder-step-logger.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Couple Image Generation Builder - Step Logger
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { BuilderStepParams } from "./types";
|
|
6
|
+
|
|
7
|
+
const DEV = typeof __DEV__ !== "undefined" && __DEV__;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Log builder step with details
|
|
11
|
+
*/
|
|
12
|
+
export function logBuilderStep(
|
|
13
|
+
prefix: string,
|
|
14
|
+
stepName: string,
|
|
15
|
+
params: BuilderStepParams = {}
|
|
16
|
+
): void {
|
|
17
|
+
if (!DEV) return;
|
|
18
|
+
|
|
19
|
+
console.log(`${prefix} ===== ${stepName} =====`);
|
|
20
|
+
|
|
21
|
+
if (params.photoUrisCount !== undefined) {
|
|
22
|
+
console.log(`${prefix} Photo URIs count:`, params.photoUrisCount);
|
|
23
|
+
}
|
|
24
|
+
if (params.photo1 !== undefined) {
|
|
25
|
+
console.log(`${prefix} Photo 1:`, params.photo1.substring(0, 60) + "...");
|
|
26
|
+
}
|
|
27
|
+
if (params.photo2 !== undefined) {
|
|
28
|
+
console.log(`${prefix} Photo 2:`, params.photo2.substring(0, 60) + "...");
|
|
29
|
+
}
|
|
30
|
+
if (params.photoCount !== undefined) {
|
|
31
|
+
console.log(`${prefix} Photo count:`, params.photoCount);
|
|
32
|
+
}
|
|
33
|
+
if (params.isCoupleMode !== undefined) {
|
|
34
|
+
console.log(`${prefix} Is couple mode:`, params.isCoupleMode);
|
|
35
|
+
}
|
|
36
|
+
if (params.basePromptLength !== undefined) {
|
|
37
|
+
console.log(`${prefix} Base prompt length:`, params.basePromptLength);
|
|
38
|
+
}
|
|
39
|
+
if (params.contextLength !== undefined) {
|
|
40
|
+
console.log(`${prefix} Appearance context length:`, params.contextLength);
|
|
41
|
+
}
|
|
42
|
+
if (params.contextPreview !== undefined) {
|
|
43
|
+
if (params.contextPreview.length > 0) {
|
|
44
|
+
console.log(`${prefix} Appearance context preview:`, params.contextPreview + "...");
|
|
45
|
+
} else {
|
|
46
|
+
console.log(`${prefix} ℹ️ No appearance context returned (vision disabled)`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (params.refinedPromptLength !== undefined) {
|
|
50
|
+
console.log(`${prefix} Refined prompt length:`, params.refinedPromptLength);
|
|
51
|
+
}
|
|
52
|
+
if (params.refinedPromptPreview !== undefined) {
|
|
53
|
+
console.log(`${prefix} Refined prompt preview:`, params.refinedPromptPreview + "...");
|
|
54
|
+
}
|
|
55
|
+
if (params.finalPromptLength !== undefined) {
|
|
56
|
+
console.log(`${prefix} Final prompt length:`, params.finalPromptLength);
|
|
57
|
+
}
|
|
58
|
+
if (params.finalPromptPreview !== undefined) {
|
|
59
|
+
console.log(`${prefix} Final prompt preview:`, params.finalPromptPreview + "...");
|
|
60
|
+
}
|
|
61
|
+
if (params.promptLength !== undefined) {
|
|
62
|
+
console.log(`${prefix} Prompt length:`, params.promptLength);
|
|
63
|
+
}
|
|
64
|
+
if (params.promptPreview !== undefined) {
|
|
65
|
+
console.log(`${prefix} Prompt preview:`, params.promptPreview + "...");
|
|
66
|
+
}
|
|
67
|
+
if (params.hasCustomInstructions !== undefined) {
|
|
68
|
+
console.log(`${prefix} Has custom instructions:`, params.hasCustomInstructions);
|
|
69
|
+
}
|
|
70
|
+
if (params.customInstructions !== undefined) {
|
|
71
|
+
console.log(`${prefix} Custom instructions:`, params.customInstructions);
|
|
72
|
+
}
|
|
73
|
+
if (params.partner1Uri !== undefined) {
|
|
74
|
+
console.log(`${prefix} Partner 1 URI:`, params.partner1Uri.substring(0, 50) + "...");
|
|
75
|
+
}
|
|
76
|
+
if (params.partner2Uri !== undefined) {
|
|
77
|
+
console.log(`${prefix} Partner 2 URI:`, params.partner2Uri ? params.partner2Uri.substring(0, 50) + "..." : null);
|
|
78
|
+
}
|
|
79
|
+
if (params.singleTarget !== undefined) {
|
|
80
|
+
console.log(`${prefix} Single target:`, params.singleTarget);
|
|
81
|
+
}
|
|
82
|
+
if (params.coupleTarget !== undefined) {
|
|
83
|
+
console.log(`${prefix} Couple target:`, params.coupleTarget);
|
|
84
|
+
}
|
|
85
|
+
if (params.targetModel !== undefined) {
|
|
86
|
+
console.log(`${prefix} Target model:`, params.targetModel);
|
|
87
|
+
}
|
|
88
|
+
if (params.targetProvider !== undefined) {
|
|
89
|
+
console.log(`${prefix} Target provider:`, params.targetProvider);
|
|
90
|
+
}
|
|
91
|
+
if (params.imageUrlsCount !== undefined) {
|
|
92
|
+
console.log(`${prefix} Image URLs count:`, params.imageUrlsCount);
|
|
93
|
+
}
|
|
94
|
+
if (params.image1 !== undefined) {
|
|
95
|
+
console.log(`${prefix} Image 1:`, params.image1.substring(0, 80) + "...");
|
|
96
|
+
}
|
|
97
|
+
if (params.image2 !== undefined) {
|
|
98
|
+
console.log(`${prefix} Image 2:`, params.image2?.substring(0, 80) + "...");
|
|
99
|
+
}
|
|
100
|
+
if (params.aspectRatio !== undefined) {
|
|
101
|
+
console.log(`${prefix} Aspect ratio:`, params.aspectRatio);
|
|
102
|
+
}
|
|
103
|
+
if (params.strength !== undefined) {
|
|
104
|
+
console.log(`${prefix} Strength:`, params.strength);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Couple Image Generation Builder - Utility Functions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export { logBuilderStart } from "./builder-start-logger";
|
|
6
|
+
export { logBuilderStep } from "./builder-step-logger";
|
|
7
|
+
export { logBuilderEnd } from "./builder-end-logger";
|
|
8
|
+
export type { BuilderStartParams, BuilderStepParams } from "./types";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Couple Image Generation Builder - Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export interface BuilderStartParams {
|
|
6
|
+
isCoupleMode?: boolean;
|
|
7
|
+
basePromptLength?: number;
|
|
8
|
+
scenarioPromptLength?: number;
|
|
9
|
+
aspectRatio?: string;
|
|
10
|
+
hasPartner2?: boolean;
|
|
11
|
+
hasCustomInstructions?: boolean;
|
|
12
|
+
hasStrength?: boolean;
|
|
13
|
+
strength?: number;
|
|
14
|
+
partner1Uri?: string;
|
|
15
|
+
partner2Uri?: string;
|
|
16
|
+
scenarioPromptPreview?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface BuilderStepParams {
|
|
20
|
+
photoUrisCount?: number;
|
|
21
|
+
photo1?: string;
|
|
22
|
+
photo2?: string;
|
|
23
|
+
photoCount?: number;
|
|
24
|
+
isCoupleMode?: boolean;
|
|
25
|
+
basePromptLength?: number;
|
|
26
|
+
contextLength?: number;
|
|
27
|
+
contextPreview?: string;
|
|
28
|
+
refinedPromptLength?: number;
|
|
29
|
+
refinedPromptPreview?: string;
|
|
30
|
+
finalPromptLength?: number;
|
|
31
|
+
finalPromptPreview?: string;
|
|
32
|
+
promptLength?: number;
|
|
33
|
+
promptPreview?: string;
|
|
34
|
+
hasCustomInstructions?: boolean;
|
|
35
|
+
customInstructions?: string;
|
|
36
|
+
partner1Uri?: string;
|
|
37
|
+
partner2Uri?: string;
|
|
38
|
+
singleTarget?: string;
|
|
39
|
+
coupleTarget?: string;
|
|
40
|
+
targetModel?: string;
|
|
41
|
+
targetProvider?: string;
|
|
42
|
+
imageUrlsCount?: number;
|
|
43
|
+
image1?: string;
|
|
44
|
+
image2?: string;
|
|
45
|
+
prompt?: string;
|
|
46
|
+
imageUrls?: string[];
|
|
47
|
+
aspectRatio?: string;
|
|
48
|
+
strength?: number;
|
|
49
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Couple Image Generation Builder - Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Logging and helper functions for the couple generation builder
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { logBuilderStart, logBuilderStep, logBuilderEnd } from "./utils";
|
|
8
|
+
export type { BuilderStartParams, BuilderStepParams } from "./utils";
|