@umituz/react-native-ai-generation-content 1.46.1 → 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.
- package/package.json +1 -1
- package/src/domains/prompts/domain/entities/MultiPersonPromptStructure.ts +30 -20
- package/src/domains/prompts/domain/repositories/IAIPromptServices.ts +4 -83
- package/src/domains/prompts/index.ts +5 -53
- package/src/domains/prompts/domain/entities/BackgroundRemovalConfig.ts +0 -86
- package/src/domains/prompts/domain/entities/ColorizationConfig.ts +0 -101
- package/src/domains/prompts/domain/entities/FaceSwapConfig.ts +0 -54
- package/src/domains/prompts/domain/entities/FuturePredictionConfig.ts +0 -94
- package/src/domains/prompts/domain/entities/ImageEnhancementConfig.ts +0 -93
- package/src/domains/prompts/domain/entities/PhotoRestorationConfig.ts +0 -64
- package/src/domains/prompts/domain/entities/StyleTransferConfig.ts +0 -80
- package/src/domains/prompts/domain/entities/TextGenerationConfig.ts +0 -100
- package/src/domains/prompts/infrastructure/services/AIServiceProcessor.ts +0 -142
- package/src/domains/prompts/infrastructure/services/BackgroundRemovalService.ts +0 -75
- package/src/domains/prompts/infrastructure/services/ColorizationService.ts +0 -90
- package/src/domains/prompts/infrastructure/services/FaceSwapService.ts +0 -106
- package/src/domains/prompts/infrastructure/services/FuturePredictionService.ts +0 -129
- package/src/domains/prompts/infrastructure/services/ImageEnhancementService.ts +0 -75
- package/src/domains/prompts/infrastructure/services/PhotoRestorationService.ts +0 -82
- package/src/domains/prompts/infrastructure/services/StyleTransferService.ts +0 -94
- package/src/domains/prompts/infrastructure/services/TextGenerationService.ts +0 -90
- package/src/domains/prompts/presentation/hooks/useAIServices.ts +0 -99
- package/src/domains/prompts/presentation/hooks/useFaceSwap.ts +0 -97
- package/src/domains/prompts/presentation/hooks/useImageEnhancement.ts +0 -98
- package/src/domains/prompts/presentation/hooks/usePhotoRestoration.ts +0 -98
- package/src/domains/prompts/presentation/hooks/useStyleTransfer.ts +0 -123
|
@@ -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
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Colorization Service
|
|
3
|
-
* AI prompt generation for photo colorization
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type {IColorizationService} from '../../domain/repositories/IAIPromptServices';
|
|
7
|
-
import type {ColorizationConfig} from '../../domain/entities/ColorizationConfig';
|
|
8
|
-
import type {AIPromptTemplate} from '../../domain/entities/AIPromptTemplate';
|
|
9
|
-
import {
|
|
10
|
-
validateColorizationConfig,
|
|
11
|
-
getColorizationQuality,
|
|
12
|
-
getSuggestedColorPalette,
|
|
13
|
-
} from '../../domain/entities/ColorizationConfig';
|
|
14
|
-
import { BasePromptService } from './base';
|
|
15
|
-
|
|
16
|
-
const BASE_TEMPLATE = `
|
|
17
|
-
You are an expert AI colorization specialist.
|
|
18
|
-
This is a PHOTO COLORIZATION task, not image generation.
|
|
19
|
-
|
|
20
|
-
COLORIZATION PRINCIPLES:
|
|
21
|
-
- Research appropriate color schemes for image era/content
|
|
22
|
-
- Apply colors that match scene context and lighting
|
|
23
|
-
- Preserve details and textures while adding color
|
|
24
|
-
- Ensure color harmony and balance
|
|
25
|
-
|
|
26
|
-
TECHNICAL:
|
|
27
|
-
- Preserve edges and details during color application
|
|
28
|
-
- Apply colors smoothly and naturally
|
|
29
|
-
- Consider lighting and shadow relationships
|
|
30
|
-
|
|
31
|
-
SAFETY:
|
|
32
|
-
- Do not alter content or composition
|
|
33
|
-
- Preserve important details and features
|
|
34
|
-
- Avoid inappropriate or unrealistic colors
|
|
35
|
-
`.trim();
|
|
36
|
-
|
|
37
|
-
export class ColorizationService
|
|
38
|
-
extends BasePromptService<ColorizationConfig>
|
|
39
|
-
implements IColorizationService
|
|
40
|
-
{
|
|
41
|
-
protected getServiceName(): string {
|
|
42
|
-
return 'colorization';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
validateConfig(config: ColorizationConfig): boolean {
|
|
46
|
-
return validateColorizationConfig(config);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
getColorPalette(config: ColorizationConfig): string[] {
|
|
50
|
-
return getSuggestedColorPalette(config.targetType, config.colorMode);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
getQualityScore(config: ColorizationConfig): number {
|
|
54
|
-
return getColorizationQuality(config);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
protected buildVariables(config: ColorizationConfig): Record<string, unknown> {
|
|
58
|
-
return {
|
|
59
|
-
targetType: config.targetType,
|
|
60
|
-
colorMode: config.colorMode,
|
|
61
|
-
preserveOriginal: config.preserveOriginal,
|
|
62
|
-
adjustLighting: config.adjustLighting,
|
|
63
|
-
skinTonePreservation: config.skinTonePreservation,
|
|
64
|
-
era: config.era || '',
|
|
65
|
-
qualityScore: getColorizationQuality(config),
|
|
66
|
-
colorPalette: this.getColorPalette(config),
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
protected createTemplate(config: ColorizationConfig): AIPromptTemplate {
|
|
71
|
-
const quality = Math.round(getColorizationQuality(config) * 100);
|
|
72
|
-
|
|
73
|
-
return this.createTemplateWithDefaults({
|
|
74
|
-
id: `colorization-${config.targetType}-${config.colorMode}`,
|
|
75
|
-
name: `Colorization: ${config.targetType} to ${config.colorMode}`,
|
|
76
|
-
description: `Colorize ${config.targetType} images with ${config.colorMode} treatment`,
|
|
77
|
-
category: 'colorization',
|
|
78
|
-
template: `${BASE_TEMPLATE}
|
|
79
|
-
|
|
80
|
-
TARGET: ${config.targetType}
|
|
81
|
-
MODE: ${config.colorMode}
|
|
82
|
-
PRESERVE ORIGINAL: ${config.preserveOriginal}
|
|
83
|
-
ADJUST LIGHTING: ${config.adjustLighting}
|
|
84
|
-
SKIN TONE PRESERVATION: ${config.skinTonePreservation}
|
|
85
|
-
${config.era ? `ERA: ${config.era}` : ''}
|
|
86
|
-
|
|
87
|
-
QUALITY: ${quality}%`,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|