@umituz/react-native-ai-gemini-provider 1.14.28 → 1.14.30

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 (49) hide show
  1. package/package.json +41 -3
  2. package/src/domain/README.md +232 -0
  3. package/src/domain/constants/README.md +191 -0
  4. package/src/domain/entities/README.md +238 -0
  5. package/src/infrastructure/README.md +252 -0
  6. package/src/infrastructure/cache/CACHE_SYSTEM.md +213 -0
  7. package/src/infrastructure/cache/README.md +213 -0
  8. package/src/infrastructure/content/CONTENT_BUILDER.md +175 -0
  9. package/src/infrastructure/content/README.md +175 -0
  10. package/src/infrastructure/interceptors/README.md +226 -0
  11. package/src/infrastructure/interceptors/REQUEST_INTERCEPTORS.md +171 -0
  12. package/src/infrastructure/job/JOB_MANAGER.md +174 -0
  13. package/src/infrastructure/job/README.md +194 -0
  14. package/src/infrastructure/response/README.md +187 -0
  15. package/src/infrastructure/response/RESPONSE_FORMATTER.md +185 -0
  16. package/src/infrastructure/services/CORE_CLIENT_SERVICE.md +202 -0
  17. package/src/infrastructure/services/FEATURE_MODEL_SELECTOR_SERVICE.md +206 -0
  18. package/src/infrastructure/services/GENERATION_EXECUTOR_SERVICE.md +176 -0
  19. package/src/infrastructure/services/IMAGE_EDIT_SERVICE.md +169 -0
  20. package/src/infrastructure/services/IMAGE_GENERATION_SERVICE.md +166 -0
  21. package/src/infrastructure/services/JOB_PROCESSOR_SERVICE.md +174 -0
  22. package/src/infrastructure/services/PROVIDER_INITIALIZER_SERVICE.md +176 -0
  23. package/src/infrastructure/services/README.md +233 -0
  24. package/src/infrastructure/services/RETRY_SERVICE.md +178 -0
  25. package/src/infrastructure/services/STREAMING_SERVICE.md +166 -0
  26. package/src/infrastructure/services/STRUCTURED_TEXT_SERVICE.md +175 -0
  27. package/src/infrastructure/services/TEXT_GENERATION_SERVICE.md +160 -0
  28. package/src/infrastructure/services/VEO_HTTP_CLIENT_SERVICE.md +179 -0
  29. package/src/infrastructure/services/VEO_POLLING_SERVICE.md +173 -0
  30. package/src/infrastructure/services/VIDEO_DOWNLOADER_SERVICE.md +166 -0
  31. package/src/infrastructure/services/VIDEO_ERROR_HANDLER_SERVICE.md +185 -0
  32. package/src/infrastructure/services/VIDEO_GENERATION_SERVICE.md +176 -0
  33. package/src/infrastructure/services/VIDEO_URL_EXTRACTOR_SERVICE.md +186 -0
  34. package/src/infrastructure/services/gemini-provider.ts +9 -2
  35. package/src/infrastructure/telemetry/README.md +203 -0
  36. package/src/infrastructure/telemetry/TELEMETRY_SYSTEM.md +200 -0
  37. package/src/infrastructure/utils/DATA_TRANSFORMER_UTILS.md +175 -0
  38. package/src/infrastructure/utils/ERROR_MAPPER.md +170 -0
  39. package/src/infrastructure/utils/ERROR_UTILITIES.md +208 -0
  40. package/src/infrastructure/utils/IMAGE_PREPARER_UTILS.md +185 -0
  41. package/src/infrastructure/utils/INPUT_BUILDERS.md +214 -0
  42. package/src/infrastructure/utils/MODEL_VALIDATION_UTILS.md +189 -0
  43. package/src/infrastructure/utils/PERFORMANCE_UTILITIES.md +477 -0
  44. package/src/infrastructure/utils/PERFORMANCE_UTILS.md +219 -0
  45. package/src/infrastructure/utils/README.md +289 -0
  46. package/src/presentation/README.md +187 -0
  47. package/src/presentation/hooks/README.md +188 -0
  48. package/src/presentation/hooks/USE_GEMINI_HOOK.md +226 -0
  49. package/src/providers/README.md +247 -0
