@umituz/react-native-ai-generation-content 1.46.0 → 1.47.0

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.
Files changed (33) hide show
  1. package/package.json +1 -1
  2. package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.ts +1 -0
  3. package/src/domains/generation/wizard/infrastructure/strategies/image-generation.strategy.ts +2 -1
  4. package/src/domains/generation/wizard/infrastructure/strategies/image-generation.types.ts +3 -0
  5. package/src/domains/generation/wizard/infrastructure/strategies/shared/unified-prompt-builder.ts +16 -4
  6. package/src/domains/generation/wizard/presentation/hooks/wizard-generation.types.ts +3 -1
  7. package/src/domains/prompts/domain/entities/MultiPersonPromptStructure.ts +56 -1
  8. package/src/domains/prompts/domain/repositories/IAIPromptServices.ts +4 -83
  9. package/src/domains/prompts/index.ts +7 -53
  10. package/src/domains/scenarios/domain/Scenario.ts +8 -0
  11. package/src/domains/scenarios/index.ts +1 -1
  12. package/src/domains/prompts/domain/entities/BackgroundRemovalConfig.ts +0 -86
  13. package/src/domains/prompts/domain/entities/ColorizationConfig.ts +0 -101
  14. package/src/domains/prompts/domain/entities/FaceSwapConfig.ts +0 -54
  15. package/src/domains/prompts/domain/entities/FuturePredictionConfig.ts +0 -94
  16. package/src/domains/prompts/domain/entities/ImageEnhancementConfig.ts +0 -93
  17. package/src/domains/prompts/domain/entities/PhotoRestorationConfig.ts +0 -64
  18. package/src/domains/prompts/domain/entities/StyleTransferConfig.ts +0 -80
  19. package/src/domains/prompts/domain/entities/TextGenerationConfig.ts +0 -100
  20. package/src/domains/prompts/infrastructure/services/AIServiceProcessor.ts +0 -142
  21. package/src/domains/prompts/infrastructure/services/BackgroundRemovalService.ts +0 -75
  22. package/src/domains/prompts/infrastructure/services/ColorizationService.ts +0 -90
  23. package/src/domains/prompts/infrastructure/services/FaceSwapService.ts +0 -106
  24. package/src/domains/prompts/infrastructure/services/FuturePredictionService.ts +0 -129
  25. package/src/domains/prompts/infrastructure/services/ImageEnhancementService.ts +0 -75
  26. package/src/domains/prompts/infrastructure/services/PhotoRestorationService.ts +0 -82
  27. package/src/domains/prompts/infrastructure/services/StyleTransferService.ts +0 -94
  28. package/src/domains/prompts/infrastructure/services/TextGenerationService.ts +0 -90
  29. package/src/domains/prompts/presentation/hooks/useAIServices.ts +0 -99
  30. package/src/domains/prompts/presentation/hooks/useFaceSwap.ts +0 -97
  31. package/src/domains/prompts/presentation/hooks/useImageEnhancement.ts +0 -98
  32. package/src/domains/prompts/presentation/hooks/usePhotoRestoration.ts +0 -98
  33. package/src/domains/prompts/presentation/hooks/useStyleTransfer.ts +0 -123
