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

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 (48) hide show
  1. package/package.json +1 -1
  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/telemetry/README.md +203 -0
  35. package/src/infrastructure/telemetry/TELEMETRY_SYSTEM.md +200 -0
  36. package/src/infrastructure/utils/DATA_TRANSFORMER_UTILS.md +175 -0
  37. package/src/infrastructure/utils/ERROR_MAPPER.md +170 -0
  38. package/src/infrastructure/utils/ERROR_UTILITIES.md +208 -0
  39. package/src/infrastructure/utils/IMAGE_PREPARER_UTILS.md +185 -0
  40. package/src/infrastructure/utils/INPUT_BUILDERS.md +214 -0
  41. package/src/infrastructure/utils/MODEL_VALIDATION_UTILS.md +189 -0
  42. package/src/infrastructure/utils/PERFORMANCE_UTILITIES.md +477 -0
  43. package/src/infrastructure/utils/PERFORMANCE_UTILS.md +219 -0
  44. package/src/infrastructure/utils/README.md +289 -0
  45. package/src/presentation/README.md +187 -0
  46. package/src/presentation/hooks/README.md +188 -0
  47. package/src/presentation/hooks/USE_GEMINI_HOOK.md +226 -0
  48. package/src/providers/README.md +247 -0
@@ -0,0 +1,174 @@
1
+ # Job Processor Service
2
+
3
+ Service for handling asynchronous AI generation jobs. Manages job submission, status tracking, and result retrieval with automatic async processing.
4
+
5
+ ## 📍 Import Path
6
+
7
+ ```
8
+ import { jobProcessor } from '@umituz/react-native-ai-gemini-provider';
9
+ ```
10
+
11
+ ## 🎯 Purpose
12
+
13
+ Use job processor to handle long-running AI operations asynchronously. Submit jobs, track status, and retrieve results when ready.
14
+
15
+ **When to use:**
16
+ - Process long-running operations
17
+ - Track job status over time
18
+ - Implement async job management
19
+ - Handle video generation
20
+ - Manage background processing
21
+
22
+ ## 📌 Strategy
23
+
24
+ Async processing improves UX. This service:
25
+ - Manages job lifecycle
26
+ - Tracks status changes
27
+ - Stores results for retrieval
28
+ - Handles polling automatically
29
+ - Provides job management
30
+
31
+ **Key Decision**: Use job processor for operations taking > 30 seconds. Poll for status instead of blocking.
32
+
33
+ ## ⚠️ Rules
34
+
35
+ ### Job Submission Rules
36
+ - **MUST** save request ID after submission
37
+ - **SHOULD** validate input before submission
38
+ - **MUST** handle submission errors
39
+ - **SHOULD** track submitted jobs
40
+ - **MUST NOT** lose request IDs
41
+
42
+ ### Status Tracking Rules
43
+ - **MUST** poll status periodically
44
+ - **SHOULD** implement exponential backoff
45
+ - **MUST** handle status changes
46
+ - **SHOULD** monitor job progress
47
+ - **MUST NOT** poll too frequently
48
+
49
+ ### Result Retrieval Rules
50
+ - **SHOULD** verify job completion
51
+ - **MUST** handle retrieval errors
52
+ - **SHOULD** validate result format
53
+ - **MUST** clear old results
54
+ - **SHOULD NOT** retrieve incomplete jobs
55
+
56
+ ### Cleanup Rules
57
+ - **SHOULD** clear completed jobs
58
+ - **MUST** handle cleanup errors
59
+ - **SHOULD** implement job expiration
60
+ - **MUST** manage memory usage
61
+ - **SHOULD NOT** accumulate old jobs
62
+
63
+ ## 🤖 AI Agent Guidelines
64
+
65
+ ### When Submitting Jobs
66
+ 1. **VALIDATE** input parameters
67
+ 2. **CALL** submitJob()
68
+ 3. **SAVE** request ID
69
+ 4. **TRACK** job status
70
+ 5. **HANDLE** submission errors
71
+
72
+ ### When Tracking Status
73
+ 1. **POLL** getJobStatus() periodically
74
+ 2. **IMPLEMENT** exponential backoff
75
+ 3. **CHECK** status changes
76
+ 4. **UPDATE** UI accordingly
77
+ 5. **HANDLE** completion
78
+
79
+ ### When Retrieving Results
80
+ 1. **VERIFY** job completion
81
+ 2. **CALL** getJobResult()
82
+ 3. **VALIDATE** result format
83
+ 4. **USE** result data
84
+ 5. **CLEAR** job data
85
+
86
+ ### Code Style Rules
87
+ - **SAVE** request IDs persistently
88
+ - **IMPLEMENT** polling with timeout
89
+ - **HANDLE** all status cases
90
+ - **CLEAN UP** old jobs
91
+ - **LOG** job lifecycle events
92
+
93
+ ## 📦 Available Service
94
+
95
+ ### jobProcessor
96
+
97
+ **Refer to**: [`job-processor.ts`](./job-processor.ts)
98
+
99
+ **Methods:**
100
+ - `submitJob(model, input)` - Submit async job
101
+ - `getJobStatus(model, requestId)` - Get job status
102
+ - `getJobResult(model, requestId)` - Get job result
103
+ - `clear()` - Clear all jobs
104
+
105
+ ## 🔗 Related Modules
106
+
107
+ - **Job Manager**: [`../../job/README.md`](../../job/README.md)
108
+ - **Video Generation**: [`VIDEO_GENERATION_SERVICE.md`](./VIDEO_GENERATION_SERVICE.md)
109
+ - **Generation Executor**: [`GENERATION_EXECUTOR_SERVICE.md`](./GENERATION_EXECUTOR_SERVICE.md)
110
+
111
+ ## 📋 Job States
112
+
113
+ ### IN_QUEUE
114
+ Job is queued, waiting to start.
115
+
116
+ ### PROCESSING
117
+ Job is currently being processed.
118
+
119
+ ### COMPLETED
120
+ Job finished successfully with result.
121
+
122
+ ### FAILED
123
+ Job failed with error.
124
+
125
+ ## 🎓 Usage Patterns
126
+
127
+ ### Job Submission
128
+ 1. Validate input parameters
129
+ 2. Call submitJob()
130
+ 3. Save request ID
131
+ 4. Display submission status
132
+ 5. Begin polling
133
+
134
+ ### Status Polling
135
+ 1. Poll getJobStatus() periodically
136
+ 2. Implement exponential backoff
137
+ 3. Update UI with status
138
+ 4. Handle completion/failure
139
+ 5. Stop polling when done
140
+
141
+ ### Result Retrieval
142
+ 1. Verify job completion
143
+ 2. Call getJobResult()
144
+ 3. Validate result format
145
+ 4. Use result data
146
+ 5. Clear job data
147
+
148
+ ### Job Cleanup
149
+ 1. Track job completion time
150
+ 2. Clear old completed jobs
151
+ 3. Remove failed jobs
152
+ 4. Manage memory usage
153
+ 5. Implement expiration
154
+
155
+ ## 🚨 Common Pitfalls
156
+
157
+ ### Don't
158
+ - Lose request IDs
159
+ - Poll too frequently
160
+ - Skip error handling
161
+ - Forget to clean up jobs
162
+ - Block on job submission
163
+
164
+ ### Do
165
+ - Save request IDs persistently
166
+ - Implement exponential backoff
167
+ - Handle all job states
168
+ - Clean up completed jobs
169
+ - Provide user feedback
170
+
171
+ ---
172
+
173
+ **Last Updated**: 2025-01-08
174
+ **See Also**: [AI_GUIDELINES.md](../../../../AI_GUIDELINES.md)
@@ -0,0 +1,176 @@
1
+ # Provider Initializer Service
2
+
3
+ Service for initializing and configuring the Gemini Provider. Handles setup of the core client with provider-specific configuration.
4
+
5
+ ## 📍 Import Path
6
+
7
+ ```
8
+ import { providerInitializer } from '@umituz/react-native-ai-gemini-provider';
9
+ ```
10
+
11
+ ## 🎯 Purpose
12
+
13
+ Use provider initializer to configure and set up the Gemini provider before using any services. Initializes core client with API keys and configuration.
14
+
15
+ **When to use:**
16
+ - Initialize provider on application startup
17
+ - Configure retry and timeout settings
18
+ - Set default models for different features
19
+ - Reset provider for testing
20
+ - Verify initialization status
21
+
22
+ ## 📌 Strategy
23
+
24
+ Provider must be initialized before any AI operations. This service:
25
+ - Initializes singleton core client
26
+ - Configures retry and timeout behavior
27
+ - Sets default models for features
28
+ - Prevents duplicate initialization
29
+ - Provides reset capability for testing
30
+ - Validates configuration
31
+
32
+ **Key Decision**: Initialize provider once at application startup. Use `isInitialized()` to verify before operations.
33
+
34
+ ## ⚠️ Rules
35
+
36
+ ### Initialization Rules
37
+ - **MUST** initialize before using any service
38
+ - **SHOULD** initialize on app startup
39
+ - **MUST** provide valid API key
40
+ - **SHOULD** check initialization status
41
+ - **MUST NOT** reinitialize unnecessarily
42
+
43
+ ### Configuration Rules
44
+ - **MUST** provide API key (required field)
45
+ - **SHOULD** set appropriate retry limits
46
+ - **MUST** configure timeouts appropriately
47
+ - **SHOULD** use environment variables for secrets
48
+ - **MUST NOT** hardcode API keys
49
+
50
+ ### API Key Rules
51
+ - **MUST** store API keys securely
52
+ - **SHOULD** use environment variables
53
+ - **MUST NOT** commit API keys to version control
54
+ - **SHOULD** rotate keys periodically
55
+ - **MUST** validate key format
56
+
57
+ ### Reset Rules
58
+ - **SHOULD** only reset for testing
59
+ - **MUST NOT** reset in production
60
+ - **SHOULD** reinitialize after reset
61
+ - **MUST** handle reset errors
62
+ - **SHOULD** warn before resetting
63
+
64
+ ## 🤖 AI Agent Guidelines
65
+
66
+ ### When Initializing Provider
67
+ 1. **CALL** initialize() with configuration
68
+ 2. **PROVIDE** valid API key
69
+ 3. **SET** appropriate retry/timeout values
70
+ 4. **CONFIGURE** default models
71
+ 5. **VERIFY** initialization success
72
+
73
+ ### When Checking Status
74
+ 1. **CALL** isInitialized() before operations
75
+ 2. **THROW** error if not initialized
76
+ 3. **INITIALIZE** if not ready
77
+ 4. **LOG** initialization status
78
+ 5. **HANDLE** initialization errors
79
+
80
+ ### When Resetting Provider
81
+ 1. **USE** only in test environments
82
+ 2. **CALL** reset() to clear state
83
+ 3. **REINITIALIZE** with new config
84
+ 4. **VERIFY** reset success
85
+ 5. **CLEAN UP** resources
86
+
87
+ ### Code Style Rules
88
+ - **INITIALIZE** early in app lifecycle
89
+ - **VALIDATE** configuration before initialization
90
+ - **HANDLE** initialization errors
91
+ - **LOG** initialization in development
92
+ - **USE** environment variables for secrets
93
+
94
+ ## 📦 Available Service
95
+
96
+ ### providerInitializer
97
+
98
+ **Refer to**: [`provider-initializer.ts`](./provider-initializer.ts)
99
+
100
+ **Singleton instance**
101
+
102
+ **Methods:**
103
+ - `initialize(config)` - Initialize provider with configuration
104
+ - `isInitialized()` - Check if provider is initialized
105
+ - `reset()` - Reset provider state
106
+
107
+ ## 🔗 Related Modules
108
+
109
+ - **Core Client**: [`CORE_CLIENT_SERVICE.md`](./CORE_CLIENT_SERVICE.md)
110
+ - **Domain Types**: [`../../domain/README.md`](../../domain/README.md)
111
+ - **Services README**: [`./README.md`](./README.md)
112
+
113
+ ## 📋 Configuration
114
+
115
+ ### Required Fields
116
+ - `apiKey`: Google Cloud API key
117
+
118
+ ### Optional Fields
119
+ - `maxRetries`: Maximum retry attempts (default: from core config)
120
+ - `baseDelay`: Base delay for retries in ms (default: from core config)
121
+ - `maxDelay`: Maximum delay for retries in ms (default: from core config)
122
+ - `defaultTimeoutMs`: Default timeout for requests in ms (default: from core config)
123
+ - `textModel`: Default model for text generation
124
+ - `textToImageModel`: Default model for image generation
125
+ - `imageEditModel`: Default model for image editing
126
+
127
+ ## 🎓 Usage Patterns
128
+
129
+ ### Basic Initialization
130
+ 1. Import providerInitializer
131
+ 2. Call initialize() with API key
132
+ 3. Verify initialization success
133
+ 4. Use Gemini services normally
134
+ 5. Handle initialization errors
135
+
136
+ ### Full Configuration
137
+ 1. Create configuration object
138
+ 2. Set API key and models
139
+ 3. Configure retry/timeout values
140
+ 4. Initialize provider
141
+ 5. Verify all settings
142
+
143
+ ### React Native Integration
144
+ 1. Import in App component
145
+ 2. Initialize in useEffect
146
+ 3. Set loading state
147
+ 4. Handle errors
148
+ 5. Render app when ready
149
+
150
+ ### Environment-Based Configuration
151
+ 1. Detect environment (dev/prod)
152
+ 2. Select appropriate configuration
153
+ 3. Initialize with environment settings
154
+ 4. Log configuration in development
155
+ 5. Use appropriate models
156
+
157
+ ## 🚨 Common Pitfalls
158
+
159
+ ### Don't
160
+ - Initialize provider before every operation
161
+ - Hardcode API keys in source code
162
+ - Skip initialization status checks
163
+ - Use invalid API keys
164
+ - Reset provider in production
165
+
166
+ ### Do
167
+ - Initialize once at app startup
168
+ - Use environment variables for API keys
169
+ - Check initialization status before use
170
+ - Validate configuration format
171
+ - Handle initialization errors gracefully
172
+
173
+ ---
174
+
175
+ **Last Updated**: 2025-01-08
176
+ **See Also**: [AI_GUIDELINES.md](../../../../AI_GUIDELINES.md)
@@ -0,0 +1,233 @@
1
+ # Services Layer
2
+
3
+ Communication layer with Gemini API. Contains all business logic for text, image, and video generation.
4
+
5
+ ## 📍 Import Path
6
+
7
+ ```
8
+ import {
9
+ geminiClientCoreService,
10
+ geminiTextGenerationService,
11
+ geminiImageGenerationService,
12
+ geminiImageEditService,
13
+ geminiVideoGenerationService,
14
+ geminiStreamingService,
15
+ geminiRetryService,
16
+ providerInitializer,
17
+ featureModelSelector
18
+ } from '@umituz/react-native-ai-gemini-provider';
19
+ ```
20
+
21
+ ## 🎯 Purpose
22
+
23
+ Use services to execute AI operations. Each service handles specific AI capabilities with proper error handling and retry logic.
24
+
25
+ **When to use:**
26
+ - Generate text content
27
+ - Create images from text
28
+ - Edit and transform images
29
+ - Generate videos
30
+ - Stream real-time responses
31
+ - Handle AI errors and retries
32
+
33
+ ## 📌 Strategy
34
+
35
+ Services encapsulate API communication logic. This layer:
36
+ - Provides high-level interfaces for AI operations
37
+ - Handles error detection and retry logic
38
+ - Manages API communication complexity
39
+ - Implements feature-based model selection
40
+ - Supports both simple and advanced use cases
41
+
42
+ **Key Decision**: Use services for all AI operations. They handle complexity, errors, and optimization automatically.
43
+
44
+ ## ⚠️ Rules
45
+
46
+ ### Usage Rules
47
+ - **MUST** initialize provider before using services
48
+ - **SHOULD** use appropriate service for operation type
49
+ - **MUST** handle service errors appropriately
50
+ - **SHOULD** check model validation
51
+ - **MUST NOT** bypass error handling
52
+
53
+ ### Error Handling Rules
54
+ - **MUST** catch and handle `GeminiError`
55
+ - **SHOULD** implement retry logic for transient errors
56
+ - **MUST** provide user-friendly error messages
57
+ - **SHOULD** log errors for debugging
58
+ - **MUST NOT** expose API keys in errors
59
+
60
+ ### Configuration Rules
61
+ - **MUST** use valid model IDs
62
+ - **SHOULD** configure appropriate generation parameters
63
+ - **MUST** respect API rate limits
64
+ - **SHOULD** implement timeouts for long operations
65
+ - **MUST NOT** use deprecated models
66
+
67
+ ### Model Selection Rules
68
+ - **SHOULD** use feature-based model selector
69
+ - **MUST** validate model before use
70
+ - **SHOULD** consider user tier for model selection
71
+ - **MUST NOT** hardcode model IDs in application code
72
+
73
+ ## 🤖 AI Agent Guidelines
74
+
75
+ ### When Modifying Services
76
+ 1. **READ** the implementation file first
77
+ 2. **UNDERSTAND** service dependencies
78
+ 3. **MAINTAIN** backward compatibility
79
+ 4. **ADD** tests for new functionality
80
+ 5. **UPDATE** all documentation
81
+
82
+ ### When Adding New Services
83
+ 1. **CHECK** if similar service exists
84
+ 2. **FOLLOW** existing service patterns
85
+ 3. **USE** established error handling
86
+ 4. **DOCUMENT** in service documentation
87
+ 5. **ADD** examples to tests (not docs)
88
+
89
+ ### When Fixing Service Bugs
90
+ 1. **REPRODUCE** bug locally first
91
+ 2. **IDENTIFY** root cause
92
+ 3. **FIX** with minimal changes
93
+ 4. **ADD** regression test
94
+ 5. **VERIFY** all tests pass
95
+
96
+ ### Code Style Rules
97
+ - **USE** async/await (no callbacks)
98
+ - **VALIDATE** inputs at service entry
99
+ - **THROW** typed errors (`GeminiError`)
100
+ - **LOG** important operations
101
+ - **COMMENT** complex logic only
102
+
103
+ ## 📦 Available Services
104
+
105
+ ### Core Services
106
+
107
+ **Text Generation**: Generate AI text content
108
+
109
+ **Refer to**: [`TEXT_GENERATION_SERVICE.md`](./TEXT_GENERATION_SERVICE.md)
110
+
111
+ **Image Generation**: Create images from text prompts
112
+
113
+ **Refer to**: [`IMAGE_GENERATION_SERVICE.md`](./IMAGE_GENERATION_SERVICE.md)
114
+
115
+ **Image Edit**: Edit and transform images
116
+
117
+ **Refer to**: [`IMAGE_EDIT_SERVICE.md`](./IMAGE_EDIT_SERVICE.md)
118
+
119
+ **Video Generation**: Generate videos from text/images
120
+
121
+ **Refer to**: [`VIDEO_GENERATION_SERVICE.md`](./VIDEO_GENERATION_SERVICE.md)
122
+
123
+ **Streaming**: Real-time text streaming
124
+
125
+ **Refer to**: [`STREAMING_SERVICE.md`](./STREAMING_SERVICE.md)
126
+
127
+ **Retry**: Automatic retry with backoff
128
+
129
+ **Refer to**: [`RETRY_SERVICE.md`](./RETRY_SERVICE.md)
130
+
131
+ ### Support Services
132
+
133
+ **Core Client**: Low-level SDK communication
134
+
135
+ **Refer to**: [`CORE_CLIENT_SERVICE.md`](./CORE_CLIENT_SERVICE.md)
136
+
137
+ **Feature Model Selector**: Feature-based model selection
138
+
139
+ **Refer to**: [`FEATURE_MODEL_SELECTOR_SERVICE.md`](./FEATURE_MODEL_SELECTOR_SERVICE.md)
140
+
141
+ **Provider Initializer**: Provider initialization
142
+
143
+ **Refer to**: [`PROVIDER_INITIALIZER_SERVICE.md`](./PROVIDER_INITIALIZER_SERVICE.md)
144
+
145
+ ## 🔗 Related Modules
146
+
147
+ - **Domain Types**: [`../../domain/README.md`](../../domain/README.md)
148
+ - **Infrastructure**: [`../infrastructure/README.md`](../infrastructure/README.md)
149
+ - **Presentation**: [`../presentation/README.md`](../presentation/README.md)
150
+
151
+ ## 📋 Service Categories
152
+
153
+ ### Text Services
154
+ - Text generation (simple and structured)
155
+ - Multimodal content (text + images)
156
+ - Streaming responses
157
+ - Conversational AI
158
+
159
+ ### Image Services
160
+ - Text-to-image generation
161
+ - Image editing and transformation
162
+ - Background removal
163
+ - Image enhancement
164
+ - Style transfer
165
+
166
+ ### Video Services
167
+ - Text-to-video generation
168
+ - Image-to-video generation
169
+ - Progress tracking
170
+ - Polling mechanism
171
+
172
+ ### Infrastructure Services
173
+ - SDK client management
174
+ - Error handling and retry
175
+ - Model selection and validation
176
+ - Provider initialization
177
+
178
+ ## 🎓 Usage Patterns
179
+
180
+ ### Basic Text Generation
181
+ 1. Import `geminiTextGenerationService`
182
+ 2. Call `generateText()` with model and prompt
183
+ 3. Handle response or error
184
+ 4. Display result to user
185
+
186
+ ### Image Generation
187
+ 1. Import `geminiImageGenerationService`
188
+ 2. Call `generateImage()` with descriptive prompt
189
+ 3. Handle image data (URL or base64)
190
+ 4. Display image in UI
191
+
192
+ ### Video Generation
193
+ 1. Import `geminiVideoGenerationService`
194
+ 2. Call `generateTextToVideo()` with prompt
195
+ 3. Provide progress callback
196
+ 4. Monitor progress
197
+ 5. Handle completion
198
+
199
+ ### Error Handling
200
+ 1. Wrap service call in try-catch
201
+ 2. Check if error is `GeminiError`
202
+ 3. Switch on error type
203
+ 4. Handle each error type appropriately
204
+ 5. Provide user feedback
205
+
206
+ ### Streaming
207
+ 1. Import `geminiStreamingService`
208
+ 2. Call `streamText()` with model and prompt
209
+ 3. Use `for await` to consume stream
210
+ 4. Display chunks progressively
211
+ 5. Handle completion
212
+
213
+ ## 🚨 Common Pitfalls
214
+
215
+ ### Don't
216
+ - Use services without initializing provider
217
+ - Ignore error handling
218
+ - Hardcode model IDs
219
+ - Exceed API rate limits
220
+ - Skip progress callbacks for long operations
221
+
222
+ ### Do
223
+ - Initialize provider before using services
224
+ - Handle all error types
225
+ - Use feature model selector
226
+ - Implement retry logic
227
+ - Provide user feedback
228
+ - Monitor long operations
229
+
230
+ ---
231
+
232
+ **Last Updated**: 2025-01-08
233
+ **See Also**: [AI_GUIDELINES.md](../../../AI_GUIDELINES.md)