@umituz/react-native-ai-generation-content 1.12.2 → 1.12.4

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 (55) hide show
  1. package/package.json +6 -1
  2. package/src/domains/content-moderation/domain/entities/moderation.types.ts +84 -0
  3. package/src/domains/content-moderation/domain/interfaces/content-filter.interface.ts +24 -0
  4. package/src/domains/content-moderation/index.ts +67 -0
  5. package/src/domains/content-moderation/infrastructure/rules/default-rules.data.ts +144 -0
  6. package/src/domains/content-moderation/infrastructure/rules/rules-registry.ts +75 -0
  7. package/src/domains/content-moderation/infrastructure/services/content-moderation.service.ts +150 -0
  8. package/src/domains/content-moderation/infrastructure/services/index.ts +8 -0
  9. package/src/domains/content-moderation/infrastructure/services/moderators/base.moderator.ts +62 -0
  10. package/src/domains/content-moderation/infrastructure/services/moderators/image.moderator.ts +64 -0
  11. package/src/domains/content-moderation/infrastructure/services/moderators/index.ts +10 -0
  12. package/src/domains/content-moderation/infrastructure/services/moderators/text.moderator.ts +144 -0
  13. package/src/domains/content-moderation/infrastructure/services/moderators/video.moderator.ts +64 -0
  14. package/src/domains/content-moderation/infrastructure/services/moderators/voice.moderator.ts +74 -0
  15. package/src/domains/content-moderation/infrastructure/services/pattern-matcher.service.ts +51 -0
  16. package/src/domains/content-moderation/presentation/exceptions/content-policy-violation.exception.ts +48 -0
  17. package/src/domains/prompts/domain/entities/AIPromptTemplate.ts +48 -0
  18. package/src/domains/prompts/domain/entities/BackgroundRemovalConfig.ts +86 -0
  19. package/src/domains/prompts/domain/entities/ColorizationConfig.ts +101 -0
  20. package/src/domains/prompts/domain/entities/FaceSwapConfig.ts +54 -0
  21. package/src/domains/prompts/domain/entities/FuturePredictionConfig.ts +93 -0
  22. package/src/domains/prompts/domain/entities/GeneratedPrompt.ts +32 -0
  23. package/src/domains/prompts/domain/entities/ImageEnhancementConfig.ts +93 -0
  24. package/src/domains/prompts/domain/entities/PhotoRestorationConfig.ts +64 -0
  25. package/src/domains/prompts/domain/entities/StyleTransferConfig.ts +80 -0
  26. package/src/domains/prompts/domain/entities/TextGenerationConfig.ts +100 -0
  27. package/src/domains/prompts/domain/entities/types.ts +27 -0
  28. package/src/domains/prompts/domain/entities/value-objects.ts +33 -0
  29. package/src/domains/prompts/domain/repositories/IAIPromptServices.ts +106 -0
  30. package/src/domains/prompts/domain/repositories/IPromptHistoryRepository.ts +10 -0
  31. package/src/domains/prompts/domain/repositories/ITemplateRepository.ts +11 -0
  32. package/src/domains/prompts/index.ts +318 -0
  33. package/src/domains/prompts/infrastructure/repositories/PromptHistoryRepository.ts +85 -0
  34. package/src/domains/prompts/infrastructure/repositories/TemplateRepository.ts +77 -0
  35. package/src/domains/prompts/infrastructure/services/BackgroundRemovalService.ts +209 -0
  36. package/src/domains/prompts/infrastructure/services/ColorizationService.ts +232 -0
  37. package/src/domains/prompts/infrastructure/services/FaceSwapService.ts +198 -0
  38. package/src/domains/prompts/infrastructure/services/FuturePredictionService.ts +176 -0
  39. package/src/domains/prompts/infrastructure/services/ImageEnhancementService.ts +181 -0
  40. package/src/domains/prompts/infrastructure/services/PhotoRestorationService.ts +160 -0
  41. package/src/domains/prompts/infrastructure/services/PromptGenerationService.ts +59 -0
  42. package/src/domains/prompts/infrastructure/services/StyleTransferService.ts +194 -0
  43. package/src/domains/prompts/infrastructure/services/TextGenerationService.ts +241 -0
  44. package/src/domains/prompts/presentation/hooks/useAIServices.ts +213 -0
  45. package/src/domains/prompts/presentation/hooks/useAsyncState.ts +56 -0
  46. package/src/domains/prompts/presentation/hooks/useFaceSwap.ts +100 -0
  47. package/src/domains/prompts/presentation/hooks/useImageEnhancement.ts +100 -0
  48. package/src/domains/prompts/presentation/hooks/usePhotoRestoration.ts +100 -0
  49. package/src/domains/prompts/presentation/hooks/usePromptGeneration.ts +144 -0
  50. package/src/domains/prompts/presentation/hooks/useStyleTransfer.ts +125 -0
  51. package/src/domains/prompts/presentation/hooks/useTemplateRepository.ts +113 -0
  52. package/src/domains/prompts/presentation/theme/theme.ts +16 -0
  53. package/src/domains/prompts/presentation/theme/types.ts +82 -0
  54. package/src/domains/prompts/presentation/theme/utils.ts +24 -0
  55. package/src/index.ts +12 -0
