@umituz/react-native-ai-fal-provider 2.0.14 → 2.0.15
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/domain/entities/error.types.ts +2 -0
- package/src/domain/types/provider.types.ts +1 -0
- package/src/exports/infrastructure.ts +0 -3
- package/src/exports/presentation.ts +0 -9
- package/src/index.ts +0 -3
- package/src/infrastructure/services/fal-feature-models.ts +3 -1
- package/src/infrastructure/services/fal-provider-subscription.ts +35 -13
- package/src/infrastructure/services/fal-provider.ts +6 -0
- package/src/infrastructure/services/fal-queue-operations.ts +30 -1
- package/src/infrastructure/services/fal-status-mapper.ts +2 -0
- package/src/infrastructure/services/request-store.ts +30 -2
- package/src/infrastructure/utils/cost-tracker.ts +34 -8
- package/src/infrastructure/utils/error-mapper.ts +17 -3
- package/src/infrastructure/utils/image-feature-builders.util.ts +10 -5
- package/src/infrastructure/utils/index.ts +7 -6
- package/src/infrastructure/utils/input-validator.util.ts +92 -0
- package/src/infrastructure/utils/type-guards.util.ts +7 -3
- package/src/infrastructure/utils/video-feature-builders.util.ts +6 -3
- package/src/infrastructure/validators/nsfw-validator.ts +62 -4
- package/src/presentation/hooks/index.ts +3 -21
- package/src/presentation/hooks/use-fal-generation.ts +5 -4
- package/src/domain/constants/default-models.constants.README.md +0 -378
- package/src/domain/constants/models/image-to-video.README.md +0 -266
- package/src/domain/constants/models/index.README.md +0 -269
- package/src/domain/constants/models/text-to-image.README.md +0 -237
- package/src/domain/constants/models/text-to-text.README.md +0 -249
- package/src/domain/constants/models/text-to-video.README.md +0 -259
- package/src/domain/constants/models/text-to-voice.README.md +0 -264
- package/src/domain/entities/error.types.README.md +0 -292
- package/src/domain/entities/fal.types.README.md +0 -460
- package/src/domain/types/index.README.md +0 -229
- package/src/domain/types/model-selection.types.README.md +0 -311
- package/src/exports/registry.ts +0 -39
- package/src/index.README.md +0 -420
- package/src/infrastructure/builders/image-feature-builder.README.md +0 -435
- package/src/infrastructure/builders/index.ts +0 -7
- package/src/infrastructure/services/fal-models-service.README.md +0 -293
- package/src/infrastructure/services/fal-provider-subscription.README.md +0 -257
- package/src/infrastructure/services/fal-provider.README.md +0 -474
- package/src/infrastructure/services/fal-status-mapper.README.md +0 -246
- package/src/infrastructure/services/nsfw-content-error.README.md +0 -215
- package/src/infrastructure/utils/base-builders.util.README.md +0 -313
- package/src/infrastructure/utils/cost-tracker-queries.ts +0 -67
- package/src/infrastructure/utils/error-categorizer.README.md +0 -395
- package/src/infrastructure/utils/error-mapper.README.md +0 -367
- package/src/infrastructure/utils/helpers.util.README.md +0 -395
- package/src/infrastructure/utils/image-feature-builders.util.README.md +0 -411
- package/src/infrastructure/utils/index.README.md +0 -338
- package/src/infrastructure/utils/job-metadata/index.README.md +0 -267
- package/src/infrastructure/utils/job-metadata/job-metadata-format.util.README.md +0 -209
- package/src/infrastructure/utils/job-metadata/job-metadata-lifecycle.util.README.md +0 -311
- package/src/infrastructure/utils/job-metadata/job-metadata-queries.util.README.md +0 -332
- package/src/infrastructure/utils/job-metadata/job-metadata.types.README.md +0 -446
- package/src/infrastructure/utils/job-metadata.README.md +0 -268
- package/src/infrastructure/utils/timing-helpers.util.ts +0 -56
- package/src/infrastructure/utils/type-guards.util.README.md +0 -371
- package/src/infrastructure/validators/index.README.md +0 -205
- package/src/infrastructure/validators/nsfw-validator.README.md +0 -309
- package/src/presentation/hooks/index.README.md +0 -224
- package/src/presentation/hooks/use-fal-generation.README.md +0 -398
- package/src/presentation/hooks/use-model-capabilities.ts +0 -99
- package/src/presentation/hooks/use-models.README.md +0 -318
- package/src/registry/global-capabilities.ts +0 -75
- package/src/registry/index.ts +0 -50
- package/src/registry/model-registry.service.ts +0 -93
- package/src/registry/model-registry.types.ts +0 -106
- package/src/registry/models/index.ts +0 -6
- package/src/registry/models/sora-2.config.ts +0 -95
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
# useModels Hook
|
|
2
|
-
|
|
3
|
-
React hook for managing FAL AI model selection, pricing, and model information.
|
|
4
|
-
|
|
5
|
-
**Location:** `src/presentation/hooks/use-models.ts`
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
The `useModels` hook provides functionality for managing FAL AI models including model selection, pricing information, model lists, and refresh capabilities. It handles model state management and provides easy access to model configurations.
|
|
10
|
-
|
|
11
|
-
## Purpose
|
|
12
|
-
|
|
13
|
-
Simplifies model management in React components by:
|
|
14
|
-
- Providing filtered model lists by type
|
|
15
|
-
- Managing selected model state
|
|
16
|
-
- Calculating credit costs dynamically
|
|
17
|
-
- Handling model refresh operations
|
|
18
|
-
- Supporting initial and default model configuration
|
|
19
|
-
|
|
20
|
-
## Import
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { useModels } from '@umituz/react-native-ai-fal-provider';
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Parameters
|
|
27
|
-
|
|
28
|
-
**Props:** `UseModelsProps`
|
|
29
|
-
|
|
30
|
-
| Parameter | Type | Required | Description |
|
|
31
|
-
|-----------|------|----------|-------------|
|
|
32
|
-
| `type` | `ModelType` | ✅ Yes | Model type filter |
|
|
33
|
-
| `config` | `ModelSelectionConfig` | ❌ No | Optional configuration |
|
|
34
|
-
|
|
35
|
-
**Model Types:**
|
|
36
|
-
- `text-to-image`: Text to image generation models
|
|
37
|
-
- `text-to-video`: Text to video generation models
|
|
38
|
-
- `image-to-video`: Image to video conversion models
|
|
39
|
-
- `text-to-voice`: Text to voice generation models
|
|
40
|
-
|
|
41
|
-
**Configuration Options:**
|
|
42
|
-
- `initialModelId`: Model ID to select initially
|
|
43
|
-
- `defaultModelId`: Fallback model ID if initial not found
|
|
44
|
-
- `defaultCreditCost`: Default cost if model pricing unavailable
|
|
45
|
-
|
|
46
|
-
**Implementation:** See `src/presentation/hooks/use-models.ts` for complete type definitions
|
|
47
|
-
|
|
48
|
-
**Related:**
|
|
49
|
-
- Model types: `src/domain/types/model-selection.types.ts`
|
|
50
|
-
- Model constants: `src/domain/constants/default-models.constants.ts`
|
|
51
|
-
|
|
52
|
-
## Return Values
|
|
53
|
-
|
|
54
|
-
**Result:** `UseModelsReturn`
|
|
55
|
-
|
|
56
|
-
| Property | Type | Description |
|
|
57
|
-
|----------|------|-------------|
|
|
58
|
-
| `models` | `FalModelConfig[]` | Array of available models for type |
|
|
59
|
-
| `selectedModel` | `FalModelConfig \| null` | Currently selected model object |
|
|
60
|
-
| `selectModel` | `function` | Function to select a model by ID |
|
|
61
|
-
| `creditCost` | `number` | Credit cost of selected model |
|
|
62
|
-
| `modelId` | `string` | ID of selected model |
|
|
63
|
-
| `isLoading` | `boolean` | True if models are loading |
|
|
64
|
-
| `error` | `string \| null` | Error message if loading failed |
|
|
65
|
-
| `refreshModels` | `function` | Function to refresh model list |
|
|
66
|
-
|
|
67
|
-
**Related:**
|
|
68
|
-
- Model config types: `src/domain/types/model-selection.types.ts`
|
|
69
|
-
|
|
70
|
-
## Methods
|
|
71
|
-
|
|
72
|
-
### selectModel
|
|
73
|
-
|
|
74
|
-
Select a model by ID.
|
|
75
|
-
|
|
76
|
-
**Parameters:**
|
|
77
|
-
- `id`: Model ID to select
|
|
78
|
-
|
|
79
|
-
**Usage:**
|
|
80
|
-
Call this function when user selects a model from UI. Updates `selectedModel`, `modelId`, and `creditCost` automatically. Pass model ID from model list.
|
|
81
|
-
|
|
82
|
-
### refreshModels
|
|
83
|
-
|
|
84
|
-
Refresh the model list from source.
|
|
85
|
-
|
|
86
|
-
**Usage:**
|
|
87
|
-
Call this function to reload models. Useful for updating model list after changes or when retrying after failed load.
|
|
88
|
-
|
|
89
|
-
## Usage Guidelines
|
|
90
|
-
|
|
91
|
-
### For Model Selection UI
|
|
92
|
-
|
|
93
|
-
**Basic Setup:**
|
|
94
|
-
1. Import `useModels` from package
|
|
95
|
-
2. Pass model type as prop
|
|
96
|
-
3. Provide optional config for default/initial model
|
|
97
|
-
4. Render model list from `models` array
|
|
98
|
-
5. Use `selectModel()` when user selects
|
|
99
|
-
|
|
100
|
-
**Model Display:**
|
|
101
|
-
- Show model name from `model.name`
|
|
102
|
-
- Display cost from `model.pricing?.freeUserCost`
|
|
103
|
-
- Use `model.id` as value for selection
|
|
104
|
-
- Show `creditCost` for selected model
|
|
105
|
-
|
|
106
|
-
**Related:**
|
|
107
|
-
- Default models: `src/domain/constants/default-models.constants.ts`
|
|
108
|
-
- Model types: `src/domain/types/model-selection.types.ts`
|
|
109
|
-
|
|
110
|
-
### For Pricing Display
|
|
111
|
-
|
|
112
|
-
**Cost Information:**
|
|
113
|
-
1. Use `creditCost` for selected model cost
|
|
114
|
-
2. Display cost in UI before generation
|
|
115
|
-
3. Update automatically when model changes
|
|
116
|
-
4. Handle missing cost with `defaultCreditCost`
|
|
117
|
-
|
|
118
|
-
**Pricing Structure:**
|
|
119
|
-
- Free user cost: `model.pricing?.freeUserCost`
|
|
120
|
-
- Paid user cost: `model.pricing?.paidUserCost`
|
|
121
|
-
- Credit cost: Total credits consumed per generation
|
|
122
|
-
|
|
123
|
-
### For Initial Model Selection
|
|
124
|
-
|
|
125
|
-
**Configuration:**
|
|
126
|
-
1. Set `initialModelId` for pre-selected model
|
|
127
|
-
2. Set `defaultModelId` as fallback
|
|
128
|
-
3. Set `defaultCreditCost` for pricing fallback
|
|
129
|
-
4. Handle case where initial model not found
|
|
130
|
-
|
|
131
|
-
**Selection Priority:**
|
|
132
|
-
1. Try to select `initialModelId` if provided
|
|
133
|
-
2. Fall back to `defaultModelId` if initial not found
|
|
134
|
-
3. Select first model if neither provided
|
|
135
|
-
4. Use `defaultCreditCost` if pricing unavailable
|
|
136
|
-
|
|
137
|
-
### For Error Handling
|
|
138
|
-
|
|
139
|
-
**Loading Errors:**
|
|
140
|
-
1. Check `error` for error message
|
|
141
|
-
2. Display error to user
|
|
142
|
-
3. Provide `refreshModels()` button
|
|
143
|
-
4. Show loading indicator when `isLoading` is true
|
|
144
|
-
|
|
145
|
-
**Error Scenarios:**
|
|
146
|
-
- Invalid model type
|
|
147
|
-
- Model list loading failure
|
|
148
|
-
- Model not found (shouldn't occur with defaults)
|
|
149
|
-
- Configuration errors
|
|
150
|
-
|
|
151
|
-
### For Model Type Filtering
|
|
152
|
-
|
|
153
|
-
**Available Types:**
|
|
154
|
-
- Text-to-image: Flux models (Schnell, Dev, Pro)
|
|
155
|
-
- Text-to-video: Hunyuan, MiniMax, Kling, Mochi
|
|
156
|
-
- Image-to-video: Image-to-video conversion models
|
|
157
|
-
- Text-to-voice: Voice generation models
|
|
158
|
-
|
|
159
|
-
**Filtering:**
|
|
160
|
-
- Models automatically filtered by `type` prop
|
|
161
|
-
- Only matching models included in `models` array
|
|
162
|
-
- Use separate hook instances for different types
|
|
163
|
-
|
|
164
|
-
**Related:**
|
|
165
|
-
- Model definitions: `src/domain/constants/models/`
|
|
166
|
-
|
|
167
|
-
## Best Practices
|
|
168
|
-
|
|
169
|
-
### 1. Always Handle Loading State
|
|
170
|
-
|
|
171
|
-
Check `isLoading` before rendering:
|
|
172
|
-
- Show loading indicator when true
|
|
173
|
-
- Disable model selection during load
|
|
174
|
-
- Handle empty state appropriately
|
|
175
|
-
- Provide user feedback
|
|
176
|
-
|
|
177
|
-
### 2. Provide Default Configuration
|
|
178
|
-
|
|
179
|
-
Always provide sensible defaults:
|
|
180
|
-
- Set `defaultModelId` for fallback
|
|
181
|
-
- Set `defaultCreditCost` for pricing
|
|
182
|
-
- Use `initialModelId` for pre-selection
|
|
183
|
-
- Handle missing models gracefully
|
|
184
|
-
|
|
185
|
-
### 3. Display Clear Pricing
|
|
186
|
-
|
|
187
|
-
Show cost information prominently:
|
|
188
|
-
- Display `creditCost` before generation
|
|
189
|
-
- Show cost per model in list
|
|
190
|
-
- Update cost when model changes
|
|
191
|
-
- Warn about high-cost models
|
|
192
|
-
|
|
193
|
-
### 4. Handle Model Changes
|
|
194
|
-
|
|
195
|
-
Respond to model selection:
|
|
196
|
-
- Update generation preview
|
|
197
|
-
- Refresh pricing display
|
|
198
|
-
- Clear previous generation
|
|
199
|
-
- Update configuration options
|
|
200
|
-
|
|
201
|
-
### 5. Support Model Refresh
|
|
202
|
-
|
|
203
|
-
Provide refresh functionality:
|
|
204
|
-
- Add refresh button in UI
|
|
205
|
-
- Call `refreshModels()` on error
|
|
206
|
-
- Show refresh status
|
|
207
|
-
- Handle refresh success/failure
|
|
208
|
-
|
|
209
|
-
## For AI Agents
|
|
210
|
-
|
|
211
|
-
### When Using useModels
|
|
212
|
-
|
|
213
|
-
**DO:**
|
|
214
|
-
- Import from package root
|
|
215
|
-
- Provide model type prop
|
|
216
|
-
- Set default configuration
|
|
217
|
-
- Handle loading state
|
|
218
|
-
- Display pricing information
|
|
219
|
-
- Support model refresh
|
|
220
|
-
- Handle errors gracefully
|
|
221
|
-
|
|
222
|
-
**DON'T:**
|
|
223
|
-
- Skip model type prop
|
|
224
|
-
- Forget default configuration
|
|
225
|
-
- Ignore loading states
|
|
226
|
-
- Hide pricing from users
|
|
227
|
-
- Prevent model refresh
|
|
228
|
-
- Ignore error states
|
|
229
|
-
- Use undefined model types
|
|
230
|
-
|
|
231
|
-
### When Building UI
|
|
232
|
-
|
|
233
|
-
**DO:**
|
|
234
|
-
- Show all available models
|
|
235
|
-
- Display model names clearly
|
|
236
|
-
- Show credit costs
|
|
237
|
-
- Highlight selected model
|
|
238
|
-
- Provide clear selection mechanism
|
|
239
|
-
- Support keyboard navigation
|
|
240
|
-
- Handle long model lists
|
|
241
|
-
|
|
242
|
-
**DON'T:**
|
|
243
|
-
- Hide model list from users
|
|
244
|
-
- Show technical IDs only
|
|
245
|
-
- Skip pricing display
|
|
246
|
-
- Make selection unclear
|
|
247
|
-
- Limit navigation options
|
|
248
|
-
- Ignore accessibility
|
|
249
|
-
- Show overwhelming lists
|
|
250
|
-
|
|
251
|
-
### When Adding Features
|
|
252
|
-
|
|
253
|
-
**For New Model Types:**
|
|
254
|
-
1. Add type to `ModelType` in types
|
|
255
|
-
2. Add model constants to appropriate file
|
|
256
|
-
3. Update filtering logic in hook
|
|
257
|
-
4. Update this README
|
|
258
|
-
5. Test with new type
|
|
259
|
-
|
|
260
|
-
**For New Config Options:**
|
|
261
|
-
1. Add to `ModelSelectionConfig` type
|
|
262
|
-
2. Implement logic in hook
|
|
263
|
-
3. Update TypeScript types
|
|
264
|
-
4. Document in this README
|
|
265
|
-
5. Provide examples
|
|
266
|
-
|
|
267
|
-
**For New Return Values:**
|
|
268
|
-
1. Add to `UseModelsReturn` type
|
|
269
|
-
2. Implement in hook logic
|
|
270
|
-
3. Update TypeScript types
|
|
271
|
-
4. Document usage
|
|
272
|
-
5. Test thoroughly
|
|
273
|
-
|
|
274
|
-
## Implementation Notes
|
|
275
|
-
|
|
276
|
-
**Location:** `src/presentation/hooks/use-models.ts`
|
|
277
|
-
|
|
278
|
-
**Dependencies:**
|
|
279
|
-
- Uses model constants from `src/domain/constants/default-models.constants.ts`
|
|
280
|
-
- Uses model types from `src/domain/types/model-selection.types.ts`
|
|
281
|
-
- Integrates with React hooks (useState, useMemo, useCallback)
|
|
282
|
-
- Filters models by type automatically
|
|
283
|
-
|
|
284
|
-
**TypeScript Types:**
|
|
285
|
-
- Strongly typed model configurations
|
|
286
|
-
- Type-safe model selection
|
|
287
|
-
- Proper null handling for selected model
|
|
288
|
-
- Generic pricing information
|
|
289
|
-
|
|
290
|
-
**Model Filtering:**
|
|
291
|
-
- Filters by `type` prop
|
|
292
|
-
- Returns array of matching models
|
|
293
|
-
- Maintains model order from constants
|
|
294
|
-
- Empty array if no models match
|
|
295
|
-
|
|
296
|
-
**State Management:**
|
|
297
|
-
- `models`: Computed from type filter (memoized)
|
|
298
|
-
- `selectedModel`: State updated by `selectModel()`
|
|
299
|
-
- `creditCost`: Derived from selected model pricing
|
|
300
|
-
- `isLoading`: Can be used for async loading in future
|
|
301
|
-
- `error`: Can be used for error handling in future
|
|
302
|
-
|
|
303
|
-
**Import:**
|
|
304
|
-
```typescript
|
|
305
|
-
import { useModels } from '@umituz/react-native-ai-fal-provider';
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
**Related:**
|
|
309
|
-
- useFalGeneration hook: `src/presentation/hooks/use-fal-generation.README.md`
|
|
310
|
-
- Hooks index: `src/presentation/hooks/index.README.md`
|
|
311
|
-
- Model types: `src/domain/types/model-selection.types.README.md`
|
|
312
|
-
|
|
313
|
-
## Related Documentation
|
|
314
|
-
|
|
315
|
-
- [useFalGeneration Hook](./use-fal-generation.README.md)
|
|
316
|
-
- [React Hooks Index](./index.README.md)
|
|
317
|
-
- [Model Selection Types](../../domain/types/model-selection.types.README.md)
|
|
318
|
-
- [Default Models](../../domain/constants/default-models.constants.README.md)
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Global Capabilities
|
|
3
|
-
* Shared capabilities across all AI models
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type {
|
|
7
|
-
AspectRatioOption,
|
|
8
|
-
GlobalCapabilities,
|
|
9
|
-
GlobalDefaults,
|
|
10
|
-
} from "./model-registry.types";
|
|
11
|
-
|
|
12
|
-
// =============================================================================
|
|
13
|
-
// VIDEO ASPECT RATIOS (No square - most video models don't support it)
|
|
14
|
-
// =============================================================================
|
|
15
|
-
|
|
16
|
-
export const VIDEO_ASPECT_RATIOS: AspectRatioOption[] = [
|
|
17
|
-
{
|
|
18
|
-
id: "16:9",
|
|
19
|
-
name: "Landscape",
|
|
20
|
-
description: "Best for YouTube, TV",
|
|
21
|
-
icon: "desktop-outline",
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
id: "9:16",
|
|
25
|
-
name: "Portrait",
|
|
26
|
-
description: "Best for TikTok, Reels",
|
|
27
|
-
icon: "phone-portrait-outline",
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
// =============================================================================
|
|
32
|
-
// IMAGE ASPECT RATIOS (Includes square)
|
|
33
|
-
// =============================================================================
|
|
34
|
-
|
|
35
|
-
export const IMAGE_ASPECT_RATIOS: AspectRatioOption[] = [
|
|
36
|
-
{
|
|
37
|
-
id: "16:9",
|
|
38
|
-
name: "Landscape",
|
|
39
|
-
description: "Wide format",
|
|
40
|
-
icon: "desktop-outline",
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
id: "9:16",
|
|
44
|
-
name: "Portrait",
|
|
45
|
-
description: "Tall format",
|
|
46
|
-
icon: "phone-portrait-outline",
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
id: "1:1",
|
|
50
|
-
name: "Square",
|
|
51
|
-
description: "Instagram, profile",
|
|
52
|
-
icon: "square-outline",
|
|
53
|
-
},
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
// =============================================================================
|
|
57
|
-
// GLOBAL CAPABILITIES
|
|
58
|
-
// =============================================================================
|
|
59
|
-
|
|
60
|
-
export const GLOBAL_CAPABILITIES: GlobalCapabilities = {
|
|
61
|
-
aspectRatios: {
|
|
62
|
-
video: VIDEO_ASPECT_RATIOS,
|
|
63
|
-
image: IMAGE_ASPECT_RATIOS,
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// =============================================================================
|
|
68
|
-
// GLOBAL DEFAULTS
|
|
69
|
-
// =============================================================================
|
|
70
|
-
|
|
71
|
-
export const GLOBAL_DEFAULTS: GlobalDefaults = {
|
|
72
|
-
maxPromptLength: 500,
|
|
73
|
-
supportsSound: false,
|
|
74
|
-
supportsStyle: true,
|
|
75
|
-
};
|
package/src/registry/index.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model Registry Index
|
|
3
|
-
* Export all registry types, models, and services
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Types
|
|
7
|
-
export type {
|
|
8
|
-
ModelType,
|
|
9
|
-
ModelProvider,
|
|
10
|
-
DurationOption,
|
|
11
|
-
ResolutionOption,
|
|
12
|
-
AspectRatioOption,
|
|
13
|
-
ModelCapabilities,
|
|
14
|
-
ModelPricing,
|
|
15
|
-
ModelDefaults,
|
|
16
|
-
ModelConfig,
|
|
17
|
-
ModelRegistry,
|
|
18
|
-
ResolvedCapabilities,
|
|
19
|
-
GlobalCapabilities,
|
|
20
|
-
GlobalDefaults,
|
|
21
|
-
} from "./model-registry.types";
|
|
22
|
-
|
|
23
|
-
// Global Capabilities
|
|
24
|
-
export {
|
|
25
|
-
VIDEO_ASPECT_RATIOS,
|
|
26
|
-
IMAGE_ASPECT_RATIOS,
|
|
27
|
-
GLOBAL_CAPABILITIES,
|
|
28
|
-
GLOBAL_DEFAULTS,
|
|
29
|
-
} from "./global-capabilities";
|
|
30
|
-
|
|
31
|
-
// Model Configurations
|
|
32
|
-
export {
|
|
33
|
-
SORA_2_DURATIONS,
|
|
34
|
-
SORA_2_RESOLUTIONS,
|
|
35
|
-
SORA_2_CREDITS_BY_DURATION,
|
|
36
|
-
SORA_2_TEXT_TO_VIDEO,
|
|
37
|
-
SORA_2_IMAGE_TO_VIDEO,
|
|
38
|
-
SORA_2_MODELS,
|
|
39
|
-
} from "./models";
|
|
40
|
-
|
|
41
|
-
// Registry Service
|
|
42
|
-
export {
|
|
43
|
-
MODEL_REGISTRY,
|
|
44
|
-
getModelConfig,
|
|
45
|
-
getModelsByType,
|
|
46
|
-
getEnabledModels,
|
|
47
|
-
getModelCapabilities,
|
|
48
|
-
getModelCreditCost,
|
|
49
|
-
getDefaultModelFromRegistry,
|
|
50
|
-
} from "./model-registry.service";
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model Registry Service
|
|
3
|
-
* Central registry for all AI model configurations
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type {
|
|
7
|
-
ModelConfig,
|
|
8
|
-
ModelRegistry,
|
|
9
|
-
ModelType,
|
|
10
|
-
ResolvedCapabilities,
|
|
11
|
-
} from "./model-registry.types";
|
|
12
|
-
import {
|
|
13
|
-
GLOBAL_DEFAULTS,
|
|
14
|
-
VIDEO_ASPECT_RATIOS,
|
|
15
|
-
IMAGE_ASPECT_RATIOS,
|
|
16
|
-
} from "./global-capabilities";
|
|
17
|
-
import { SORA_2_TEXT_TO_VIDEO, SORA_2_IMAGE_TO_VIDEO } from "./models";
|
|
18
|
-
|
|
19
|
-
// =============================================================================
|
|
20
|
-
// MODEL REGISTRY
|
|
21
|
-
// =============================================================================
|
|
22
|
-
|
|
23
|
-
export const MODEL_REGISTRY: ModelRegistry = {
|
|
24
|
-
[SORA_2_TEXT_TO_VIDEO.id]: SORA_2_TEXT_TO_VIDEO,
|
|
25
|
-
[SORA_2_IMAGE_TO_VIDEO.id]: SORA_2_IMAGE_TO_VIDEO,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// =============================================================================
|
|
29
|
-
// REGISTRY HELPERS
|
|
30
|
-
// =============================================================================
|
|
31
|
-
|
|
32
|
-
export function getModelConfig(modelId: string): ModelConfig | undefined {
|
|
33
|
-
return MODEL_REGISTRY[modelId];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function getModelsByType(type: ModelType): ModelConfig[] {
|
|
37
|
-
return Object.values(MODEL_REGISTRY).filter(
|
|
38
|
-
(model) => model.type === type && model.enabled
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function getEnabledModels(): ModelConfig[] {
|
|
43
|
-
return Object.values(MODEL_REGISTRY).filter((model) => model.enabled);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function getModelCapabilities(
|
|
47
|
-
modelId: string
|
|
48
|
-
): ResolvedCapabilities | undefined {
|
|
49
|
-
const config = MODEL_REGISTRY[modelId];
|
|
50
|
-
if (!config) return undefined;
|
|
51
|
-
|
|
52
|
-
const isVideoModel =
|
|
53
|
-
config.type === "text-to-video" || config.type === "image-to-video";
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
durations: config.capabilities.durations ?? [],
|
|
57
|
-
resolutions: config.capabilities.resolutions ?? [],
|
|
58
|
-
aspectRatios:
|
|
59
|
-
config.capabilities.aspectRatios ??
|
|
60
|
-
(isVideoModel ? VIDEO_ASPECT_RATIOS : IMAGE_ASPECT_RATIOS),
|
|
61
|
-
maxPromptLength:
|
|
62
|
-
config.capabilities.maxPromptLength ?? GLOBAL_DEFAULTS.maxPromptLength,
|
|
63
|
-
supportsSound:
|
|
64
|
-
config.capabilities.supportsSound ?? GLOBAL_DEFAULTS.supportsSound,
|
|
65
|
-
supportsStyle:
|
|
66
|
-
config.capabilities.supportsStyle ?? GLOBAL_DEFAULTS.supportsStyle,
|
|
67
|
-
pricing: config.pricing,
|
|
68
|
-
defaults: config.defaults,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function getModelCreditCost(modelId: string, duration: number): number {
|
|
73
|
-
const config = MODEL_REGISTRY[modelId];
|
|
74
|
-
if (!config) return 0;
|
|
75
|
-
|
|
76
|
-
if (config.pricing.creditsByDuration) {
|
|
77
|
-
return config.pricing.creditsByDuration[duration] ?? 0;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (config.pricing.costPerSecond) {
|
|
81
|
-
const dollarCost = config.pricing.costPerSecond * duration;
|
|
82
|
-
return Math.ceil(dollarCost * 10);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return config.pricing.costPerGeneration ?? 0;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function getDefaultModelFromRegistry(
|
|
89
|
-
type: ModelType
|
|
90
|
-
): ModelConfig | undefined {
|
|
91
|
-
const models = getModelsByType(type);
|
|
92
|
-
return models[0];
|
|
93
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model Registry Types
|
|
3
|
-
* Type definitions for model capabilities and configuration
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// =============================================================================
|
|
7
|
-
// PRIMITIVE TYPES
|
|
8
|
-
// =============================================================================
|
|
9
|
-
|
|
10
|
-
export type ModelType = "text-to-video" | "image-to-video" | "text-to-image";
|
|
11
|
-
export type ModelProvider = "fal" | "openai" | "stability" | "runway";
|
|
12
|
-
|
|
13
|
-
// =============================================================================
|
|
14
|
-
// OPTION TYPES
|
|
15
|
-
// =============================================================================
|
|
16
|
-
|
|
17
|
-
export interface DurationOption {
|
|
18
|
-
value: number;
|
|
19
|
-
label: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface ResolutionOption {
|
|
23
|
-
value: string;
|
|
24
|
-
label: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface AspectRatioOption {
|
|
28
|
-
id: string;
|
|
29
|
-
name: string;
|
|
30
|
-
description: string;
|
|
31
|
-
icon: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// =============================================================================
|
|
35
|
-
// CAPABILITIES
|
|
36
|
-
// =============================================================================
|
|
37
|
-
|
|
38
|
-
export interface ModelCapabilities {
|
|
39
|
-
durations?: DurationOption[];
|
|
40
|
-
resolutions?: ResolutionOption[];
|
|
41
|
-
aspectRatios?: AspectRatioOption[];
|
|
42
|
-
maxPromptLength?: number;
|
|
43
|
-
supportsSound?: boolean;
|
|
44
|
-
supportsStyle?: boolean;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface ModelPricing {
|
|
48
|
-
costPerSecond?: number;
|
|
49
|
-
costPerGeneration?: number;
|
|
50
|
-
creditsByDuration?: Record<number, number>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface ModelDefaults {
|
|
54
|
-
duration: number;
|
|
55
|
-
resolution: string;
|
|
56
|
-
aspectRatio: string;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// =============================================================================
|
|
60
|
-
// MODEL CONFIG
|
|
61
|
-
// =============================================================================
|
|
62
|
-
|
|
63
|
-
export interface ModelConfig {
|
|
64
|
-
id: string;
|
|
65
|
-
name: string;
|
|
66
|
-
type: ModelType;
|
|
67
|
-
provider: ModelProvider;
|
|
68
|
-
capabilities: ModelCapabilities;
|
|
69
|
-
pricing: ModelPricing;
|
|
70
|
-
defaults: ModelDefaults;
|
|
71
|
-
enabled: boolean;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// =============================================================================
|
|
75
|
-
// REGISTRY TYPES
|
|
76
|
-
// =============================================================================
|
|
77
|
-
|
|
78
|
-
export type ModelRegistry = Record<string, ModelConfig>;
|
|
79
|
-
|
|
80
|
-
export interface ResolvedCapabilities {
|
|
81
|
-
durations: DurationOption[];
|
|
82
|
-
resolutions: ResolutionOption[];
|
|
83
|
-
aspectRatios: AspectRatioOption[];
|
|
84
|
-
maxPromptLength: number;
|
|
85
|
-
supportsSound: boolean;
|
|
86
|
-
supportsStyle: boolean;
|
|
87
|
-
pricing: ModelPricing;
|
|
88
|
-
defaults: ModelDefaults;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// =============================================================================
|
|
92
|
-
// GLOBAL CAPABILITIES
|
|
93
|
-
// =============================================================================
|
|
94
|
-
|
|
95
|
-
export interface GlobalCapabilities {
|
|
96
|
-
aspectRatios: {
|
|
97
|
-
video: AspectRatioOption[];
|
|
98
|
-
image: AspectRatioOption[];
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface GlobalDefaults {
|
|
103
|
-
maxPromptLength: number;
|
|
104
|
-
supportsSound: boolean;
|
|
105
|
-
supportsStyle: boolean;
|
|
106
|
-
}
|