@@ -1,94 +0,0 @@
1
- import type { AIPromptVariable } from './value-objects';
2
-
3
- /**
4
- * Future Prediction Configuration
5
- * Generic configuration for generating future scenarios/visualizations
6
- */
7
-
8
- export interface FuturePredictionSettings {
9
- readonly scenarioType: string; // e.g. 'lifestyle', 'career', 'family', 'adventure'
10
- readonly outputType: FuturePredictionOutputType;
11
- readonly personCount: 1 | 2;
12
- readonly includeDate: boolean;
13
- readonly language: string; // Language code (e.g. 'en', 'tr')
14
- readonly languageName?: string; // Full language name provided by app (e.g. 'Turkish', 'English')
15
- readonly tone?: string; // e.g. 'romantic', 'professional', 'funny', 'dramatic'
16
- readonly subjectRole?: string; // e.g. 'couple', 'best friends', 'business partners', 'parents'
17
- readonly year?: number; // Optional specific year for prediction
18
- }
19
-
20
- export type FuturePredictionOutputType = 'image' | 'story' | 'both';
21
-
22
- export interface FuturePredictionConfig {
23
- readonly scenarioId: string;
24
- readonly scenarioTitle: string;
25
- readonly promptModifier: string;
26
- readonly subjectA: string;
27
- readonly subjectB?: string;
28
- readonly settings: FuturePredictionSettings;
29
- readonly customPrompt?: string;
30
- }
31
-
32
- export interface FuturePredictionTemplate {
33
- readonly id: string;
34
- readonly name: string;
35
- readonly description: string;
36
- readonly imagePrompt: string;
37
- readonly storyPrompt: string;
38
- readonly variables: readonly FuturePredictionVariable[];
39
- }
40
-
41
- export interface FuturePredictionVariable extends AIPromptVariable {
42
- readonly category: 'subject' | 'scenario' | 'output';
43
- }
44
-
45
- export interface FuturePredictionResult {
46
- readonly imagePrompt: string;
47
- readonly storyPrompt: string;
48
- readonly metadata: FuturePredictionMetadata;
49
- }
50
-
51
- export interface FuturePredictionMetadata {
52
- readonly scenarioId: string;
53
- readonly personCount: number;
54
- readonly language: string;
55
- readonly generatedAt: number;
56
- }
57
-
58
- export const validateFuturePredictionConfig = (
59
- config: FuturePredictionConfig
60
- ): boolean => {
61
- if (!config.scenarioId || typeof config.scenarioId !== 'string') {
62
- return false;
63
- }
64
- if (!config.subjectA || typeof config.subjectA !== 'string') {
65
- return false;
66
- }
67
- if (!config.settings) {
68
- return false;
69
- }
70
- return true;
71
- };
72
-
73
- export const createFuturePredictionVariable = (
74
- name: string,
75
- type: 'string' | 'number' | 'boolean',
76
- description: string,
77
- category: 'subject' | 'scenario' | 'output',
78
- required: boolean = true,
79
- defaultValue?: string | number | boolean
80
- ): FuturePredictionVariable => ({
81
- name,
82
- type,
83
- description,
84
- category,
85
- required,
86
- defaultValue,
87
- });
88
-
89
- export const getFutureYear = (): number => {
90
- const currentYear = new Date().getFullYear();
91
- // Typical future predictions are 1-50 years ahead
92
- const offset = 1 + Math.floor(Math.random() * 50);
93
- return currentYear + offset;
94
- };
@@ -1,93 +0,0 @@
1
- import type { AIPromptTemplate } from './AIPromptTemplate';
2
-
3
- export interface ImageEnhancementConfig {
4
- enhancementType: 'brightness' | 'contrast' | 'saturation' | 'sharpness' | 'all';
5
- intensity: number;
6
- preserveNatural: boolean;
7
- autoAdjust: boolean;
8
- targetStyle: 'natural' | 'vivid' | 'dramatic' | 'professional';
9
- }
10
-
11
- export interface ImageEnhancementTemplate {
12
- readonly id: string;
13
- readonly name: string;
14
- readonly description: string;
15
- readonly basePrompt: string;
16
- readonly variables: ImageEnhancementVariable[];
17
- readonly enhancement: EnhancementSettings;
18
- }
19
-
20
- export interface ImageEnhancementVariable {
21
- name: string;
22
- description: string;
23
- required: boolean;
24
- type: 'number' | 'select';
25
- min?: number;
26
- max?: number;
27
- options?: string[];
28
- }
29
-
30
- export interface EnhancementSettings {
31
- brightnessRange: [number, number];
32
- contrastRange: [number, number];
33
- saturationRange: [number, number];
34
- sharpnessRange: [number, number];
35
- }
36
-
37
- export interface ImageEnhancementResult {
38
- template: AIPromptTemplate;
39
- config: ImageEnhancementConfig;
40
- adjustments: EnhancementAdjustments;
41
- }
42
-
43
- export interface EnhancementAdjustments {
44
- brightness: number;
45
- contrast: number;
46
- saturation: number;
47
- sharpness: number;
48
- overall: number;
49
- }
50
-
51
- export const validateImageEnhancementConfig = (config: ImageEnhancementConfig): boolean => {
52
- return !!(
53
- config.enhancementType &&
54
- config.intensity >= 0 &&
55
- config.intensity <= 1 &&
56
- config.targetStyle
57
- );
58
- };
59
-
60
- export const createImageEnhancementVariable = (
61
- name: string,
62
- description: string,
63
- type: ImageEnhancementVariable['type'] = 'select',
64
- required: boolean = true,
65
- options?: string[]
66
- ): ImageEnhancementVariable => ({
67
- name,
68
- description,
69
- type,
70
- required,
71
- options,
72
- });
73
-
74
- export const calculateAdjustments = (
75
- config: ImageEnhancementConfig
76
- ): EnhancementAdjustments => {
77
- const baseIntensity = config.intensity;
78
- const multiplier = config.targetStyle === 'dramatic' ? 1.5 :
79
- config.targetStyle === 'vivid' ? 1.2 :
80
- config.targetStyle === 'professional' ? 0.8 : 1;
81
-
82
- return {
83
- brightness: config.enhancementType === 'brightness' || config.enhancementType === 'all'
84
- ? baseIntensity * multiplier : 0,
85
- contrast: config.enhancementType === 'contrast' || config.enhancementType === 'all'
86
- ? baseIntensity * multiplier : 0,
87
- saturation: config.enhancementType === 'saturation' || config.enhancementType === 'all'
88
- ? baseIntensity * multiplier : 0,
89
- sharpness: config.enhancementType === 'sharpness' || config.enhancementType === 'all'
90
- ? baseIntensity * multiplier : 0,
91
- overall: baseIntensity * multiplier,
92
- };
93
- };
@@ -1,64 +0,0 @@
1
- import type { AIPromptTemplate } from './AIPromptTemplate';
2
-
3
- export interface PhotoRestorationConfig {
4
- severity: 'minor' | 'moderate' | 'severe';
5
- preserveOriginal: boolean;
6
- enhanceColors: boolean;
7
- removeNoise: boolean;
8
- fixBlur: boolean;
9
- restoreDetails: boolean;
10
- }
11
-
12
- export interface PhotoRestorationTemplate {
13
- readonly id: string;
14
- readonly name: string;
15
- readonly description: string;
16
- readonly basePrompt: string;
17
- readonly variables: PhotoRestorationVariable[];
18
- readonly quality: PhotoRestorationQuality;
19
- }
20
-
21
- export interface PhotoRestorationVariable {
22
- name: string;
23
- description: string;
24
- required: boolean;
25
- options?: string[];
26
- }
27
-
28
- export interface PhotoRestorationQuality {
29
- detailLevel: number;
30
- noiseReduction: number;
31
- colorAccuracy: number;
32
- sharpness: number;
33
- }
34
-
35
- export interface PhotoRestorationResult {
36
- template: AIPromptTemplate;
37
- config: PhotoRestorationConfig;
38
- estimatedQuality: number;
39
- }
40
-
41
- export const validatePhotoRestorationConfig = (config: PhotoRestorationConfig): boolean => {
42
- return !!(config.severity && config.severity.trim().length > 0);
43
- };
44
-
45
- export const createPhotoRestorationVariable = (
46
- name: string,
47
- description: string,
48
- required: boolean = true,
49
- options?: string[]
50
- ): PhotoRestorationVariable => ({
51
- name,
52
- description,
53
- required,
54
- options,
55
- });
56
-
57
- export const getQualityLevel = (severity: PhotoRestorationConfig['severity']): number => {
58
- switch (severity) {
59
- case 'minor': return 0.7;
60
- case 'moderate': return 0.5;
61
- case 'severe': return 0.3;
62
- default: return 0.5;
63
- }
64
- };
@@ -1,80 +0,0 @@
1
- import type { AIPromptTemplate } from './AIPromptTemplate';
2
-
3
- export interface StyleTransferConfig {
4
- targetStyle: string;
5
- preserveContent: boolean;
6
- styleStrength: number;
7
- artisticMode: 'photorealistic' | 'artistic' | 'abstract' | 'cartoon';
8
- maintainColors: boolean;
9
- adaptToSubject: boolean;
10
- }
11
-
12
- export interface StyleTransferTemplate {
13
- readonly id: string;
14
- readonly name: string;
15
- readonly description: string;
16
- readonly basePrompt: string;
17
- readonly variables: StyleTransferVariable[];
18
- readonly style: StyleTransferSettings;
19
- }
20
-
21
- export interface StyleTransferVariable {
22
- name: string;
23
- description: string;
24
- required: boolean;
25
- options?: string[];
26
- type: 'string' | 'select';
27
- }
28
-
29
- export interface StyleTransferSettings {
30
- supportedStyles: string[];
31
- maxStyleStrength: number;
32
- preserveContentLevels: number[];
33
- qualityPresets: Record<string, number>;
34
- }
35
-
36
- export interface StyleTransferResult {
37
- template: AIPromptTemplate;
38
- config: StyleTransferConfig;
39
- appliedStyle: string;
40
- expectedQuality: number;
41
- }
42
-
43
- export const validateStyleTransferConfig = (config: StyleTransferConfig): boolean => {
44
- return !!(
45
- config.targetStyle &&
46
- config.targetStyle.trim().length > 0 &&
47
- config.styleStrength >= 0 &&
48
- config.styleStrength <= 1 &&
49
- config.artisticMode
50
- );
51
- };
52
-
53
- export const createStyleTransferVariable = (
54
- name: string,
55
- description: string,
56
- required: boolean = true,
57
- options?: string[]
58
- ): StyleTransferVariable => ({
59
- name,
60
- description,
61
- required,
62
- options,
63
- type: 'string',
64
- });
65
-
66
- export const getStyleStrengthValue = (strength: number): string => {
67
- if (strength <= 0.3) return 'subtle';
68
- if (strength <= 0.6) return 'moderate';
69
- return 'strong';
70
- };
71
-
72
- export const getArtisticModeDescription = (mode: StyleTransferConfig['artisticMode']): string => {
73
- switch (mode) {
74
- case 'photorealistic': return 'Maintain realistic appearance while applying style';
75
- case 'artistic': return 'Apply artistic interpretation with creative freedom';
76
- case 'abstract': return 'Transform into abstract artistic representation';
77
- case 'cartoon': return 'Convert to cartoon/animated style';
78
- default: return 'Apply selected artistic style';
79
- }
80
- };
@@ -1,100 +0,0 @@
1
- import type { AIPromptTemplate } from './AIPromptTemplate';
2
-
3
- export interface TextGenerationConfig {
4
- promptType: 'creative' | 'technical' | 'marketing' | 'educational' | 'conversational';
5
- tone: 'formal' | 'casual' | 'professional' | 'friendly' | 'humorous';
6
- length: 'short' | 'medium' | 'long';
7
- language: string;
8
- context?: string;
9
- keywords?: string[];
10
- }
11
-
12
- export interface TextGenerationTemplate {
13
- readonly id: string;
14
- readonly name: string;
15
- readonly description: string;
16
- readonly basePrompt: string;
17
- readonly variables: TextGenerationVariable[];
18
- readonly generation: TextGenerationSettings;
19
- }
20
-
21
- export interface TextGenerationVariable {
22
- name: string;
23
- description: string;
24
- required: boolean;
25
- type: 'string' | 'select' | 'array';
26
- options?: string[];
27
- }
28
-
29
- export interface TextGenerationSettings {
30
- supportedLanguages: string[];
31
- maxTokens: Record<string, number>;
32
- temperaturePresets: Record<string, number>;
33
- }
34
-
35
- export interface TextGenerationResult {
36
- template: AIPromptTemplate;
37
- config: TextGenerationConfig;
38
- estimatedTokens: number;
39
- suggestedParameters: {
40
- temperature: number;
41
- maxTokens: number;
42
- topP: number;
43
- };
44
- }
45
-
46
- export const validateTextGenerationConfig = (config: TextGenerationConfig): boolean => {
47
- return !!(
48
- config.promptType &&
49
- config.tone &&
50
- config.length &&
51
- config.language &&
52
- config.language.trim().length > 0
53
- );
54
- };
55
-
56
- export const createTextGenerationVariable = (
57
- name: string,
58
- description: string,
59
- type: TextGenerationVariable['type'] = 'string',
60
- required: boolean = true,
61
- options?: string[]
62
- ): TextGenerationVariable => ({
63
- name,
64
- description,
65
- type,
66
- required,
67
- options,
68
- });
69
-
70
- export const getTokenCount = (length: TextGenerationConfig['length']): number => {
71
- switch (length) {
72
- case 'short': return 50;
73
- case 'medium': return 200;
74
- case 'long': return 500;
75
- default: return 200;
76
- }
77
- };
78
-
79
- export const getTemperature = (
80
- promptType: TextGenerationConfig['promptType'],
81
- tone: TextGenerationConfig['tone']
82
- ): number => {
83
- let temp = 0.7;
84
-
85
- if (promptType === 'creative') temp += 0.2;
86
- if (promptType === 'technical') temp -= 0.3;
87
- if (tone === 'humorous') temp += 0.1;
88
- if (tone === 'formal') temp -= 0.2;
89
-
90
- return Math.max(0.1, Math.min(1.0, temp));
91
- };
92
-
93
- export const getTopP = (promptType: TextGenerationConfig['promptType']): number => {
94
- switch (promptType) {
95
- case 'creative': return 0.95;
96
- case 'technical': return 0.8;
97
- case 'educational': return 0.85;
98
- default: return 0.9;
99
- }
100
- };
@@ -1,142 +0,0 @@
1
- /**
2
- * AI Service Processor
3
- * Handles processing of different AI service types
4
- */
5
-
6
- import type {FaceSwapConfig} from '../../domain/entities/FaceSwapConfig';
7
- import type {PhotoRestorationConfig} from '../../domain/entities/PhotoRestorationConfig';
8
- import type {ImageEnhancementConfig} from '../../domain/entities/ImageEnhancementConfig';
9
- import type {StyleTransferConfig} from '../../domain/entities/StyleTransferConfig';
10
- import type {BackgroundRemovalConfig} from '../../domain/entities/BackgroundRemovalConfig';
11
- import type {TextGenerationConfig} from '../../domain/entities/TextGenerationConfig';
12
- import type {ColorizationConfig} from '../../domain/entities/ColorizationConfig';
13
- import type {
14
- IFaceSwapService,
15
- IPhotoRestorationService,
16
- IImageEnhancementService,
17
- IStyleTransferService,
18
- IBackgroundRemovalService,
19
- ITextGenerationService,
20
- IColorizationService,
21
- } from '../../domain/repositories/IAIPromptServices';
22
- import type {AIPromptResult} from '../../domain/entities/types';
23
- import type {AIPromptTemplate} from '../../domain/entities/AIPromptTemplate';
24
-
25
- export type AIConfig =
26
- | { type: 'face-swap'; config: FaceSwapConfig }
27
- | { type: 'photo-restoration'; config: PhotoRestorationConfig }
28
- | { type: 'image-enhancement'; config: ImageEnhancementConfig }
29
- | { type: 'style-transfer'; config: StyleTransferConfig }
30
- | { type: 'background-removal'; config: BackgroundRemovalConfig }
31
- | { type: 'text-generation'; config: TextGenerationConfig }
32
- | { type: 'colorization'; config: ColorizationConfig };
33
-
34
- export interface AIServices {
35
- faceSwap: IFaceSwapService;
36
- photoRestoration: IPhotoRestorationService;
37
- imageEnhancement: IImageEnhancementService;
38
- styleTransfer: IStyleTransferService;
39
- backgroundRemoval: IBackgroundRemovalService;
40
- textGeneration: ITextGenerationService;
41
- colorization: IColorizationService;
42
- }
43
-
44
- export interface ProcessResult {
45
- template: AIPromptTemplate;
46
- prompt: string;
47
- config: Record<string, unknown>;
48
- }
49
-
50
- export class AIServiceProcessor {
51
- constructor(private services: AIServices) { }
52
-
53
- async process(aiConfig: AIConfig): Promise<ProcessResult> {
54
- const { templateResult, promptResult } = await this.executeService(aiConfig);
55
-
56
- if (!templateResult?.success || !templateResult.data) {
57
- throw new Error('Failed to generate template');
58
- }
59
-
60
- if (!promptResult?.success || !promptResult.data) {
61
- throw new Error('Failed to generate prompt');
62
- }
63
-
64
- return {
65
- template: templateResult.data,
66
- prompt: promptResult.data,
67
- config: aiConfig.config as unknown as Record<string, unknown>,
68
- };
69
- }
70
-
71
- async getAvailableStyles(serviceType: string): Promise<string[]> {
72
- switch (serviceType) {
73
- case 'face-swap':
74
- return await this.services.faceSwap.getAvailableStyles();
75
- case 'style-transfer':
76
- return await this.services.styleTransfer.getAvailableStyles();
77
- default:
78
- return [];
79
- }
80
- }
81
-
82
- private async executeService(aiConfig: AIConfig): Promise<{
83
- templateResult: AIPromptResult<AIPromptTemplate> | undefined;
84
- promptResult: AIPromptResult<string> | undefined;
85
- }> {
86
- let templateResult: AIPromptResult<AIPromptTemplate> | undefined;
87
- let promptResult: AIPromptResult<string> | undefined;
88
-
89
- switch (aiConfig.type) {
90
- case 'face-swap':
91
- templateResult = await this.services.faceSwap.generateTemplate(aiConfig.config);
92
- if (templateResult.success && templateResult.data) {
93
- promptResult = await this.services.faceSwap.generatePrompt(templateResult.data, aiConfig.config);
94
- }
95
- break;
96
-
97
- case 'photo-restoration':
98
- templateResult = await this.services.photoRestoration.generateTemplate(aiConfig.config);
99
- if (templateResult.success && templateResult.data) {
100
- promptResult = await this.services.photoRestoration.generatePrompt(templateResult.data, aiConfig.config);
101
- }
102
- break;
103
-
104
- case 'image-enhancement':
105
- templateResult = await this.services.imageEnhancement.generateTemplate(aiConfig.config);
106
- if (templateResult.success && templateResult.data) {
107
- promptResult = await this.services.imageEnhancement.generatePrompt(templateResult.data, aiConfig.config);
108
- }
109
- break;
110
-
111
- case 'style-transfer':
112
- templateResult = await this.services.styleTransfer.generateTemplate(aiConfig.config);
113
- if (templateResult.success && templateResult.data) {
114
- promptResult = await this.services.styleTransfer.generatePrompt(templateResult.data, aiConfig.config);
115
- }
116
- break;
117
-
118
- case 'background-removal':
119
- templateResult = await this.services.backgroundRemoval.generateTemplate(aiConfig.config);
120
- if (templateResult.success && templateResult.data) {
121
- promptResult = await this.services.backgroundRemoval.generatePrompt(templateResult.data, aiConfig.config);
122
- }
123
- break;
124
-
125
- case 'text-generation':
126
- templateResult = await this.services.textGeneration.generateTemplate(aiConfig.config);
127
- if (templateResult.success && templateResult.data) {
128
- promptResult = await this.services.textGeneration.generatePrompt(templateResult.data, aiConfig.config);
129
- }
130
- break;
131
-
132
- case 'colorization':
133
- templateResult = await this.services.colorization.generateTemplate(aiConfig.config);
134
- if (templateResult.success && templateResult.data) {
135
- promptResult = await this.services.colorization.generatePrompt(templateResult.data, aiConfig.config);
136
- }
137
- break;
138
- }
139
-
140
- return { templateResult, promptResult };
141
- }
142
- }
@@ -1,75 +0,0 @@
1
- /**
2
- * Background Removal Service
3
- * AI prompt generation for background removal tasks
4
- */
5
-
6
- import type {IBackgroundRemovalService} from '../../domain/repositories/IAIPromptServices';
7
- import type {BackgroundRemovalConfig} from '../../domain/entities/BackgroundRemovalConfig';
8
- import type {AIPromptTemplate} from '../../domain/entities/AIPromptTemplate';
9
- import {validateBackgroundRemovalConfig, getProcessingTime, getQualityScore} from '../../domain/entities/BackgroundRemovalConfig';
10
- import { BasePromptService } from './base';
11
-
12
- const BASE_TEMPLATE = `
13
- You are an expert AI background removal specialist.
14
- This is a BACKGROUND REMOVAL task, not image generation.
15
-
16
- DETECTION PRINCIPLES:
17
- - Accurately identify foreground subject
18
- - Distinguish between subject and background
19
- - Handle complex edges (hair, fur, transparent objects)
20
- - Preserve fine details and textures
21
-
22
- SAFETY CONSTRAINTS:
23
- - Preserve subject completely
24
- - Do not alter foreground content
25
- - Maintain important details
26
- - Avoid over-removal of subject elements
27
- `.trim();
28
-
29
- export class BackgroundRemovalService
30
- extends BasePromptService<BackgroundRemovalConfig>
31
- implements IBackgroundRemovalService
32
- {
33
- protected getServiceName(): string {
34
- return 'background removal';
35
- }
36
-
37
- validateConfig(config: BackgroundRemovalConfig): boolean {
38
- return validateBackgroundRemovalConfig(config);
39
- }
40
-
41
- estimateProcessingTime(config: BackgroundRemovalConfig): number {
42
- return getProcessingTime(config.precision);
43
- }
44
-
45
- protected buildVariables(config: BackgroundRemovalConfig): Record<string, unknown> {
46
- return {
47
- precision: config.precision,
48
- edgeRefinement: config.edgeRefinement,
49
- preserveHair: config.preserveHair,
50
- outputFormat: config.outputFormat,
51
- addNewBackground: config.addNewBackground,
52
- processingTime: getProcessingTime(config.precision),
53
- qualityScore: getQualityScore(config),
54
- };
55
- }
56
-
57
- protected createTemplate(config: BackgroundRemovalConfig): AIPromptTemplate {
58
- return this.createTemplateWithDefaults({
59
- id: `background-removal-${config.precision}`,
60
- name: `Background Removal: ${config.precision}`,
61
- description: `Remove background with ${config.precision} precision`,
62
- category: 'background-removal',
63
- template: `${BASE_TEMPLATE}
64
-
65
- PRECISION: ${config.precision}
66
- EDGE REFINEMENT: ${config.edgeRefinement}
67
- PRESERVE HAIR: ${config.preserveHair}
68
- OUTPUT: ${config.outputFormat}
69
- ${config.addNewBackground ? `NEW BACKGROUND: ${config.addNewBackground}` : ''}
70
-
71
- QUALITY: ${Math.round(getQualityScore(config) * 100)}%
72
- EST. TIME: ${getProcessingTime(config.precision)}s`,
73
- });
74
- }
75
- }