@ruvector/edge-net 0.5.0 → 0.5.3

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.
@@ -0,0 +1,109 @@
1
+ /**
2
+ * @ruvector/edge-net Models Module
3
+ *
4
+ * Model optimization, quantization, and management for edge deployment
5
+ *
6
+ * @module @ruvector/edge-net/models
7
+ */
8
+
9
+ // Model optimization exports
10
+ export {
11
+ ModelOptimizer,
12
+ QuantizationEngine,
13
+ PruningEngine,
14
+ OnnxOptimizer,
15
+ DistillationEngine,
16
+ BenchmarkEngine,
17
+ TARGET_MODELS,
18
+ QUANTIZATION_CONFIGS,
19
+ PRUNING_STRATEGIES,
20
+ default,
21
+ } from './model-optimizer.js';
22
+
23
+ // Model utilities exports
24
+ export {
25
+ loadRegistry,
26
+ saveRegistry,
27
+ getModel,
28
+ getProfile,
29
+ formatSize,
30
+ parseSize,
31
+ hashFile,
32
+ hashBuffer,
33
+ getModelCacheDir,
34
+ isModelCached,
35
+ getCachedModelSize,
36
+ getDirectorySize,
37
+ estimateQuantizedSize,
38
+ getRecommendedQuantization,
39
+ downloadFile,
40
+ pinToIPFS,
41
+ getIPFSUrl,
42
+ getGCSUrl,
43
+ checkGCSExists,
44
+ createAdapterMetadata,
45
+ getAdapterPath,
46
+ createBenchmarkResult,
47
+ DEFAULT_CACHE_DIR,
48
+ REGISTRY_PATH,
49
+ GCS_CONFIG,
50
+ IPFS_CONFIG,
51
+ LORA_DEFAULTS,
52
+ } from './model-utils.js';
53
+
54
+ // Registry utilities
55
+ import { readFileSync } from 'fs';
56
+ import { join, dirname } from 'path';
57
+ import { fileURLToPath } from 'url';
58
+
59
+ const __filename = fileURLToPath(import.meta.url);
60
+ const __dirname = dirname(__filename);
61
+
62
+ /**
63
+ * Get the full model registry
64
+ * @returns {Object} Registry object
65
+ */
66
+ export function getRegistry() {
67
+ try {
68
+ const registryPath = join(__dirname, 'registry.json');
69
+ return JSON.parse(readFileSync(registryPath, 'utf-8'));
70
+ } catch (error) {
71
+ console.error('[Models] Failed to load registry:', error.message);
72
+ return { version: '0.0.0', models: {}, profiles: {} };
73
+ }
74
+ }
75
+
76
+ /**
77
+ * List all available models
78
+ * @param {Object} options - Filter options
79
+ * @param {string} [options.type] - Filter by type (embedding, generation)
80
+ * @param {number} [options.tier] - Filter by tier (1-4)
81
+ * @returns {Array} Array of model entries
82
+ */
83
+ export function listModels(options = {}) {
84
+ const registry = getRegistry();
85
+ return Object.entries(registry.models)
86
+ .filter(([_, m]) => !options.type || m.type === options.type)
87
+ .filter(([_, m]) => !options.tier || m.tier === options.tier)
88
+ .map(([id, model]) => ({ id, ...model }));
89
+ }
90
+
91
+ /**
92
+ * Get recommended model profile for a use case
93
+ * @param {string} profileId - Profile identifier
94
+ * @returns {Object|null} Profile configuration
95
+ */
96
+ export function getRecommendedProfile(profileId) {
97
+ const registry = getRegistry();
98
+ return registry.profiles[profileId] || null;
99
+ }
100
+
101
+ /**
102
+ * Get all available profiles
103
+ * @returns {Array} Array of profile entries
104
+ */
105
+ export function listProfiles() {
106
+ const registry = getRegistry();
107
+ return Object.entries(registry.profiles)
108
+ .map(([id, profile]) => ({ id, ...profile }));
109
+ }