@umituz/react-native-ai-generation-content 1.12.21 → 1.12.23
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 +33 -15
- package/src/domains/content-moderation/infrastructure/services/content-moderation.service.ts +4 -32
- package/src/domains/content-moderation/infrastructure/services/moderators/base.moderator.ts +1 -1
- package/src/domains/face-detection/infrastructure/validators/faceValidator.ts +1 -1
- package/src/domains/face-detection/presentation/components/FaceValidationStatus.tsx +3 -3
- package/src/domains/feature-background/presentation/components/BackgroundFeature.tsx +5 -4
- package/src/domains/feature-background/presentation/components/ComparisonSlider.tsx +45 -51
- package/src/domains/feature-background/presentation/components/ErrorDisplay.tsx +5 -3
- package/src/domains/feature-background/presentation/components/ModeSelector.tsx +2 -2
- package/src/domains/feature-background/presentation/hooks/useBackgroundFeature.ts +3 -2
- package/src/domains/prompts/domain/entities/FuturePredictionConfig.ts +2 -1
- package/src/domains/prompts/domain/entities/GeneratedPrompt.ts +0 -1
- package/src/domains/prompts/domain/repositories/IAIPromptServices.ts +6 -12
- package/src/domains/prompts/infrastructure/repositories/PromptHistoryRepository.ts +42 -42
- package/src/domains/prompts/infrastructure/repositories/TemplateRepository.ts +42 -42
- package/src/domains/prompts/infrastructure/services/BackgroundRemovalService.ts +7 -7
- package/src/domains/prompts/infrastructure/services/ColorizationService.ts +7 -7
- package/src/domains/prompts/infrastructure/services/FaceSwapService.ts +19 -20
- package/src/domains/prompts/infrastructure/services/FuturePredictionService.ts +11 -31
- package/src/domains/prompts/infrastructure/services/ImageEnhancementService.ts +7 -7
- package/src/domains/prompts/infrastructure/services/PhotoRestorationService.ts +7 -7
- package/src/domains/prompts/infrastructure/services/PromptGenerationService.ts +13 -13
- package/src/domains/prompts/infrastructure/services/StyleTransferService.ts +8 -8
- package/src/domains/prompts/infrastructure/services/TextGenerationService.ts +7 -7
- package/src/domains/prompts/presentation/hooks/useAIServices.ts +30 -28
- package/src/domains/prompts/presentation/hooks/useFaceSwap.ts +1 -2
- package/src/domains/prompts/presentation/hooks/usePromptGeneration.ts +4 -5
- package/src/domains/prompts/presentation/hooks/useStyleTransfer.ts +1 -1
- package/src/domains/prompts/presentation/hooks/useTemplateRepository.ts +3 -3
- package/src/domains/prompts/presentation/theme/utils.ts +1 -1
- package/src/index.ts +0 -5
- package/src/infrastructure/utils/status-checker.util.ts +4 -4
- package/src/infrastructure/wrappers/synchronous-generation.wrapper.ts +3 -3
- package/src/presentation/components/result/GenerationResultContent.tsx +21 -22
- package/src/presentation/components/result/ResultActions.tsx +51 -52
- package/src/presentation/components/result/ResultHeader.tsx +24 -25
- package/src/presentation/components/result/ResultImageCard.tsx +19 -20
- package/src/presentation/components/result/ResultStoryCard.tsx +23 -24
- package/src/presentation/hooks/photo-generation.types.ts +4 -4
- package/src/presentation/hooks/usePhotoGeneration.ts +18 -13
- package/src/domains/creations/application/services/CreationsService.ts +0 -72
- package/src/domains/creations/domain/entities/Creation.ts +0 -54
- package/src/domains/creations/domain/entities/index.ts +0 -6
- package/src/domains/creations/domain/repositories/ICreationsRepository.ts +0 -25
- package/src/domains/creations/domain/repositories/index.ts +0 -5
- package/src/domains/creations/domain/services/ICreationsStorageService.ts +0 -13
- package/src/domains/creations/domain/value-objects/CreationsConfig.ts +0 -77
- package/src/domains/creations/domain/value-objects/index.ts +0 -12
- package/src/domains/creations/index.ts +0 -84
- package/src/domains/creations/infrastructure/adapters/createRepository.ts +0 -54
- package/src/domains/creations/infrastructure/adapters/index.ts +0 -5
- package/src/domains/creations/infrastructure/repositories/CreationsRepository.ts +0 -263
- package/src/domains/creations/infrastructure/repositories/index.ts +0 -8
- package/src/domains/creations/infrastructure/services/CreationsStorageService.ts +0 -48
- package/src/domains/creations/presentation/components/CreationCard.tsx +0 -196
- package/src/domains/creations/presentation/components/CreationDetail/DetailActions.tsx +0 -76
- package/src/domains/creations/presentation/components/CreationDetail/DetailHeader.tsx +0 -81
- package/src/domains/creations/presentation/components/CreationDetail/DetailImage.tsx +0 -41
- package/src/domains/creations/presentation/components/CreationDetail/DetailStory.tsx +0 -67
- package/src/domains/creations/presentation/components/CreationDetail/index.ts +0 -4
- package/src/domains/creations/presentation/components/CreationImageViewer.tsx +0 -101
- package/src/domains/creations/presentation/components/CreationThumbnail.tsx +0 -63
- package/src/domains/creations/presentation/components/CreationsGalleryEmptyState.tsx +0 -77
- package/src/domains/creations/presentation/components/CreationsGrid.tsx +0 -87
- package/src/domains/creations/presentation/components/CreationsHomeCard.tsx +0 -176
- package/src/domains/creations/presentation/components/EmptyState.tsx +0 -75
- package/src/domains/creations/presentation/components/FilterBottomSheet.tsx +0 -157
- package/src/domains/creations/presentation/components/FilterChips.tsx +0 -105
- package/src/domains/creations/presentation/components/GalleryHeader.tsx +0 -157
- package/src/domains/creations/presentation/components/index.ts +0 -20
- package/src/domains/creations/presentation/hooks/index.ts +0 -9
- package/src/domains/creations/presentation/hooks/useCreations.ts +0 -33
- package/src/domains/creations/presentation/hooks/useCreationsFilter.ts +0 -90
- package/src/domains/creations/presentation/hooks/useDeleteCreation.ts +0 -51
- package/src/domains/creations/presentation/hooks/useDeleteMultipleCreations.ts +0 -57
- package/src/domains/creations/presentation/hooks/useToggleFavorite.ts +0 -59
- package/src/domains/creations/presentation/screens/CreationDetailScreen.tsx +0 -71
- package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +0 -264
- package/src/domains/creations/presentation/screens/index.ts +0 -5
- package/src/domains/creations/presentation/utils/filterUtils.ts +0 -52
- package/src/domains/creations/types.d.ts +0 -107
|
@@ -5,73 +5,73 @@ import type { AIPromptCategory, AIPromptResult } from '../../domain/entities/typ
|
|
|
5
5
|
export class TemplateRepository implements ITemplateRepository {
|
|
6
6
|
private storage = new Map<string, AIPromptTemplate>();
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
findById(id: string): Promise<AIPromptResult<AIPromptTemplate | null>> {
|
|
9
9
|
try {
|
|
10
10
|
const template = this.storage.get(id) || null;
|
|
11
|
-
return { success: true, data: template };
|
|
12
|
-
} catch
|
|
13
|
-
return {
|
|
14
|
-
success: false,
|
|
15
|
-
error: 'STORAGE_ERROR',
|
|
16
|
-
message: 'Failed to retrieve template'
|
|
17
|
-
};
|
|
11
|
+
return Promise.resolve({ success: true, data: template });
|
|
12
|
+
} catch {
|
|
13
|
+
return Promise.resolve({
|
|
14
|
+
success: false,
|
|
15
|
+
error: 'STORAGE_ERROR',
|
|
16
|
+
message: 'Failed to retrieve template'
|
|
17
|
+
});
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
findByCategory(category: AIPromptCategory): Promise<AIPromptResult<AIPromptTemplate[]>> {
|
|
22
22
|
try {
|
|
23
23
|
const templates = Array.from(this.storage.values())
|
|
24
24
|
.filter(template => template.category === category);
|
|
25
|
-
return { success: true, data: templates };
|
|
26
|
-
} catch
|
|
27
|
-
return {
|
|
28
|
-
success: false,
|
|
29
|
-
error: 'STORAGE_ERROR',
|
|
30
|
-
message: 'Failed to retrieve templates by category'
|
|
31
|
-
};
|
|
25
|
+
return Promise.resolve({ success: true, data: templates });
|
|
26
|
+
} catch {
|
|
27
|
+
return Promise.resolve({
|
|
28
|
+
success: false,
|
|
29
|
+
error: 'STORAGE_ERROR',
|
|
30
|
+
message: 'Failed to retrieve templates by category'
|
|
31
|
+
});
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
findAll(): Promise<AIPromptResult<AIPromptTemplate[]>> {
|
|
36
36
|
try {
|
|
37
37
|
const templates = Array.from(this.storage.values());
|
|
38
|
-
return { success: true, data: templates };
|
|
39
|
-
} catch
|
|
40
|
-
return {
|
|
41
|
-
success: false,
|
|
42
|
-
error: 'STORAGE_ERROR',
|
|
43
|
-
message: 'Failed to retrieve all templates'
|
|
44
|
-
};
|
|
38
|
+
return Promise.resolve({ success: true, data: templates });
|
|
39
|
+
} catch {
|
|
40
|
+
return Promise.resolve({
|
|
41
|
+
success: false,
|
|
42
|
+
error: 'STORAGE_ERROR',
|
|
43
|
+
message: 'Failed to retrieve all templates'
|
|
44
|
+
});
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
save(template: AIPromptTemplate): Promise<AIPromptResult<void>> {
|
|
49
49
|
try {
|
|
50
50
|
this.storage.set(template.id, template);
|
|
51
|
-
return { success: true, data: undefined };
|
|
52
|
-
} catch
|
|
53
|
-
return {
|
|
54
|
-
success: false,
|
|
55
|
-
error: 'STORAGE_ERROR',
|
|
56
|
-
message: 'Failed to save template'
|
|
57
|
-
};
|
|
51
|
+
return Promise.resolve({ success: true, data: undefined });
|
|
52
|
+
} catch {
|
|
53
|
+
return Promise.resolve({
|
|
54
|
+
success: false,
|
|
55
|
+
error: 'STORAGE_ERROR',
|
|
56
|
+
message: 'Failed to save template'
|
|
57
|
+
});
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
delete(id: string): Promise<AIPromptResult<void>> {
|
|
62
62
|
try {
|
|
63
63
|
this.storage.delete(id);
|
|
64
|
-
return { success: true, data: undefined };
|
|
65
|
-
} catch
|
|
66
|
-
return {
|
|
67
|
-
success: false,
|
|
68
|
-
error: 'STORAGE_ERROR',
|
|
69
|
-
message: 'Failed to delete template'
|
|
70
|
-
};
|
|
64
|
+
return Promise.resolve({ success: true, data: undefined });
|
|
65
|
+
} catch {
|
|
66
|
+
return Promise.resolve({
|
|
67
|
+
success: false,
|
|
68
|
+
error: 'STORAGE_ERROR',
|
|
69
|
+
message: 'Failed to delete template'
|
|
70
|
+
});
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
return this.storage.has(id);
|
|
74
|
+
exists(id: string): Promise<boolean> {
|
|
75
|
+
return Promise.resolve(this.storage.has(id));
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -83,24 +83,24 @@ export class BackgroundRemovalService implements IBackgroundRemovalService {
|
|
|
83
83
|
this.promptService = new PromptGenerationService();
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
generateTemplate(config: BackgroundRemovalConfig): Promise<AIPromptResult<AIPromptTemplate>> {
|
|
87
87
|
try {
|
|
88
88
|
if (!this.validateConfig(config)) {
|
|
89
|
-
return {
|
|
89
|
+
return Promise.resolve({
|
|
90
90
|
success: false,
|
|
91
91
|
error: 'VALIDATION_ERROR',
|
|
92
92
|
message: 'Invalid background removal configuration'
|
|
93
|
-
};
|
|
93
|
+
});
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
const template = this.createBackgroundRemovalTemplate(config);
|
|
97
|
-
return { success: true, data: template };
|
|
98
|
-
} catch
|
|
99
|
-
return {
|
|
97
|
+
return Promise.resolve({ success: true, data: template });
|
|
98
|
+
} catch {
|
|
99
|
+
return Promise.resolve({
|
|
100
100
|
success: false,
|
|
101
101
|
error: 'GENERATION_FAILED',
|
|
102
102
|
message: 'Failed to generate background removal template'
|
|
103
|
-
};
|
|
103
|
+
});
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -87,24 +87,24 @@ export class ColorizationService implements IColorizationService {
|
|
|
87
87
|
this.promptService = new PromptGenerationService();
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
generateTemplate(config: ColorizationConfig): Promise<AIPromptResult<AIPromptTemplate>> {
|
|
91
91
|
try {
|
|
92
92
|
if (!this.validateConfig(config)) {
|
|
93
|
-
return {
|
|
93
|
+
return Promise.resolve({
|
|
94
94
|
success: false,
|
|
95
95
|
error: 'VALIDATION_ERROR',
|
|
96
96
|
message: 'Invalid colorization configuration'
|
|
97
|
-
};
|
|
97
|
+
});
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
const template = this.createColorizationTemplate(config);
|
|
101
|
-
return { success: true, data: template };
|
|
102
|
-
} catch
|
|
103
|
-
return {
|
|
101
|
+
return Promise.resolve({ success: true, data: template });
|
|
102
|
+
} catch {
|
|
103
|
+
return Promise.resolve({
|
|
104
104
|
success: false,
|
|
105
105
|
error: 'GENERATION_FAILED',
|
|
106
106
|
message: 'Failed to generate colorization template'
|
|
107
|
-
};
|
|
107
|
+
});
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { IFaceSwapService } from '../../domain/repositories/IAIPromptServices';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
3
|
AIPromptTemplate
|
|
4
4
|
} from '../../domain/entities/AIPromptTemplate';
|
|
5
|
-
import type {
|
|
6
|
-
FaceSwapConfig,
|
|
7
|
-
FaceSwapGenerationResult,
|
|
5
|
+
import type {
|
|
6
|
+
FaceSwapConfig,
|
|
8
7
|
FaceSwapSafety
|
|
9
8
|
} from '../../domain/entities/FaceSwapConfig';
|
|
10
9
|
import type { AIPromptCategory } from '../../domain/entities/types';
|
|
@@ -82,29 +81,29 @@ export class FaceSwapService implements IFaceSwapService {
|
|
|
82
81
|
this.initializeDefaultStyles();
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
|
|
84
|
+
generateTemplate(config: FaceSwapConfig): Promise<AIPromptResult<AIPromptTemplate>> {
|
|
86
85
|
try {
|
|
87
86
|
if (!this.validateConfig(config)) {
|
|
88
|
-
return {
|
|
89
|
-
success: false,
|
|
90
|
-
error: 'INVALID_VARIABLES',
|
|
91
|
-
message: 'Invalid face swap configuration'
|
|
92
|
-
};
|
|
87
|
+
return Promise.resolve({
|
|
88
|
+
success: false,
|
|
89
|
+
error: 'INVALID_VARIABLES',
|
|
90
|
+
message: 'Invalid face swap configuration'
|
|
91
|
+
});
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
const template = this.createFaceSwapTemplate(config);
|
|
96
|
-
return { success: true, data: template };
|
|
97
|
-
} catch
|
|
98
|
-
return {
|
|
99
|
-
success: false,
|
|
100
|
-
error: 'GENERATION_FAILED',
|
|
101
|
-
message: 'Failed to generate face swap template'
|
|
102
|
-
};
|
|
95
|
+
return Promise.resolve({ success: true, data: template });
|
|
96
|
+
} catch {
|
|
97
|
+
return Promise.resolve({
|
|
98
|
+
success: false,
|
|
99
|
+
error: 'GENERATION_FAILED',
|
|
100
|
+
message: 'Failed to generate face swap template'
|
|
101
|
+
});
|
|
103
102
|
}
|
|
104
103
|
}
|
|
105
104
|
|
|
106
105
|
async generatePrompt(
|
|
107
|
-
template: AIPromptTemplate,
|
|
106
|
+
template: AIPromptTemplate,
|
|
108
107
|
config: FaceSwapConfig
|
|
109
108
|
): Promise<AIPromptResult<string>> {
|
|
110
109
|
const variables = {
|
|
@@ -123,7 +122,7 @@ export class FaceSwapService implements IFaceSwapService {
|
|
|
123
122
|
return validateFaceSwapConfig(config);
|
|
124
123
|
}
|
|
125
124
|
|
|
126
|
-
|
|
125
|
+
getAvailableStyles(): Promise<string[]> {
|
|
127
126
|
return Promise.resolve([...this.availableStyles]);
|
|
128
127
|
}
|
|
129
128
|
|
|
@@ -147,7 +146,7 @@ export class FaceSwapService implements IFaceSwapService {
|
|
|
147
146
|
|
|
148
147
|
private createFaceSwapTemplate(config: FaceSwapConfig): AIPromptTemplate {
|
|
149
148
|
const templateId = `face-swap-${config.styleName.toLowerCase().replace(/\s+/g, '-')}`;
|
|
150
|
-
|
|
149
|
+
|
|
151
150
|
return createAIPromptTemplate({
|
|
152
151
|
id: templateId,
|
|
153
152
|
name: `Face Swap: ${config.styleName}`,
|
|
@@ -96,36 +96,36 @@ export class FuturePredictionService implements IFuturePredictionService {
|
|
|
96
96
|
this.promptService = new PromptGenerationService();
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
generateTemplate(
|
|
100
100
|
config: FuturePredictionConfig
|
|
101
101
|
): Promise<AIPromptResult<AIPromptTemplate>> {
|
|
102
102
|
if (!this.validateConfig(config)) {
|
|
103
|
-
return {
|
|
103
|
+
return Promise.resolve({
|
|
104
104
|
success: false,
|
|
105
105
|
error: 'VALIDATION_ERROR',
|
|
106
106
|
message: 'Invalid future prediction configuration',
|
|
107
|
-
};
|
|
107
|
+
});
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
const template = this.createTemplate(config);
|
|
111
|
-
return { success: true, data: template };
|
|
111
|
+
return Promise.resolve({ success: true, data: template });
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
generatePrompts(
|
|
115
115
|
config: FuturePredictionConfig
|
|
116
116
|
): Promise<AIPromptResult<FuturePredictionResult>> {
|
|
117
117
|
if (!this.validateConfig(config)) {
|
|
118
|
-
return {
|
|
118
|
+
return Promise.resolve({
|
|
119
119
|
success: false,
|
|
120
120
|
error: 'VALIDATION_ERROR',
|
|
121
121
|
message: 'Invalid configuration',
|
|
122
|
-
};
|
|
122
|
+
});
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
const imagePrompt = this.buildImagePrompt(config);
|
|
126
126
|
const storyPrompt = this.buildStoryPrompt(config);
|
|
127
127
|
|
|
128
|
-
return {
|
|
128
|
+
return Promise.resolve({
|
|
129
129
|
success: true,
|
|
130
130
|
data: {
|
|
131
131
|
imagePrompt,
|
|
@@ -137,7 +137,7 @@ export class FuturePredictionService implements IFuturePredictionService {
|
|
|
137
137
|
generatedAt: Date.now(),
|
|
138
138
|
},
|
|
139
139
|
},
|
|
140
|
-
};
|
|
140
|
+
});
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
validateConfig(config: FuturePredictionConfig): boolean {
|
|
@@ -171,10 +171,10 @@ export class FuturePredictionService implements IFuturePredictionService {
|
|
|
171
171
|
.replace(/{{promptModifier}}/g, config.promptModifier)
|
|
172
172
|
.replace(/{{futureYear}}/g, String(futureYear));
|
|
173
173
|
|
|
174
|
-
if (config.settings.
|
|
174
|
+
if (config.settings.languageName) {
|
|
175
175
|
prompt = prompt.replace(
|
|
176
176
|
/{{#if language}}(.*?){{\/if}}/g,
|
|
177
|
-
`$1`.replace(/{{language}}/g,
|
|
177
|
+
`$1`.replace(/{{language}}/g, config.settings.languageName)
|
|
178
178
|
);
|
|
179
179
|
} else {
|
|
180
180
|
prompt = prompt.replace(/{{#if language}}.*?{{\/if}}/g, '');
|
|
@@ -201,24 +201,4 @@ export class FuturePredictionService implements IFuturePredictionService {
|
|
|
201
201
|
version: '1.0.0',
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
|
-
|
|
205
|
-
private getLanguageName(code: string): string {
|
|
206
|
-
const languages: Record<string, string> = {
|
|
207
|
-
tr: 'Turkish',
|
|
208
|
-
es: 'Spanish',
|
|
209
|
-
fr: 'French',
|
|
210
|
-
de: 'German',
|
|
211
|
-
it: 'Italian',
|
|
212
|
-
pt: 'Portuguese',
|
|
213
|
-
ru: 'Russian',
|
|
214
|
-
ja: 'Japanese',
|
|
215
|
-
ko: 'Korean',
|
|
216
|
-
zh: 'Chinese',
|
|
217
|
-
ar: 'Arabic',
|
|
218
|
-
hi: 'Hindi',
|
|
219
|
-
th: 'Thai',
|
|
220
|
-
vi: 'Vietnamese',
|
|
221
|
-
};
|
|
222
|
-
return languages[code] || 'English';
|
|
223
|
-
}
|
|
224
204
|
}
|
|
@@ -67,24 +67,24 @@ export class ImageEnhancementService implements IImageEnhancementService {
|
|
|
67
67
|
this.promptService = new PromptGenerationService();
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
generateTemplate(config: ImageEnhancementConfig): Promise<AIPromptResult<AIPromptTemplate>> {
|
|
71
71
|
try {
|
|
72
72
|
if (!this.validateConfig(config)) {
|
|
73
|
-
return {
|
|
73
|
+
return Promise.resolve({
|
|
74
74
|
success: false,
|
|
75
75
|
error: 'VALIDATION_ERROR',
|
|
76
76
|
message: 'Invalid image enhancement configuration'
|
|
77
|
-
};
|
|
77
|
+
});
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
const template = this.createImageEnhancementTemplate(config);
|
|
81
|
-
return { success: true, data: template };
|
|
82
|
-
} catch
|
|
83
|
-
return {
|
|
81
|
+
return Promise.resolve({ success: true, data: template });
|
|
82
|
+
} catch {
|
|
83
|
+
return Promise.resolve({
|
|
84
84
|
success: false,
|
|
85
85
|
error: 'GENERATION_FAILED',
|
|
86
86
|
message: 'Failed to generate image enhancement template'
|
|
87
|
-
};
|
|
87
|
+
});
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -59,24 +59,24 @@ export class PhotoRestorationService implements IPhotoRestorationService {
|
|
|
59
59
|
this.promptService = new PromptGenerationService();
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
generateTemplate(config: PhotoRestorationConfig): Promise<AIPromptResult<AIPromptTemplate>> {
|
|
63
63
|
try {
|
|
64
64
|
if (!this.validateConfig(config)) {
|
|
65
|
-
return {
|
|
65
|
+
return Promise.resolve({
|
|
66
66
|
success: false,
|
|
67
67
|
error: 'VALIDATION_ERROR',
|
|
68
68
|
message: 'Invalid photo restoration configuration'
|
|
69
|
-
};
|
|
69
|
+
});
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
const template = this.createPhotoRestorationTemplate(config);
|
|
73
|
-
return { success: true, data: template };
|
|
74
|
-
} catch
|
|
75
|
-
return {
|
|
73
|
+
return Promise.resolve({ success: true, data: template });
|
|
74
|
+
} catch {
|
|
75
|
+
return Promise.resolve({
|
|
76
76
|
success: false,
|
|
77
77
|
error: 'GENERATION_FAILED',
|
|
78
78
|
message: 'Failed to generate photo restoration template'
|
|
79
|
-
};
|
|
79
|
+
});
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { IPromptGenerationService } from '../../domain/repositories/IAIPromptServices';
|
|
2
2
|
import type { AIPromptTemplate } from '../../domain/entities/AIPromptTemplate';
|
|
3
|
-
import type { AIPromptResult
|
|
3
|
+
import type { AIPromptResult } from '../../domain/entities/types';
|
|
4
4
|
|
|
5
5
|
export class PromptGenerationService implements IPromptGenerationService {
|
|
6
6
|
generateFromTemplate(
|
|
7
|
-
template: AIPromptTemplate,
|
|
7
|
+
template: AIPromptTemplate,
|
|
8
8
|
variables: Record<string, unknown>
|
|
9
9
|
): Promise<AIPromptResult<string>> {
|
|
10
10
|
return new Promise((resolve) => {
|
|
@@ -18,25 +18,25 @@ export class PromptGenerationService implements IPromptGenerationService {
|
|
|
18
18
|
const generatedText = this.replaceTemplateVariables(template.template, variables);
|
|
19
19
|
resolve({ success: true, data: generatedText });
|
|
20
20
|
} catch (error) {
|
|
21
|
-
resolve({
|
|
22
|
-
success: false,
|
|
23
|
-
error: 'GENERATION_FAILED',
|
|
24
|
-
message: 'Failed to generate prompt'
|
|
21
|
+
resolve({
|
|
22
|
+
success: false,
|
|
23
|
+
error: 'GENERATION_FAILED',
|
|
24
|
+
message: 'Failed to generate prompt'
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
validateVariables(
|
|
31
|
-
template: AIPromptTemplate,
|
|
31
|
+
template: AIPromptTemplate,
|
|
32
32
|
variables: Record<string, unknown>
|
|
33
33
|
): AIPromptResult<void> {
|
|
34
34
|
for (const variable of template.variables) {
|
|
35
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`
|
|
36
|
+
return {
|
|
37
|
+
success: false,
|
|
38
|
+
error: 'INVALID_VARIABLES',
|
|
39
|
+
message: `Required variable ${variable.name} is missing`
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -44,11 +44,11 @@ export class PromptGenerationService implements IPromptGenerationService {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
replaceTemplateVariables(
|
|
47
|
-
template: string,
|
|
47
|
+
template: string,
|
|
48
48
|
variables: Record<string, unknown>
|
|
49
49
|
): string {
|
|
50
50
|
let result = template;
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
Object.entries(variables).forEach(([key, value]) => {
|
|
53
53
|
const regex = new RegExp(`\\$\\{${key}\\}`, 'g');
|
|
54
54
|
result = result.replace(regex, String(value || ''));
|
|
@@ -72,24 +72,24 @@ export class StyleTransferService implements IStyleTransferService {
|
|
|
72
72
|
this.initializeDefaultStyles();
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
generateTemplate(config: StyleTransferConfig): Promise<AIPromptResult<AIPromptTemplate>> {
|
|
76
76
|
try {
|
|
77
77
|
if (!this.validateConfig(config)) {
|
|
78
|
-
return {
|
|
78
|
+
return Promise.resolve({
|
|
79
79
|
success: false,
|
|
80
80
|
error: 'VALIDATION_ERROR',
|
|
81
81
|
message: 'Invalid style transfer configuration'
|
|
82
|
-
};
|
|
82
|
+
});
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
const template = this.createStyleTransferTemplate(config);
|
|
86
|
-
return { success: true, data: template };
|
|
87
|
-
} catch
|
|
88
|
-
return {
|
|
86
|
+
return Promise.resolve({ success: true, data: template });
|
|
87
|
+
} catch {
|
|
88
|
+
return Promise.resolve({
|
|
89
89
|
success: false,
|
|
90
90
|
error: 'GENERATION_FAILED',
|
|
91
91
|
message: 'Failed to generate style transfer template'
|
|
92
|
-
};
|
|
92
|
+
});
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -114,7 +114,7 @@ export class StyleTransferService implements IStyleTransferService {
|
|
|
114
114
|
return validateStyleTransferConfig(config);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
getAvailableStyles(): Promise<string[]> {
|
|
118
118
|
return Promise.resolve([...this.availableStyles]);
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -72,24 +72,24 @@ export class TextGenerationService implements ITextGenerationService {
|
|
|
72
72
|
this.promptService = new PromptGenerationService();
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
generateTemplate(config: TextGenerationConfig): Promise<AIPromptResult<AIPromptTemplate>> {
|
|
76
76
|
try {
|
|
77
77
|
if (!this.validateConfig(config)) {
|
|
78
|
-
return {
|
|
78
|
+
return Promise.resolve({
|
|
79
79
|
success: false,
|
|
80
80
|
error: 'VALIDATION_ERROR',
|
|
81
81
|
message: 'Invalid text generation configuration'
|
|
82
|
-
};
|
|
82
|
+
});
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
const template = this.createTextGenerationTemplate(config);
|
|
86
|
-
return { success: true, data: template };
|
|
87
|
-
} catch
|
|
88
|
-
return {
|
|
86
|
+
return Promise.resolve({ success: true, data: template });
|
|
87
|
+
} catch {
|
|
88
|
+
return Promise.resolve({
|
|
89
89
|
success: false,
|
|
90
90
|
error: 'GENERATION_FAILED',
|
|
91
91
|
message: 'Failed to generate text template'
|
|
92
|
-
};
|
|
92
|
+
});
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|