@@ -0,0 +1,214 @@
1
+ # Input Builders
2
+
3
+ Helper functions for building Gemini API inputs for image and video processing features. Creates properly formatted prompts and image arrays.
4
+
5
+ ## 📍 Import Path
6
+
7
+ ```
8
+ import {
9
+ buildUpscaleInput,
10
+ buildPhotoRestoreInput,
11
+ buildRemoveBackgroundInput,
12
+ buildReplaceBackgroundInput,
13
+ buildFaceSwapInput,
14
+ buildSingleImageInput,
15
+ buildDualImageInput
16
+ } from '@umituz/react-native-ai-gemini-provider';
17
+ ```
18
+
19
+ ## 🎯 Purpose
20
+
21
+ Use input builders to create properly formatted inputs for image and video features. Simplifies prompt engineering and image data preparation.
22
+
23
+ **When to use:**
24
+ - Build inputs for image editing features
25
+ - Create prompts for video generation
26
+ - Format image data correctly
27
+ - Combine multiple images
28
+ - Simplify feature integration
29
+
30
+ ## 📌 Strategy
31
+
32
+ Input builders encapsulate prompt complexity. This system:
33
+ - Creates optimized prompts for features
34
+ - Formats image data correctly
35
+ - Handles single and multiple images
36
+ - Provides consistent interface
37
+ - Simplifies feature usage
38
+
39
+ **Key Decision**: Always use input builders for image/video features. Ensures correct prompt engineering and data formatting.
40
+
41
+ ## ⚠️ Rules
42
+
43
+ ### Usage Rules
44
+ - **MUST** use builders for image/video features
45
+ - **SHOULD** provide valid base64 data
46
+ - **MUST** check required parameters
47
+ - **SHOULD** handle missing options
48
+ - **MUST NOT** create inputs manually
49
+
50
+ ### Data Rules
51
+ - **MUST** provide valid base64 strings
52
+ - **SHOULD** validate image data
53
+ - **MUST** include correct MIME types
54
+ - **SHOULD** handle encoding errors
55
+ - **MUST NOT** pass invalid data
56
+
57
+ ### Prompt Rules
58
+ - **MUST** use builder-generated prompts
59
+ - **SHOULD NOT** modify builder prompts
60
+ - **MUST** follow prompt patterns
61
+ - **SHOULD** test prompt effectiveness
62
+ - **MUST NOT** hardcode prompts
63
+
64
+ ### Options Rules
65
+ - **SHOULD** provide appropriate options
66
+ - **MUST** check required parameters
67
+ - **SHOULD** use default values wisely
68
+ - **MUST** validate option values
69
+ - **SHOULD NOT** ignore option validation
70
+
71
+ ## 🤖 AI Agent Guidelines
72
+
73
+ ### When Building Inputs
74
+ 1. **SELECT** appropriate builder function
75
+ 2. **PROVIDE** valid base64 data
76
+ 3. **CONFIGURE** options if needed
77
+ 4. **USE** returned prompt and images
78
+ 5. **HANDLE** builder errors
79
+
80
+ ### When Using Image Features
81
+ 1. **PREPARE** image base64 data
82
+ 2. **CALL** appropriate builder
83
+ 3. **USE** prompt from builder
84
+ 4. **PASS** images array to service
85
+ 5. **HANDLE** service response
86
+
87
+ ### When Creating Custom Builders
88
+ 1. **ANALYZE** existing builders
89
+ 2. **FOLLOW** builder pattern
90
+ 3. **CREATE** optimized prompt
91
+ 4. **RETURN** consistent structure
92
+ 5. **TEST** builder thoroughly
93
+
94
+ ### Code Style Rules
95
+ - **USE** builders instead of manual input
96
+ - **VALIDATE** input data
97
+ - **HANDLE** missing options
98
+ - **FOLLOW** builder patterns
99
+ - **TEST** builder output
100
+
101
+ ## 📦 Available Builders
102
+
103
+ ### Single Image Builders
104
+
105
+ **Refer to**: [`image-feature-builders.util.ts`](./image-feature-builders.util.ts)
106
+
107
+ - `buildUpscaleInput(base64, options?)` - Image upscaling
108
+ - `buildPhotoRestoreInput(base64, options?)` - Photo restoration
109
+ - `buildAnimeSelfieInput(base64, options?)` - Anime style transformation
110
+ - `buildRemoveBackgroundInput(base64, options?)` - Background removal
111
+ - `buildRemoveObjectInput(base64, options?)` - Object removal
112
+ - `buildReplaceBackgroundInput(base64, options)` - Background replacement
113
+ - `buildHDTouchUpInput(base64, options?)` - HD enhancement
114
+
115
+ ### Dual Image Builders
116
+
117
+ **Refer to**: [`image-feature-builders.util.ts`](./image-feature-builders.util.ts)
118
+
119
+ - `buildFaceSwapInput(sourceBase64, targetBase64, options?)` - Face swapping
120
+
121
+ ### Video Builders
122
+
123
+ **Refer to**: [`video-feature-builders.util.ts`](./video-feature-builders.util.ts)
124
+
125
+ - `buildAIHugInput(base64, options?)` - AI hugging effect
126
+ - `buildAIKissInput(base64, options?)` - AI kissing effect
127
+ - `buildVideoFromDualImagesInput(base64a, base64b, options?)` - Dual image to video
128
+
129
+ ### Base Builders
130
+
131
+ **Refer to**: [`base-input-builders.util.ts`](./base-input-builders.util.ts)
132
+
133
+ - `buildSingleImageInput(base64, prompt)` - Single image input
134
+ - `buildDualImageInput(base64a, base64b, prompt)` - Dual image input
135
+
136
+ ## 🔗 Related Modules
137
+
138
+ - **Image Edit Service**: [`../services/IMAGE_EDIT_SERVICE.md`](../services/IMAGE_EDIT_SERVICE.md)
139
+ - **Image Preparer Utils**: [`../utils/IMAGE_PREPARER_UTILS.md`](../utils/IMAGE_PREPARER_UTILS.md)
140
+ - **Content Builder**: [`../content/README.md`](../content/README.md)
141
+
142
+ ## 📋 Builder Return Type
143
+
144
+ All builders return:
145
+
146
+ ```typescript
147
+ {
148
+ prompt: string;
149
+ images: Array<{
150
+ base64: string;
151
+ mimeType: string;
152
+ }>;
153
+ }
154
+ ```
155
+
156
+ This structure is compatible with `geminiImageEditService.editImage()`.
157
+
158
+ ## 🎓 Usage Patterns
159
+
160
+ ### Basic Feature Usage
161
+ 1. Prepare image base64 data
162
+ 2. Call appropriate builder function
163
+ 3. Configure options if needed
164
+ 4. Use returned prompt and images
165
+ 5. Call image edit service
166
+
167
+ ### Single Image Processing
168
+ 1. Get image base64 string
169
+ 2. Call single-image builder
170
+ 3. Pass prompt and images to service
171
+ 4. Handle service response
172
+ 5. Display result
173
+
174
+ ### Dual Image Processing
175
+ 1. Get both image base64 strings
176
+ 2. Call dual-image builder
177
+ 3. Use returned input structure
178
+ 4. Call appropriate service
179
+ 5. Handle response
180
+
181
+ ### Batch Processing
182
+ 1. Prepare all images
183
+ 2. Call builder for each image
184
+ 3. Process inputs in sequence
185
+ 4. Collect all results
186
+ 5. Return batch results
187
+
188
+ ### Custom Features
189
+ 1. Analyze existing builders
190
+ 2. Create custom builder function
191
+ 3. Follow builder pattern
192
+ 4. Return consistent structure
193
+ 5. Test thoroughly
194
+
195
+ ## 🚨 Common Pitfalls
196
+
197
+ ### Don't
198
+ - Create inputs manually
199
+ - Modify builder prompts
200
+ - Skip builder functions
201
+ - Hardcode prompts
202
+ - Use invalid base64 data
203
+
204
+ ### Do
205
+ - Always use input builders
206
+ - Follow builder patterns
207
+ - Validate input data
208
+ - Use builder-generated prompts
209
+ - Test builder output
210
+
211
+ ---
212
+
213
+ **Last Updated**: 2025-01-08
214
+ **See Also**: [AI_GUIDELINES.md](../../../../AI_GUIDELINES.md)
@@ -0,0 +1,189 @@
1
+ # Model Validation Utilities
2
+
3
+ Helper functions for validating model IDs and determining model categories. Ensures only valid models are used in requests.
4
+
5
+ ## 📍 Import Path
6
+
7
+ ```
8
+ import {
9
+ isValidModel,
10
+ validateModel,
11
+ getSafeModel,
12
+ getModelCategory,
13
+ getAllValidModels,
14
+ isTextModel,
15
+ isImageModel,
16
+ isImageEditModel,
17
+ isVideoGenerationModel
18
+ } from '@umituz/react-native-ai-gemini-provider';
19
+ ```
20
+
21
+ ## 🎯 Purpose
22
+
23
+ Use validation utilities to verify model IDs before making API requests. Prevents errors from invalid model usage.
24
+
25
+ **When to use:**
26
+ - Validate model IDs before use
27
+ - Check model capabilities
28
+ - Get safe fallback models
29
+ - Determine model category
30
+ - List available models
31
+
32
+ ## 📌 Strategy
33
+
34
+ Validation prevents API errors. This system:
35
+ - Validates models against whitelist
36
+ - Provides safe fallbacks
37
+ - Categorizes models by capability
38
+ - Lists all valid models
39
+ - Ensures model compatibility
40
+
41
+ **Key Decision**: Always validate user-provided model IDs. Use `getSafeModel()` for fallback handling.
42
+
43
+ ## ⚠️ Rules
44
+
45
+ ### Validation Rules
46
+ - **MUST** validate models before API calls
47
+ - **SHOULD** use `getSafeModel()` for user input
48
+ - **MUST** handle invalid models
49
+ - **SHOULD** validate early in request flow
50
+ - **MUST NOT** skip validation
51
+
52
+ ### Fallback Rules
53
+ - **SHOULD** provide safe defaults
54
+ - **MUST** handle undefined models
55
+ - **SHOULD** use appropriate default types
56
+ - **MUST** document fallback behavior
57
+ - **SHOULD NOT** silently use wrong model
58
+
59
+ ### Category Rules
60
+ - **MUST** check category before using model
61
+ - **SHOULD** verify model capabilities
62
+ - **MUST** handle unknown models
63
+ - **SHOULD** use category checks
64
+ - **MUST NOT** assume model type
65
+
66
+ ### Usage Rules
67
+ - **SHOULD** validate in UI layer
68
+ - **MUST** throw on invalid models (validateModel)
69
+ - **SHOULD** return safe default (getSafeModel)
70
+ - **MUST** document validation behavior
71
+ - **SHOULD NOT** allow invalid models
72
+
73
+ ## 🤖 AI Agent Guidelines
74
+
75
+ ### When Validating Models
76
+ 1. **CALL** validation function
77
+ 2. **CHECK** return value
78
+ 3. **HANDLE** invalid model case
79
+ 4. **USE** fallback or throw
80
+ 5. **LOG** validation failures
81
+
82
+ ### When Getting Safe Models
83
+ 1. **USE** getSafeModel() for user input
84
+ 2. **PROVIDE** appropriate default type
85
+ 3. **HANDLE** undefined input
86
+ 4. **RETURN** valid model ID
87
+ 5. **DOCUMENT** fallback behavior
88
+
89
+ ### When Checking Categories
90
+ 1. **CALL** category check function
91
+ 2. **VERIFY** model supports feature
92
+ 3. **USE** appropriate service
93
+ 4. **HANDLE** category mismatch
94
+ 5. **PROVIDE** clear error messages
95
+
96
+ ### Code Style Rules
97
+ - **VALIDATE** early in request flow
98
+ - **USE** type-safe functions
99
+ - **HANDLE** all validation cases
100
+ - **PROVIDE** helpful error messages
101
+ - **DOCUMENT** validation behavior
102
+
103
+ ## 📦 Available Functions
104
+
105
+ **Refer to**: [`model-validation.util.ts`](./model-validation.util.ts)
106
+
107
+ ### Validation Functions
108
+ - `isValidModel(model)` - Check if model ID is valid
109
+ - `validateModel(model)` - Validate or throw error
110
+ - `getSafeModel(model, defaultType)` - Get safe model with fallback
111
+ - `getAllValidModels()` - Get all valid model IDs
112
+
113
+ ### Category Checks
114
+ - `isTextModel(model)` - Check if text model
115
+ - `isImageModel(model)` - Check if image model
116
+ - `isImageEditModel(model)` - Check if image edit model
117
+ - `isVideoGenerationModel(model)` - Check if video model
118
+ - `getModelCategory(model)` - Get model category
119
+
120
+ ## 🔗 Related Modules
121
+
122
+ - **Domain Entities**: [`../../domain/entities/README.md`](../../domain/entities/README.md)
123
+ - **Error Utilities**: [`./ERROR_UTILITIES.md`](./ERROR_UTILITIES.md)
124
+ - **Services README**: [`../services/README.md`](../services/README.md)
125
+
126
+ ## 📋 Model Categories
127
+
128
+ ### Text Models
129
+ Text generation models: `gemini-2.5-flash-lite`, `gemini-2.5-flash`, `gemini-2.5-pro`, `gemini-2.0-flash-exp`, `gemini-1.5-pro`, `gemini-1.5-flash`
130
+
131
+ ### Text-to-Image Models
132
+ Image generation models: `imagen-4.0-generate-001`, `imagen-3.0-generate-001`
133
+
134
+ ### Image Edit Models
135
+ Image editing models: `gemini-2.5-flash-image`, `gemini-3-pro-image-preview`
136
+
137
+ ### Video Generation Models
138
+ Video generation models: `veo-3.1-fast-generate-preview`, `veo-3.0-generate-001`
139
+
140
+ ## 🎓 Usage Patterns
141
+
142
+ ### Model Validation
143
+ 1. Call `isValidModel()` or `validateModel()`
144
+ 2. Check return value
145
+ 3. Handle invalid model case
146
+ 4. Use validated model in request
147
+ 5. Provide fallback if needed
148
+
149
+ ### Safe Model Selection
150
+ 1. Get user input for model
151
+ 2. Call `getSafeModel()` with default
152
+ 3. Use returned model ID
153
+ 4. Handle validation errors
154
+ 5. Use appropriate service
155
+
156
+ ### Category-Based Routing
157
+ 1. Get model category
158
+ 2. Route to appropriate service
159
+ 3. Use category-specific features
160
+ 4. Handle unknown categories
161
+ 5. Provide clear error messages
162
+
163
+ ### Model Listing
164
+ 1. Call `getAllValidModels()`
165
+ 2. Filter by category if needed
166
+ 3. Display to user
167
+ 4. Handle model selection
168
+ 5. Validate selection
169
+
170
+ ## 🚨 Common Pitfalls
171
+
172
+ ### Don't
173
+ - Skip model validation
174
+ - Use user input without validation
175
+ - Assume model type from name
176
+ - Allow invalid models to API
177
+ - Ignore category checks
178
+
179
+ ### Do
180
+ - Always validate model IDs
181
+ - Use safe fallbacks
182
+ - Check model categories
183
+ - Validate early in flow
184
+ - Handle all validation cases
185
+
186
+ ---
187
+
188
+ **Last Updated**: 2025-01-08
189
+ **See Also**: [AI_GUIDELINES.md](../../../../AI_GUIDELINES.md)