@@ -0,0 +1,181 @@
1
+ import type { IImageEnhancementService } from '../../domain/repositories/IAIPromptServices';
2
+ import type {
3
+ ImageEnhancementConfig,
4
+ EnhancementAdjustments,
5
+ } from '../../domain/entities/ImageEnhancementConfig';
6
+ import type { AIPromptTemplate } from '../../domain/entities/AIPromptTemplate';
7
+ import type { AIPromptResult } from '../../domain/entities/types';
8
+ import { createAIPromptTemplate } from '../../domain/entities/AIPromptTemplate';
9
+ import {
10
+ validateImageEnhancementConfig,
11
+ calculateAdjustments
12
+ } from '../../domain/entities/ImageEnhancementConfig';
13
+ import { PromptGenerationService } from '../services/PromptGenerationService';
14
+
15
+ const createImageEnhancementBaseTemplate = (config?: {
16
+ enhancementType?: string;
17
+ targetStyle?: string;
18
+ }): string => {
19
+ const {
20
+ enhancementType = 'comprehensive',
21
+ targetStyle = 'natural'
22
+ } = config || {};
23
+
24
+ return `
25
+ You are an expert AI image enhancement specialist.
26
+ This is an IMAGE ENHANCEMENT task, not image generation.
27
+
28
+ ENHANCEMENT GOAL:
29
+ Apply ${enhancementType} improvements with ${targetStyle} appearance
30
+ while preserving the original content and composition.
31
+
32
+ ENHANCEMENT PRINCIPLES:
33
+ - Maintain natural appearance and authenticity
34
+ - Apply subtle, professional-grade adjustments
35
+ - Preserve important details and textures
36
+ - Avoid over-processing or artificial results
37
+
38
+ TECHNICAL REQUIREMENTS:
39
+ - Proper exposure and brightness correction
40
+ - Optimal contrast and dynamic range
41
+ - Natural color balance and saturation
42
+ - Appropriate sharpening and clarity
43
+ - Noise reduction without losing details
44
+
45
+ STYLE CONSIDERATIONS:
46
+ ${targetStyle === 'vivid' ? '- Vibrant colors with high impact' :
47
+ targetStyle === 'dramatic' ? '- Enhanced contrast and mood' :
48
+ targetStyle === 'professional' ? '- Conservative, polished look' :
49
+ '- Natural, balanced appearance'}
50
+
51
+ SAFETY CONSTRAINTS:
52
+ - Do not alter the subject or composition
53
+ - Preserve skin tones and natural colors
54
+ - Avoid artificial or over-enhanced results
55
+ - Maintain photo authenticity
56
+
57
+ OUTPUT:
58
+ A professionally enhanced version with ${enhancementType} improvements,
59
+ optimized for ${targetStyle} presentation.
60
+ `.trim();
61
+ };
62
+
63
+ export class ImageEnhancementService implements IImageEnhancementService {
64
+ private promptService: PromptGenerationService;
65
+
66
+ constructor() {
67
+ this.promptService = new PromptGenerationService();
68
+ }
69
+
70
+ async generateTemplate(config: ImageEnhancementConfig): Promise<AIPromptResult<AIPromptTemplate>> {
71
+ try {
72
+ if (!this.validateConfig(config)) {
73
+ return {
74
+ success: false,
75
+ error: 'VALIDATION_ERROR',
76
+ message: 'Invalid image enhancement configuration'
77
+ };
78
+ }
79
+
80
+ const template = this.createImageEnhancementTemplate(config);
81
+ return { success: true, data: template };
82
+ } catch (error) {
83
+ return {
84
+ success: false,
85
+ error: 'GENERATION_FAILED',
86
+ message: 'Failed to generate image enhancement template'
87
+ };
88
+ }
89
+ }
90
+
91
+ async generatePrompt(
92
+ template: AIPromptTemplate,
93
+ config: ImageEnhancementConfig
94
+ ): Promise<AIPromptResult<string>> {
95
+ const adjustments = this.calculateAdjustments(config);
96
+ const variables = {
97
+ enhancementType: config.enhancementType,
98
+ intensity: config.intensity,
99
+ preserveNatural: config.preserveNatural,
100
+ autoAdjust: config.autoAdjust,
101
+ targetStyle: config.targetStyle,
102
+ adjustments,
103
+ };
104
+
105
+ return this.promptService.generateFromTemplate(template, variables);
106
+ }
107
+
108
+ validateConfig(config: ImageEnhancementConfig): boolean {
109
+ return validateImageEnhancementConfig(config);
110
+ }
111
+
112
+ calculateAdjustments(config: ImageEnhancementConfig): EnhancementAdjustments {
113
+ return calculateAdjustments(config);
114
+ }
115
+
116
+ private createImageEnhancementTemplate(config: ImageEnhancementConfig): AIPromptTemplate {
117
+ const templateId = `image-enhancement-${config.enhancementType}`;
118
+
119
+ const baseTemplate = createImageEnhancementBaseTemplate({
120
+ enhancementType: config.enhancementType,
121
+ targetStyle: config.targetStyle,
122
+ });
123
+
124
+ return createAIPromptTemplate({
125
+ id: templateId,
126
+ name: `Image Enhancement: ${config.enhancementType}`,
127
+ description: `Enhance images with ${config.enhancementType} improvements`,
128
+ category: 'image-enhancement',
129
+ template: `${baseTemplate}
130
+
131
+ ENHANCEMENT TYPE:
132
+ ${config.enhancementType}
133
+
134
+ STYLE TARGET:
135
+ ${config.targetStyle}
136
+
137
+ ADJUSTMENT PARAMETERS:
138
+ - Intensity Level: ${Math.round(config.intensity * 100)}%
139
+ - Preserve Natural: ${config.preserveNatural}
140
+ - Auto Adjust: ${config.autoAdjust}
141
+ - Target Style: ${config.targetStyle}
142
+
143
+ SPECIFIC ENHANCEMENTS:
144
+ ${this.getSpecificEnhancements(config)}
145
+
146
+ EXPECTED RESULT:
147
+ Professional ${config.enhancementType} enhancement
148
+ with ${config.targetStyle} presentation style,
149
+ maintaining authenticity while improving quality.
150
+ `.trim(),
151
+ variables: [],
152
+ safety: {
153
+ contentFilter: true,
154
+ adultContentFilter: true,
155
+ violenceFilter: true,
156
+ hateSpeechFilter: true,
157
+ copyrightFilter: true,
158
+ },
159
+ version: '1.0.0',
160
+ });
161
+ }
162
+
163
+ private getSpecificEnhancements(config: ImageEnhancementConfig): string {
164
+ const enhancements: string[] = [];
165
+
166
+ if (config.enhancementType === 'brightness' || config.enhancementType === 'all') {
167
+ enhancements.push('- Brightness optimization for perfect exposure');
168
+ }
169
+ if (config.enhancementType === 'contrast' || config.enhancementType === 'all') {
170
+ enhancements.push('- Contrast enhancement for dynamic range');
171
+ }
172
+ if (config.enhancementType === 'saturation' || config.enhancementType === 'all') {
173
+ enhancements.push('- Saturation adjustment for color vibrancy');
174
+ }
175
+ if (config.enhancementType === 'sharpness' || config.enhancementType === 'all') {
176
+ enhancements.push('- Sharpness improvement for detail clarity');
177
+ }
178
+
179
+ return enhancements.join('\n') || '- General image quality improvement';
180
+ }
181
+ }
@@ -0,0 +1,160 @@
1
+ import type { IPhotoRestorationService } from '../../domain/repositories/IAIPromptServices';
2
+ import type {
3
+ PhotoRestorationConfig,
4
+ } from '../../domain/entities/PhotoRestorationConfig';
5
+ import type { AIPromptTemplate } from '../../domain/entities/AIPromptTemplate';
6
+ import type { AIPromptResult } from '../../domain/entities/types';
7
+ import { createAIPromptTemplate } from '../../domain/entities/AIPromptTemplate';
8
+ import { validatePhotoRestorationConfig, getQualityLevel } from '../../domain/entities/PhotoRestorationConfig';
9
+ import { PromptGenerationService } from '../services/PromptGenerationService';
10
+
11
+ const createPhotoRestorationBaseTemplate = (config?: {
12
+ targetQuality?: string;
13
+ preserveOriginal?: boolean;
14
+ }): string => {
15
+ const {
16
+ targetQuality = 'high-quality',
17
+ preserveOriginal = true
18
+ } = config || {};
19
+
20
+ return `
21
+ You are an expert AI photo restoration specialist.
22
+ This is a PHOTO RESTORATION task, not image generation.
23
+
24
+ RESTORATION OBJECTIVES:
25
+ - Restore the original photo to ${targetQuality} condition
26
+ - ${preserveOriginal ? 'Preserve the original content and composition' : 'Enhance with creative improvements'}
27
+ - Remove imperfections while maintaining authenticity
28
+ - Recover lost details and enhance overall quality
29
+
30
+ RESTORATION TECHNIQUES:
31
+ - Noise reduction and grain removal
32
+ - Scratch and damage repair
33
+ - Color correction and enhancement
34
+ - Detail sharpening and clarity improvement
35
+ - Exposure and contrast adjustment
36
+
37
+ SAFETY CONSTRAINTS:
38
+ - Do not add content that wasn't originally present
39
+ - Maintain the original subject and composition
40
+ - Avoid over-processing that creates unnatural results
41
+ - Preserve important details and textures
42
+
43
+ QUALITY STANDARDS:
44
+ - Natural, authentic appearance
45
+ - Balanced color reproduction
46
+ - Appropriate level of detail enhancement
47
+ - Clean, professional-grade result
48
+
49
+ OUTPUT:
50
+ A beautifully restored version of the original photo,
51
+ maintaining its character while significantly improving quality.
52
+ `.trim();
53
+ };
54
+
55
+ export class PhotoRestorationService implements IPhotoRestorationService {
56
+ private promptService: PromptGenerationService;
57
+
58
+ constructor() {
59
+ this.promptService = new PromptGenerationService();
60
+ }
61
+
62
+ async generateTemplate(config: PhotoRestorationConfig): Promise<AIPromptResult<AIPromptTemplate>> {
63
+ try {
64
+ if (!this.validateConfig(config)) {
65
+ return {
66
+ success: false,
67
+ error: 'VALIDATION_ERROR',
68
+ message: 'Invalid photo restoration configuration'
69
+ };
70
+ }
71
+
72
+ const template = this.createPhotoRestorationTemplate(config);
73
+ return { success: true, data: template };
74
+ } catch (error) {
75
+ return {
76
+ success: false,
77
+ error: 'GENERATION_FAILED',
78
+ message: 'Failed to generate photo restoration template'
79
+ };
80
+ }
81
+ }
82
+
83
+ async generatePrompt(
84
+ template: AIPromptTemplate,
85
+ config: PhotoRestorationConfig
86
+ ): Promise<AIPromptResult<string>> {
87
+ const variables = {
88
+ severity: config.severity,
89
+ preserveOriginal: config.preserveOriginal,
90
+ enhanceColors: config.enhanceColors,
91
+ removeNoise: config.removeNoise,
92
+ fixBlur: config.fixBlur,
93
+ restoreDetails: config.restoreDetails,
94
+ qualityLevel: getQualityLevel(config.severity),
95
+ };
96
+
97
+ return this.promptService.generateFromTemplate(template, variables);
98
+ }
99
+
100
+ validateConfig(config: PhotoRestorationConfig): boolean {
101
+ return validatePhotoRestorationConfig(config);
102
+ }
103
+
104
+ estimateQuality(config: PhotoRestorationConfig): number {
105
+ let quality = 0.8;
106
+
107
+ if (config.restoreDetails) quality += 0.1;
108
+ if (config.enhanceColors) quality += 0.05;
109
+ if (config.removeNoise) quality += 0.05;
110
+
111
+ const severityMultiplier = getQualityLevel(config.severity);
112
+ return Math.min(quality * severityMultiplier, 1.0);
113
+ }
114
+
115
+ private createPhotoRestorationTemplate(config: PhotoRestorationConfig): AIPromptTemplate {
116
+ const templateId = `photo-restoration-${config.severity}`;
117
+ const qualityDesc = config.severity === 'minor' ? 'subtle restoration' :
118
+ config.severity === 'moderate' ? 'standard restoration' :
119
+ 'deep restoration';
120
+
121
+ const baseTemplate = createPhotoRestorationBaseTemplate({
122
+ targetQuality: qualityDesc,
123
+ preserveOriginal: config.preserveOriginal,
124
+ });
125
+
126
+ return createAIPromptTemplate({
127
+ id: templateId,
128
+ name: `Photo Restoration: ${config.severity}`,
129
+ description: `Restore photos with ${qualityDesc}`,
130
+ category: 'photo-restoration',
131
+ template: `${baseTemplate}
132
+
133
+ RESTORATION SEVERITY:
134
+ ${config.severity}
135
+
136
+ SPECIFIC REQUIREMENTS:
137
+ - ${config.removeNoise ? 'Remove noise and grain' : 'Maintain texture character'}
138
+ - ${config.fixBlur ? 'Fix blur and sharpen details' : 'Preserve original sharpness'}
139
+ - ${config.enhanceColors ? 'Enhance color vibrancy' : 'Maintain original colors'}
140
+ - ${config.restoreDetails ? 'Recover lost details' : 'Preserve current detail level'}
141
+
142
+ QUALITY TARGET:
143
+ ${getQualityLevel(config.severity) * 100}% quality improvement expected.
144
+
145
+ OUTPUT:
146
+ A professionally restored photo with ${qualityDesc},
147
+ ready for display or further processing.
148
+ `.trim(),
149
+ variables: [],
150
+ safety: {
151
+ contentFilter: true,
152
+ adultContentFilter: true,
153
+ violenceFilter: true,
154
+ hateSpeechFilter: true,
155
+ copyrightFilter: true,
156
+ },
157
+ version: '1.0.0',
158
+ });
159
+ }
160
+ }
@@ -0,0 +1,59 @@
1
+ import type { IPromptGenerationService } from '../../domain/repositories/IAIPromptServices';
2
+ import type { AIPromptTemplate } from '../../domain/entities/AIPromptTemplate';
3
+ import type { AIPromptResult, AIPromptError } from '../../domain/entities/types';
4
+
5
+ export class PromptGenerationService implements IPromptGenerationService {
6
+ generateFromTemplate(
7
+ template: AIPromptTemplate,
8
+ variables: Record<string, unknown>
9
+ ): Promise<AIPromptResult<string>> {
10
+ return new Promise((resolve) => {
11
+ try {
12
+ const validation = this.validateVariables(template, variables);
13
+ if (!validation.success) {
14
+ resolve(validation as AIPromptResult<string>);
15
+ return;
16
+ }
17
+
18
+ const generatedText = this.replaceTemplateVariables(template.template, variables);
19
+ resolve({ success: true, data: generatedText });
20
+ } catch (error) {
21
+ resolve({
22
+ success: false,
23
+ error: 'GENERATION_FAILED',
24
+ message: 'Failed to generate prompt'
25
+ });
26
+ }
27
+ });
28
+ }
29
+
30
+ validateVariables(
31
+ template: AIPromptTemplate,
32
+ variables: Record<string, unknown>
33
+ ): AIPromptResult<void> {
34
+ for (const variable of template.variables) {
35
+ if (variable.required && !(variable.name in variables)) {
36
+ return {
37
+ success: false,
38
+ error: 'INVALID_VARIABLES',
39
+ message: `Required variable ${variable.name} is missing`
40
+ };
41
+ }
42
+ }
43
+ return { success: true, data: undefined };
44
+ }
45
+
46
+ replaceTemplateVariables(
47
+ template: string,
48
+ variables: Record<string, unknown>
49
+ ): string {
50
+ let result = template;
51
+
52
+ Object.entries(variables).forEach(([key, value]) => {
53
+ const regex = new RegExp(`\\$\\{${key}\\}`, 'g');
54
+ result = result.replace(regex, String(value || ''));
55
+ });
56
+
57
+ return result;
58
+ }
59
+ }
@@ -0,0 +1,194 @@
1
+ import type { IStyleTransferService } from '../../domain/repositories/IAIPromptServices';
2
+ import type {
3
+ StyleTransferConfig,
4
+ } from '../../domain/entities/StyleTransferConfig';
5
+ import type { AIPromptTemplate } from '../../domain/entities/AIPromptTemplate';
6
+ import type { AIPromptResult } from '../../domain/entities/types';
7
+ import { createAIPromptTemplate } from '../../domain/entities/AIPromptTemplate';
8
+ import {
9
+ validateStyleTransferConfig,
10
+ getStyleStrengthValue,
11
+ getArtisticModeDescription
12
+ } from '../../domain/entities/StyleTransferConfig';
13
+ import { PromptGenerationService } from '../services/PromptGenerationService';
14
+
15
+ const createStyleTransferBaseTemplate = (config?: {
16
+ artisticMode?: string;
17
+ preserveContent?: boolean;
18
+ }): string => {
19
+ const {
20
+ artisticMode = 'artistic',
21
+ preserveContent = true
22
+ } = config || {};
23
+
24
+ return `
25
+ You are an expert AI style transfer specialist.
26
+ This is a STYLE TRANSFER task, applying artistic styles while maintaining content.
27
+
28
+ STYLE TRANSFER PRINCIPLES:
29
+ - Apply target artistic style to the image
30
+ - ${preserveContent ? 'Preserve original content and composition' : 'Allow creative reinterpretation'}
31
+ - Maintain key features and subject recognition
32
+ - Balance artistic expression with clarity
33
+
34
+ ARTISTIC MODE: ${artisticMode}
35
+ ${getArtisticModeDescription(artisticMode as StyleTransferConfig['artisticMode'])}
36
+
37
+ STYLE APPLICATION GUIDELINES:
38
+ - Recognize and preserve important elements
39
+ - Apply consistent style throughout the image
40
+ - Maintain appropriate color relationships
41
+ - Preserve facial features and expressions when present
42
+
43
+ TECHNICAL REQUIREMENTS:
44
+ - Smooth style transitions across the image
45
+ - Appropriate detail preservation based on style
46
+ - Consistent artistic treatment
47
+ - Professional quality output
48
+
49
+ CONTENT PRESERVATION:
50
+ ${preserveContent ?
51
+ '- Maintain key shapes and forms\n- Preserve facial features and expressions\n- Keep text readable if present\n- Maintain spatial relationships' :
52
+ '- Allow creative transformation\n- Artistic interpretation encouraged\n- Style over content fidelity'}
53
+
54
+ SAFETY CONSTRAINTS:
55
+ - Do not add inappropriate elements
56
+ - Maintain appropriate content standards
57
+ - Preserve important visual information
58
+ - Avoid destructive transformations
59
+
60
+ OUTPUT:
61
+ A beautifully stylized image with the target artistic style,
62
+ ${preserveContent ? 'maintaining content integrity' : 'with artistic freedom'}.
63
+ `.trim();
64
+ };
65
+
66
+ export class StyleTransferService implements IStyleTransferService {
67
+ private promptService: PromptGenerationService;
68
+ private availableStyles: string[] = [];
69
+
70
+ constructor() {
71
+ this.promptService = new PromptGenerationService();
72
+ this.initializeDefaultStyles();
73
+ }
74
+
75
+ async generateTemplate(config: StyleTransferConfig): Promise<AIPromptResult<AIPromptTemplate>> {
76
+ try {
77
+ if (!this.validateConfig(config)) {
78
+ return {
79
+ success: false,
80
+ error: 'VALIDATION_ERROR',
81
+ message: 'Invalid style transfer configuration'
82
+ };
83
+ }
84
+
85
+ const template = this.createStyleTransferTemplate(config);
86
+ return { success: true, data: template };
87
+ } catch (error) {
88
+ return {
89
+ success: false,
90
+ error: 'GENERATION_FAILED',
91
+ message: 'Failed to generate style transfer template'
92
+ };
93
+ }
94
+ }
95
+
96
+ async generatePrompt(
97
+ template: AIPromptTemplate,
98
+ config: StyleTransferConfig
99
+ ): Promise<AIPromptResult<string>> {
100
+ const variables = {
101
+ targetStyle: config.targetStyle,
102
+ preserveContent: config.preserveContent,
103
+ styleStrength: config.styleStrength,
104
+ artisticMode: config.artisticMode,
105
+ maintainColors: config.maintainColors,
106
+ adaptToSubject: config.adaptToSubject,
107
+ strengthLevel: getStyleStrengthValue(config.styleStrength),
108
+ };
109
+
110
+ return this.promptService.generateFromTemplate(template, variables);
111
+ }
112
+
113
+ validateConfig(config: StyleTransferConfig): boolean {
114
+ return validateStyleTransferConfig(config);
115
+ }
116
+
117
+ async getAvailableStyles(): Promise<string[]> {
118
+ return Promise.resolve([...this.availableStyles]);
119
+ }
120
+
121
+ registerStyle(style: string): void {
122
+ if (!this.availableStyles.includes(style)) {
123
+ this.availableStyles.push(style);
124
+ }
125
+ }
126
+
127
+ registerStyles(styles: string[]): void {
128
+ styles.forEach(style => this.registerStyle(style));
129
+ }
130
+
131
+ private initializeDefaultStyles(): void {
132
+ this.availableStyles = [
133
+ 'Impressionism',
134
+ 'Cubism',
135
+ 'Surrealism',
136
+ 'Pop Art',
137
+ 'Watercolor',
138
+ 'Oil Painting',
139
+ 'Pencil Sketch',
140
+ 'Anime/Manga',
141
+ 'Vintage Film',
142
+ 'Cyberpunk',
143
+ 'Steampunk',
144
+ ];
145
+ }
146
+
147
+ private createStyleTransferTemplate(config: StyleTransferConfig): AIPromptTemplate {
148
+ const templateId = `style-transfer-${config.targetStyle.toLowerCase().replace(/\s+/g, '-')}`;
149
+
150
+ const baseTemplate = createStyleTransferBaseTemplate({
151
+ artisticMode: config.artisticMode,
152
+ preserveContent: config.preserveContent,
153
+ });
154
+
155
+ return createAIPromptTemplate({
156
+ id: templateId,
157
+ name: `Style Transfer: ${config.targetStyle}`,
158
+ description: `Apply ${config.targetStyle} artistic style with ${config.artisticMode} mode`,
159
+ category: 'style-transfer',
160
+ template: `${baseTemplate}
161
+
162
+ TARGET STYLE:
163
+ ${config.targetStyle}
164
+
165
+ STYLE TRANSFER PARAMETERS:
166
+ - Style Strength: ${getStyleStrengthValue(config.styleStrength)} (${Math.round(config.styleStrength * 100)}%)
167
+ - Artistic Mode: ${config.artisticMode}
168
+ - Preserve Content: ${config.preserveContent}
169
+ - Maintain Colors: ${config.maintainColors}
170
+ - Adapt to Subject: ${config.adaptToSubject}
171
+
172
+ STYLE APPLICATION INSTRUCTIONS:
173
+ Apply ${config.targetStyle} style with ${config.artisticMode} interpretation,
174
+ using ${getStyleStrengthValue(config.styleStrength)} strength level.
175
+ ${config.preserveContent ? 'Focus on preserving content integrity while applying style.' : 'Allow artistic interpretation and transformation.'}
176
+ ${config.maintainColors ? 'Maintain original color palette where appropriate.' : 'Allow color changes to enhance style.'}
177
+
178
+ EXPECTED RESULT:
179
+ A beautifully stylized image in ${config.targetStyle} style,
180
+ with ${config.artisticMode} artistic interpretation,
181
+ using ${getStyleStrengthValue(config.styleStrength)} strength application.
182
+ `.trim(),
183
+ variables: [],
184
+ safety: {
185
+ contentFilter: true,
186
+ adultContentFilter: true,
187
+ violenceFilter: true,
188
+ hateSpeechFilter: true,
189
+ copyrightFilter: true,
190
+ },
191
+ version: '1.0.0',
192
+ });
193
+ }
194
+ }