n8n-nodes-openrouter-selector 0.3.0
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/README.md +307 -0
- package/dist/credentials/OpenRouterApi.credentials.d.ts +10 -0
- package/dist/credentials/OpenRouterApi.credentials.d.ts.map +1 -0
- package/dist/credentials/OpenRouterApi.credentials.js +38 -0
- package/dist/credentials/OpenRouterApi.credentials.js.map +1 -0
- package/dist/credentials/SupabaseModelCatalogApi.credentials.d.ts +10 -0
- package/dist/credentials/SupabaseModelCatalogApi.credentials.d.ts.map +1 -0
- package/dist/credentials/SupabaseModelCatalogApi.credentials.js +51 -0
- package/dist/credentials/SupabaseModelCatalogApi.credentials.js.map +1 -0
- package/dist/nodes/OpenRouterChatCompletion/OpenRouterChatCompletion.node.d.ts +11 -0
- package/dist/nodes/OpenRouterChatCompletion/OpenRouterChatCompletion.node.d.ts.map +1 -0
- package/dist/nodes/OpenRouterChatCompletion/OpenRouterChatCompletion.node.js +300 -0
- package/dist/nodes/OpenRouterChatCompletion/OpenRouterChatCompletion.node.js.map +1 -0
- package/dist/nodes/OpenRouterChatCompletion/openrouter-chat.svg +13 -0
- package/dist/nodes/OpenRouterModelSelector/OpenRouterModelSelector.node.d.ts +14 -0
- package/dist/nodes/OpenRouterModelSelector/OpenRouterModelSelector.node.d.ts.map +1 -0
- package/dist/nodes/OpenRouterModelSelector/OpenRouterModelSelector.node.js +412 -0
- package/dist/nodes/OpenRouterModelSelector/OpenRouterModelSelector.node.js.map +1 -0
- package/dist/nodes/OpenRouterModelSelector/modelScoring.d.ts +28 -0
- package/dist/nodes/OpenRouterModelSelector/modelScoring.d.ts.map +1 -0
- package/dist/nodes/OpenRouterModelSelector/modelScoring.js +384 -0
- package/dist/nodes/OpenRouterModelSelector/modelScoring.js.map +1 -0
- package/dist/nodes/OpenRouterModelSelector/openrouter-selector.svg +37 -0
- package/dist/nodes/OpenRouterModelSelector/taskProfiles.d.ts +39 -0
- package/dist/nodes/OpenRouterModelSelector/taskProfiles.d.ts.map +1 -0
- package/dist/nodes/OpenRouterModelSelector/taskProfiles.js +271 -0
- package/dist/nodes/OpenRouterModelSelector/taskProfiles.js.map +1 -0
- package/dist/nodes/OpenRouterModelSelector/types.d.ts +217 -0
- package/dist/nodes/OpenRouterModelSelector/types.d.ts.map +1 -0
- package/dist/nodes/OpenRouterModelSelector/types.js +44 -0
- package/dist/nodes/OpenRouterModelSelector/types.js.map +1 -0
- package/dist/nodes/OpenRouterSmartChat/OpenRouterSmartChat.node.d.ts +11 -0
- package/dist/nodes/OpenRouterSmartChat/OpenRouterSmartChat.node.d.ts.map +1 -0
- package/dist/nodes/OpenRouterSmartChat/OpenRouterSmartChat.node.js +657 -0
- package/dist/nodes/OpenRouterSmartChat/OpenRouterSmartChat.node.js.map +1 -0
- package/dist/nodes/OpenRouterSmartChat/modelScoring.d.ts +28 -0
- package/dist/nodes/OpenRouterSmartChat/modelScoring.d.ts.map +1 -0
- package/dist/nodes/OpenRouterSmartChat/modelScoring.js +384 -0
- package/dist/nodes/OpenRouterSmartChat/modelScoring.js.map +1 -0
- package/dist/nodes/OpenRouterSmartChat/openrouter-smart.svg +11 -0
- package/dist/nodes/OpenRouterSmartChat/taskProfiles.d.ts +39 -0
- package/dist/nodes/OpenRouterSmartChat/taskProfiles.d.ts.map +1 -0
- package/dist/nodes/OpenRouterSmartChat/taskProfiles.js +271 -0
- package/dist/nodes/OpenRouterSmartChat/taskProfiles.js.map +1 -0
- package/dist/nodes/OpenRouterSmartChat/types.d.ts +217 -0
- package/dist/nodes/OpenRouterSmartChat/types.d.ts.map +1 -0
- package/dist/nodes/OpenRouterSmartChat/types.js +44 -0
- package/dist/nodes/OpenRouterSmartChat/types.js.map +1 -0
- package/dist/nodes/OpenRouterSmartEmbedding/OpenRouterEmbeddings.class.d.ts +48 -0
- package/dist/nodes/OpenRouterSmartEmbedding/OpenRouterEmbeddings.class.d.ts.map +1 -0
- package/dist/nodes/OpenRouterSmartEmbedding/OpenRouterEmbeddings.class.js +265 -0
- package/dist/nodes/OpenRouterSmartEmbedding/OpenRouterEmbeddings.class.js.map +1 -0
- package/dist/nodes/OpenRouterSmartEmbedding/OpenRouterSmartEmbedding.node.d.ts +16 -0
- package/dist/nodes/OpenRouterSmartEmbedding/OpenRouterSmartEmbedding.node.d.ts.map +1 -0
- package/dist/nodes/OpenRouterSmartEmbedding/OpenRouterSmartEmbedding.node.js +177 -0
- package/dist/nodes/OpenRouterSmartEmbedding/OpenRouterSmartEmbedding.node.js.map +1 -0
- package/dist/nodes/OpenRouterSmartEmbedding/openrouter-embed.svg +22 -0
- package/dist/nodes/shared/contentAnalyzer.d.ts +16 -0
- package/dist/nodes/shared/contentAnalyzer.d.ts.map +1 -0
- package/dist/nodes/shared/contentAnalyzer.js +256 -0
- package/dist/nodes/shared/contentAnalyzer.js.map +1 -0
- package/dist/nodes/shared/embeddingScoring.d.ts +12 -0
- package/dist/nodes/shared/embeddingScoring.d.ts.map +1 -0
- package/dist/nodes/shared/embeddingScoring.js +329 -0
- package/dist/nodes/shared/embeddingScoring.js.map +1 -0
- package/dist/nodes/shared/types.d.ts +131 -0
- package/dist/nodes/shared/types.d.ts.map +1 -0
- package/dist/nodes/shared/types.js +24 -0
- package/dist/nodes/shared/types.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Task Profiles Configuration
|
|
4
|
+
*
|
|
5
|
+
* Defines which benchmarks are relevant for each task category
|
|
6
|
+
* and provider-specific boosts based on empirical performance.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TASK_PROFILES = void 0;
|
|
10
|
+
exports.getTaskProfile = getTaskProfile;
|
|
11
|
+
exports.getTaskCategories = getTaskCategories;
|
|
12
|
+
exports.getProviderBoost = getProviderBoost;
|
|
13
|
+
exports.normalizeBenchmarkWeights = normalizeBenchmarkWeights;
|
|
14
|
+
exports.getTaskDescription = getTaskDescription;
|
|
15
|
+
/**
|
|
16
|
+
* Task Profiles
|
|
17
|
+
*
|
|
18
|
+
* Each profile defines:
|
|
19
|
+
* - displayName: Human-readable task name
|
|
20
|
+
* - benchmarkWeights: Which benchmarks matter and their relative importance (should sum to 1.0)
|
|
21
|
+
* - providerBoosts: Multipliers for providers known to excel at this task
|
|
22
|
+
* - minContextLength: Minimum context window required
|
|
23
|
+
* - Optional requirements (JSON mode, vision, etc.)
|
|
24
|
+
*/
|
|
25
|
+
exports.TASK_PROFILES = {
|
|
26
|
+
// ===========================================================================
|
|
27
|
+
// Translation
|
|
28
|
+
// ===========================================================================
|
|
29
|
+
translation: {
|
|
30
|
+
displayName: 'Translation',
|
|
31
|
+
benchmarkWeights: {
|
|
32
|
+
// LMSYS Elo reflects human preference for natural language
|
|
33
|
+
lmsys_elo: 0.4,
|
|
34
|
+
// Language understanding from LiveBench
|
|
35
|
+
livebench_language: 0.25,
|
|
36
|
+
// General intelligence for nuanced translations
|
|
37
|
+
aa_intelligence_index: 0.2,
|
|
38
|
+
// Instruction following for format compliance
|
|
39
|
+
livebench_instruction_following: 0.15,
|
|
40
|
+
},
|
|
41
|
+
providerBoosts: {
|
|
42
|
+
// DeepSeek excels at Chinese <-> English
|
|
43
|
+
deepseek: 1.2,
|
|
44
|
+
// Qwen has strong multilingual capabilities
|
|
45
|
+
qwen: 1.15,
|
|
46
|
+
// Claude is excellent at nuanced translation
|
|
47
|
+
anthropic: 1.1,
|
|
48
|
+
},
|
|
49
|
+
minContextLength: 8000,
|
|
50
|
+
},
|
|
51
|
+
// ===========================================================================
|
|
52
|
+
// Coding
|
|
53
|
+
// ===========================================================================
|
|
54
|
+
coding: {
|
|
55
|
+
displayName: 'Coding & Development',
|
|
56
|
+
benchmarkWeights: {
|
|
57
|
+
// Dedicated coding benchmarks are most relevant
|
|
58
|
+
aa_coding_index: 0.35,
|
|
59
|
+
livebench_coding: 0.30,
|
|
60
|
+
lmsys_elo_coding: 0.20,
|
|
61
|
+
// Reasoning helps with complex algorithms
|
|
62
|
+
livebench_reasoning: 0.15,
|
|
63
|
+
},
|
|
64
|
+
providerBoosts: {
|
|
65
|
+
// Claude is consistently top for coding
|
|
66
|
+
anthropic: 1.15,
|
|
67
|
+
// OpenAI GPT-4 variants are strong
|
|
68
|
+
openai: 1.1,
|
|
69
|
+
// DeepSeek Coder is competitive
|
|
70
|
+
deepseek: 1.08,
|
|
71
|
+
},
|
|
72
|
+
minContextLength: 32000, // Code often needs large context
|
|
73
|
+
requireJsonMode: false, // Useful but not required
|
|
74
|
+
},
|
|
75
|
+
// ===========================================================================
|
|
76
|
+
// Analysis
|
|
77
|
+
// ===========================================================================
|
|
78
|
+
analysis: {
|
|
79
|
+
displayName: 'Data Analysis & Reasoning',
|
|
80
|
+
benchmarkWeights: {
|
|
81
|
+
// Intelligence index for complex analysis
|
|
82
|
+
aa_intelligence_index: 0.30,
|
|
83
|
+
// Data analysis specific benchmark
|
|
84
|
+
livebench_data_analysis: 0.25,
|
|
85
|
+
// Reasoning for logical conclusions
|
|
86
|
+
livebench_reasoning: 0.25,
|
|
87
|
+
// Human preference for coherent analysis
|
|
88
|
+
lmsys_elo: 0.20,
|
|
89
|
+
},
|
|
90
|
+
providerBoosts: {
|
|
91
|
+
// Claude excels at analytical tasks
|
|
92
|
+
anthropic: 1.15,
|
|
93
|
+
// OpenAI o1/o3 models are strong reasoners
|
|
94
|
+
openai: 1.1,
|
|
95
|
+
// Google Gemini is good at analysis
|
|
96
|
+
google: 1.05,
|
|
97
|
+
},
|
|
98
|
+
minContextLength: 16000,
|
|
99
|
+
},
|
|
100
|
+
// ===========================================================================
|
|
101
|
+
// Vision (Multimodal)
|
|
102
|
+
// ===========================================================================
|
|
103
|
+
vision: {
|
|
104
|
+
displayName: 'Vision & Image Analysis',
|
|
105
|
+
benchmarkWeights: {
|
|
106
|
+
// General intelligence matters for image understanding
|
|
107
|
+
aa_intelligence_index: 0.40,
|
|
108
|
+
// Human preference for vision tasks
|
|
109
|
+
lmsys_elo: 0.30,
|
|
110
|
+
// Instruction following for structured output
|
|
111
|
+
livebench_instruction_following: 0.30,
|
|
112
|
+
},
|
|
113
|
+
providerBoosts: {
|
|
114
|
+
// GPT-4V is the gold standard
|
|
115
|
+
openai: 1.15,
|
|
116
|
+
// Gemini has strong vision capabilities
|
|
117
|
+
google: 1.12,
|
|
118
|
+
// Claude 3 vision is competitive
|
|
119
|
+
anthropic: 1.08,
|
|
120
|
+
},
|
|
121
|
+
minContextLength: 8000,
|
|
122
|
+
requireVision: true,
|
|
123
|
+
},
|
|
124
|
+
// ===========================================================================
|
|
125
|
+
// Chat
|
|
126
|
+
// ===========================================================================
|
|
127
|
+
chat: {
|
|
128
|
+
displayName: 'Conversational Chat',
|
|
129
|
+
benchmarkWeights: {
|
|
130
|
+
// Human preference is paramount for chat
|
|
131
|
+
lmsys_elo: 0.50,
|
|
132
|
+
// Speed matters for responsive chat
|
|
133
|
+
aa_speed_index: 0.20,
|
|
134
|
+
// Language understanding
|
|
135
|
+
livebench_language: 0.15,
|
|
136
|
+
// Following conversation instructions
|
|
137
|
+
livebench_instruction_following: 0.15,
|
|
138
|
+
},
|
|
139
|
+
providerBoosts: {
|
|
140
|
+
// Claude is known for helpful, harmless chat
|
|
141
|
+
anthropic: 1.1,
|
|
142
|
+
// ChatGPT defined the category
|
|
143
|
+
openai: 1.08,
|
|
144
|
+
},
|
|
145
|
+
minContextLength: 8000,
|
|
146
|
+
},
|
|
147
|
+
// ===========================================================================
|
|
148
|
+
// Embedding
|
|
149
|
+
// ===========================================================================
|
|
150
|
+
embedding: {
|
|
151
|
+
displayName: 'Text Embedding',
|
|
152
|
+
benchmarkWeights: {
|
|
153
|
+
// Embedding quality correlates with language understanding
|
|
154
|
+
livebench_language: 0.40,
|
|
155
|
+
// Intelligence for semantic understanding
|
|
156
|
+
aa_intelligence_index: 0.35,
|
|
157
|
+
// Speed is important for batch embedding
|
|
158
|
+
aa_speed_index: 0.25,
|
|
159
|
+
},
|
|
160
|
+
providerBoosts: {
|
|
161
|
+
// OpenAI embeddings are industry standard
|
|
162
|
+
openai: 1.15,
|
|
163
|
+
// Cohere has specialized embedding models
|
|
164
|
+
cohere: 1.12,
|
|
165
|
+
},
|
|
166
|
+
minContextLength: 8000,
|
|
167
|
+
},
|
|
168
|
+
// ===========================================================================
|
|
169
|
+
// Summarization
|
|
170
|
+
// ===========================================================================
|
|
171
|
+
summarization: {
|
|
172
|
+
displayName: 'Text Summarization',
|
|
173
|
+
benchmarkWeights: {
|
|
174
|
+
// Language quality for summaries
|
|
175
|
+
livebench_language: 0.30,
|
|
176
|
+
// Intelligence for understanding complex docs
|
|
177
|
+
aa_intelligence_index: 0.25,
|
|
178
|
+
// Human preference for summary quality
|
|
179
|
+
lmsys_elo: 0.25,
|
|
180
|
+
// Following length/format instructions
|
|
181
|
+
livebench_instruction_following: 0.20,
|
|
182
|
+
},
|
|
183
|
+
providerBoosts: {
|
|
184
|
+
// Claude excels at summarization
|
|
185
|
+
anthropic: 1.12,
|
|
186
|
+
// Gemini with long context is good
|
|
187
|
+
google: 1.08,
|
|
188
|
+
},
|
|
189
|
+
minContextLength: 32000, // Need large context for long docs
|
|
190
|
+
},
|
|
191
|
+
// ===========================================================================
|
|
192
|
+
// Math
|
|
193
|
+
// ===========================================================================
|
|
194
|
+
math: {
|
|
195
|
+
displayName: 'Mathematical Reasoning',
|
|
196
|
+
benchmarkWeights: {
|
|
197
|
+
// Math-specific benchmarks
|
|
198
|
+
aa_math_index: 0.40,
|
|
199
|
+
livebench_math: 0.35,
|
|
200
|
+
// General reasoning ability
|
|
201
|
+
livebench_reasoning: 0.25,
|
|
202
|
+
},
|
|
203
|
+
providerBoosts: {
|
|
204
|
+
// DeepSeek excels at math
|
|
205
|
+
deepseek: 1.15,
|
|
206
|
+
// Qwen is strong in math
|
|
207
|
+
qwen: 1.12,
|
|
208
|
+
// OpenAI o1/o3 reasoning models
|
|
209
|
+
openai: 1.1,
|
|
210
|
+
},
|
|
211
|
+
minContextLength: 8000,
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Get task profile by category
|
|
216
|
+
*/
|
|
217
|
+
function getTaskProfile(task) {
|
|
218
|
+
return exports.TASK_PROFILES[task];
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Get all available task categories
|
|
222
|
+
*/
|
|
223
|
+
function getTaskCategories() {
|
|
224
|
+
return Object.keys(exports.TASK_PROFILES);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Get provider boost for a specific task and provider
|
|
228
|
+
*/
|
|
229
|
+
function getProviderBoost(task, provider) {
|
|
230
|
+
const profile = exports.TASK_PROFILES[task];
|
|
231
|
+
// Extract base provider name (e.g., "anthropic" from "anthropic/claude-sonnet-4")
|
|
232
|
+
const baseProvider = provider.split('/')[0].toLowerCase();
|
|
233
|
+
return profile.providerBoosts[baseProvider] ?? 1.0;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Normalize benchmark weights to ensure they sum to 1.0
|
|
237
|
+
*/
|
|
238
|
+
function normalizeBenchmarkWeights(weights) {
|
|
239
|
+
const sum = Object.values(weights).reduce((a, b) => a + b, 0);
|
|
240
|
+
if (sum === 0)
|
|
241
|
+
return weights;
|
|
242
|
+
const normalized = {};
|
|
243
|
+
for (const [key, value] of Object.entries(weights)) {
|
|
244
|
+
normalized[key] = value / sum;
|
|
245
|
+
}
|
|
246
|
+
return normalized;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Get human-readable description of task requirements
|
|
250
|
+
*/
|
|
251
|
+
function getTaskDescription(task) {
|
|
252
|
+
const profile = exports.TASK_PROFILES[task];
|
|
253
|
+
const requirements = [];
|
|
254
|
+
if (profile.minContextLength > 8000) {
|
|
255
|
+
requirements.push(`${(profile.minContextLength / 1000).toFixed(0)}K+ context`);
|
|
256
|
+
}
|
|
257
|
+
if (profile.requireVision) {
|
|
258
|
+
requirements.push('vision capable');
|
|
259
|
+
}
|
|
260
|
+
if (profile.requireJsonMode) {
|
|
261
|
+
requirements.push('JSON mode');
|
|
262
|
+
}
|
|
263
|
+
if (profile.requireDeterministic) {
|
|
264
|
+
requirements.push('deterministic');
|
|
265
|
+
}
|
|
266
|
+
const reqString = requirements.length > 0
|
|
267
|
+
? ` (requires: ${requirements.join(', ')})`
|
|
268
|
+
: '';
|
|
269
|
+
return `${profile.displayName}${reqString}`;
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=taskProfiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskProfiles.js","sourceRoot":"","sources":["../../../nodes/OpenRouterSmartChat/taskProfiles.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAsNH,wCAEC;AAKD,8CAEC;AAKD,4CAQC;AAKD,8DAWC;AAKD,gDAsBC;AAnRD;;;;;;;;;GASG;AACU,QAAA,aAAa,GAAsC;IAC9D,8EAA8E;IAC9E,cAAc;IACd,8EAA8E;IAC9E,WAAW,EAAE;QACX,WAAW,EAAE,aAAa;QAC1B,gBAAgB,EAAE;YAChB,2DAA2D;YAC3D,SAAS,EAAE,GAAG;YACd,wCAAwC;YACxC,kBAAkB,EAAE,IAAI;YACxB,gDAAgD;YAChD,qBAAqB,EAAE,GAAG;YAC1B,8CAA8C;YAC9C,+BAA+B,EAAE,IAAI;SACtC;QACD,cAAc,EAAE;YACd,yCAAyC;YACzC,QAAQ,EAAE,GAAG;YACb,4CAA4C;YAC5C,IAAI,EAAE,IAAI;YACV,6CAA6C;YAC7C,SAAS,EAAE,GAAG;SACf;QACD,gBAAgB,EAAE,IAAI;KACvB;IAED,8EAA8E;IAC9E,SAAS;IACT,8EAA8E;IAC9E,MAAM,EAAE;QACN,WAAW,EAAE,sBAAsB;QACnC,gBAAgB,EAAE;YAChB,gDAAgD;YAChD,eAAe,EAAE,IAAI;YACrB,gBAAgB,EAAE,IAAI;YACtB,gBAA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C,GAAG,KAAK,GAAG,GAAG,CAAC;IAChC,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,IAAkB;IACnD,MAAM,OAAO,GAAG,qBAAa,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,YAAY,GAAa,EAAE,CAAC;IAElC,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,EAAE,CAAC;QACpC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IACjF,CAAC;IACD,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;QAC1B,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;QAC5B,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;QACjC,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC;QACvC,CAAC,CAAC,eAAe,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QAC3C,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenRouter Model Selector - TypeScript Types & Interfaces
|
|
3
|
+
*/
|
|
4
|
+
export type TaskCategory = 'translation' | 'coding' | 'analysis' | 'vision' | 'chat' | 'embedding' | 'summarization' | 'math';
|
|
5
|
+
export type BudgetPreference = 'cheap' | 'balanced' | 'premium';
|
|
6
|
+
export interface BudgetThresholds {
|
|
7
|
+
/** Max price per 1K tokens in USD */
|
|
8
|
+
maxPricePerK: number;
|
|
9
|
+
/** Description for UI */
|
|
10
|
+
description: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const BUDGET_THRESHOLDS: Record<BudgetPreference, BudgetThresholds>;
|
|
13
|
+
export interface ModelCatalogEntry {
|
|
14
|
+
id: string;
|
|
15
|
+
model: string;
|
|
16
|
+
provider: string;
|
|
17
|
+
display_name: string;
|
|
18
|
+
price_prompt_per_1k_usd: number;
|
|
19
|
+
price_completion_per_1k_usd: number;
|
|
20
|
+
currency: string;
|
|
21
|
+
context_length: number;
|
|
22
|
+
supports_json: boolean;
|
|
23
|
+
supports_seed: boolean;
|
|
24
|
+
modality: string | null;
|
|
25
|
+
quality_estimate: number | null;
|
|
26
|
+
speed_estimate: number | null;
|
|
27
|
+
created_at: string;
|
|
28
|
+
updated_at: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ModelBenchmarks {
|
|
31
|
+
openrouter_id: string;
|
|
32
|
+
aa_intelligence_index: number | null;
|
|
33
|
+
aa_coding_index: number | null;
|
|
34
|
+
aa_math_index: number | null;
|
|
35
|
+
aa_speed_index: number | null;
|
|
36
|
+
lmsys_elo: number | null;
|
|
37
|
+
lmsys_elo_coding: number | null;
|
|
38
|
+
livebench_overall: number | null;
|
|
39
|
+
livebench_coding: number | null;
|
|
40
|
+
livebench_math: number | null;
|
|
41
|
+
livebench_reasoning: number | null;
|
|
42
|
+
livebench_language: number | null;
|
|
43
|
+
livebench_data_analysis: number | null;
|
|
44
|
+
livebench_instruction_following: number | null;
|
|
45
|
+
updated_at: string;
|
|
46
|
+
}
|
|
47
|
+
export interface ModelNameMapping {
|
|
48
|
+
openrouter_id: string;
|
|
49
|
+
canonical_name: string;
|
|
50
|
+
aa_name: string | null;
|
|
51
|
+
lmsys_pattern: string | null;
|
|
52
|
+
livebench_name: string | null;
|
|
53
|
+
aliases: string[] | null;
|
|
54
|
+
provider: string | null;
|
|
55
|
+
verified: boolean;
|
|
56
|
+
created_at: string;
|
|
57
|
+
updated_at: string;
|
|
58
|
+
}
|
|
59
|
+
export interface ModelWithBenchmarks {
|
|
60
|
+
model: ModelCatalogEntry;
|
|
61
|
+
benchmarks: ModelBenchmarks | null;
|
|
62
|
+
mapping: ModelNameMapping | null;
|
|
63
|
+
}
|
|
64
|
+
export interface BenchmarkWeights {
|
|
65
|
+
aa_intelligence_index?: number;
|
|
66
|
+
aa_coding_index?: number;
|
|
67
|
+
aa_math_index?: number;
|
|
68
|
+
aa_speed_index?: number;
|
|
69
|
+
lmsys_elo?: number;
|
|
70
|
+
lmsys_elo_coding?: number;
|
|
71
|
+
livebench_overall?: number;
|
|
72
|
+
livebench_coding?: number;
|
|
73
|
+
livebench_math?: number;
|
|
74
|
+
livebench_reasoning?: number;
|
|
75
|
+
livebench_language?: number;
|
|
76
|
+
livebench_data_analysis?: number;
|
|
77
|
+
livebench_instruction_following?: number;
|
|
78
|
+
}
|
|
79
|
+
export interface ProviderBoosts {
|
|
80
|
+
[provider: string]: number;
|
|
81
|
+
}
|
|
82
|
+
export interface TaskProfile {
|
|
83
|
+
/** Human-readable name */
|
|
84
|
+
displayName: string;
|
|
85
|
+
/** Which benchmarks matter and how much */
|
|
86
|
+
benchmarkWeights: BenchmarkWeights;
|
|
87
|
+
/** Provider-specific score boosts */
|
|
88
|
+
providerBoosts: ProviderBoosts;
|
|
89
|
+
/** Minimum context length required */
|
|
90
|
+
minContextLength: number;
|
|
91
|
+
/** Require JSON mode support */
|
|
92
|
+
requireJsonMode?: boolean;
|
|
93
|
+
/** Require vision/multimodal support */
|
|
94
|
+
requireVision?: boolean;
|
|
95
|
+
/** Require deterministic output (seed support) */
|
|
96
|
+
requireDeterministic?: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface ScoreBreakdown {
|
|
99
|
+
/** Benchmark-based score (0-40) */
|
|
100
|
+
benchmarkFit: number;
|
|
101
|
+
/** Task profile fit (0-30) */
|
|
102
|
+
taskFit: number;
|
|
103
|
+
/** Budget fit (0-20) */
|
|
104
|
+
budgetFit: number;
|
|
105
|
+
/** Capability fit (0-10) */
|
|
106
|
+
capabilityFit: number;
|
|
107
|
+
/** Provider boost applied */
|
|
108
|
+
providerBonus: number;
|
|
109
|
+
}
|
|
110
|
+
export interface ScoredModel {
|
|
111
|
+
/** OpenRouter model ID */
|
|
112
|
+
modelId: string;
|
|
113
|
+
/** Provider name (e.g., "anthropic") */
|
|
114
|
+
provider: string;
|
|
115
|
+
/** Display name (e.g., "Claude Sonnet 4") */
|
|
116
|
+
displayName: string;
|
|
117
|
+
/** Context window size */
|
|
118
|
+
contextLength: number;
|
|
119
|
+
/** Whether model supports JSON mode */
|
|
120
|
+
supportsJson: boolean;
|
|
121
|
+
/** Modality (e.g., "text->text", "text+image->text") */
|
|
122
|
+
modality: string;
|
|
123
|
+
/** Pricing information */
|
|
124
|
+
pricing: ModelPricing;
|
|
125
|
+
/** Total score (0-100 + bonuses) */
|
|
126
|
+
score: number;
|
|
127
|
+
/** Detailed score breakdown */
|
|
128
|
+
scoreBreakdown: ScoreBreakdown;
|
|
129
|
+
/** Human-readable reasoning */
|
|
130
|
+
reasoning: string;
|
|
131
|
+
/** Whether manually selected (no scoring) */
|
|
132
|
+
manuallySelected?: boolean;
|
|
133
|
+
}
|
|
134
|
+
export interface ModelPricing {
|
|
135
|
+
/** Price per 1M prompt tokens in USD */
|
|
136
|
+
promptPerMUsd: number;
|
|
137
|
+
/** Price per 1M completion tokens in USD */
|
|
138
|
+
completionPerMUsd: number;
|
|
139
|
+
/** Combined average per 1M tokens */
|
|
140
|
+
combinedPerMUsd: number;
|
|
141
|
+
}
|
|
142
|
+
export interface NodeInputParams {
|
|
143
|
+
task: TaskCategory;
|
|
144
|
+
budget: BudgetPreference;
|
|
145
|
+
modelOverride: string;
|
|
146
|
+
filters: NodeFilters;
|
|
147
|
+
options: NodeOptions;
|
|
148
|
+
}
|
|
149
|
+
export interface NodeFilters {
|
|
150
|
+
minContextLength?: number;
|
|
151
|
+
requireJsonMode?: boolean;
|
|
152
|
+
requireDeterministic?: boolean;
|
|
153
|
+
requireVision?: boolean;
|
|
154
|
+
maxCostPerK?: number;
|
|
155
|
+
providerWhitelist?: string[];
|
|
156
|
+
providerBlacklist?: string[];
|
|
157
|
+
}
|
|
158
|
+
export interface NodeOptions {
|
|
159
|
+
alternativesCount: number;
|
|
160
|
+
outputFormat: OutputFormat;
|
|
161
|
+
}
|
|
162
|
+
export type OutputFormat = 'full' | 'simple' | 'compact';
|
|
163
|
+
export interface NodeOutputFull {
|
|
164
|
+
recommended: ScoredModel;
|
|
165
|
+
alternatives: ScoredModel[];
|
|
166
|
+
queryMetadata: QueryMetadata;
|
|
167
|
+
}
|
|
168
|
+
export interface NodeOutputSimple {
|
|
169
|
+
modelId: string;
|
|
170
|
+
provider: string;
|
|
171
|
+
displayName: string;
|
|
172
|
+
score: number;
|
|
173
|
+
costPerMTokens: number;
|
|
174
|
+
alternatives: Array<{
|
|
175
|
+
modelId: string;
|
|
176
|
+
score: number;
|
|
177
|
+
costPerMTokens: number;
|
|
178
|
+
}>;
|
|
179
|
+
}
|
|
180
|
+
export interface NodeOutputCompact {
|
|
181
|
+
modelId: string;
|
|
182
|
+
alternativeIds: string[];
|
|
183
|
+
}
|
|
184
|
+
export type NodeOutput = NodeOutputFull | NodeOutputSimple | NodeOutputCompact;
|
|
185
|
+
export interface QueryMetadata {
|
|
186
|
+
task: TaskCategory;
|
|
187
|
+
budget: BudgetPreference;
|
|
188
|
+
totalModelsEvaluated: number;
|
|
189
|
+
modelsPassingFilters: number;
|
|
190
|
+
executionTimeMs: number;
|
|
191
|
+
dataTimestamp: string;
|
|
192
|
+
}
|
|
193
|
+
export interface SupabaseCredentials {
|
|
194
|
+
url: string;
|
|
195
|
+
apiKey: string;
|
|
196
|
+
}
|
|
197
|
+
export interface SupabaseQueryResult<T> {
|
|
198
|
+
data: T[] | null;
|
|
199
|
+
error: SupabaseError | null;
|
|
200
|
+
}
|
|
201
|
+
export interface SupabaseError {
|
|
202
|
+
message: string;
|
|
203
|
+
details: string;
|
|
204
|
+
hint: string;
|
|
205
|
+
code: string;
|
|
206
|
+
}
|
|
207
|
+
export declare const SUPPORTED_PROVIDERS: readonly ["anthropic", "openai", "google", "deepseek", "meta-llama", "mistralai", "qwen", "cohere", "perplexity", "x-ai"];
|
|
208
|
+
export type SupportedProvider = (typeof SUPPORTED_PROVIDERS)[number];
|
|
209
|
+
export declare const SCORE_WEIGHTS: {
|
|
210
|
+
readonly benchmark: 0.4;
|
|
211
|
+
readonly task: 0.3;
|
|
212
|
+
readonly budget: 0.2;
|
|
213
|
+
readonly capability: 0.1;
|
|
214
|
+
};
|
|
215
|
+
export declare const MAX_ALTERNATIVES = 10;
|
|
216
|
+
export declare const DEFAULT_ALTERNATIVES = 3;
|
|
217
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../nodes/OpenRouterSmartChat/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,MAAM,YAAY,GACpB,aAAa,GACb,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,MAAM,GACN,WAAW,GACX,eAAe,GACf,MAAM,CAAC;AAMX,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;AAEhE,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAaxE,CAAC;AAMF,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,uBAAuB,EAAE,MAAM,CAAC;IAChC,2BAA2B,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E,MAAM,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;CACvB;AAMD,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;IACjB,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAMD,eAAO,MAAM,mBAAmB,2HAWtB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAErE,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,oBAAoB,IAAI,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OpenRouter Model Selector - TypeScript Types & Interfaces
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DEFAULT_ALTERNATIVES = exports.MAX_ALTERNATIVES = exports.SCORE_WEIGHTS = exports.SUPPORTED_PROVIDERS = exports.BUDGET_THRESHOLDS = void 0;
|
|
7
|
+
exports.BUDGET_THRESHOLDS = {
|
|
8
|
+
cheap: {
|
|
9
|
+
maxPricePerK: 0.001,
|
|
10
|
+
description: 'Cheapest option, quality secondary',
|
|
11
|
+
},
|
|
12
|
+
balanced: {
|
|
13
|
+
maxPricePerK: 0.01,
|
|
14
|
+
description: 'Good price-performance ratio',
|
|
15
|
+
},
|
|
16
|
+
premium: {
|
|
17
|
+
maxPricePerK: Infinity,
|
|
18
|
+
description: 'Best quality, cost no concern',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// Constants
|
|
23
|
+
// =============================================================================
|
|
24
|
+
exports.SUPPORTED_PROVIDERS = [
|
|
25
|
+
'anthropic',
|
|
26
|
+
'openai',
|
|
27
|
+
'google',
|
|
28
|
+
'deepseek',
|
|
29
|
+
'meta-llama',
|
|
30
|
+
'mistralai',
|
|
31
|
+
'qwen',
|
|
32
|
+
'cohere',
|
|
33
|
+
'perplexity',
|
|
34
|
+
'x-ai',
|
|
35
|
+
];
|
|
36
|
+
exports.SCORE_WEIGHTS = {
|
|
37
|
+
benchmark: 0.4, // 40 points max
|
|
38
|
+
task: 0.3, // 30 points max
|
|
39
|
+
budget: 0.2, // 20 points max
|
|
40
|
+
capability: 0.1, // 10 points max
|
|
41
|
+
};
|
|
42
|
+
exports.MAX_ALTERNATIVES = 10;
|
|
43
|
+
exports.DEFAULT_ALTERNATIVES = 3;
|
|
44
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../nodes/OpenRouterSmartChat/types.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA6BU,QAAA,iBAAiB,GAA+C;IAC3E,KAAK,EAAE;QACL,YAAY,EAAE,KAAK;QACnB,WAAW,EAAE,oCAAoC;KAClD;IACD,QAAQ,EAAE;QACR,YAAY,EAAE,IAAI;QAClB,WAAW,EAAE,8BAA8B;KAC5C;IACD,OAAO,EAAE;QACP,YAAY,EAAE,QAAQ;QACtB,WAAW,EAAE,+BAA+B;KAC7C;CACF,CAAC;AAkQF,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEnE,QAAA,mBAAmB,GAAG;IACjC,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,WAAW;IACX,MAAM;IACN,QAAQ;IACR,YAAY;IACZ,MAAM;CACE,CAAC;AAIE,QAAA,aAAa,GAAG;IAC3B,SAAS,EAAE,GAAG,EAAE,gBAAgB;IAChC,IAAI,EAAE,GAAG,EAAE,gBAAgB;IAC3B,MAAM,EAAE,GAAG,EAAE,gBAAgB;IAC7B,UAAU,EAAE,GAAG,EAAE,gBAAgB;CACzB,CAAC;AAEE,QAAA,gBAAgB,GAAG,EAAE,CAAC;AACtB,QAAA,oBAAoB,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenRouter Smart Embeddings Class
|
|
3
|
+
*
|
|
4
|
+
* Langchain-compatible Embeddings implementation with auto-selection.
|
|
5
|
+
*/
|
|
6
|
+
import { Embeddings, type EmbeddingsParams } from '@langchain/core/embeddings';
|
|
7
|
+
import type { ContentAnalysis } from '../shared/contentAnalyzer';
|
|
8
|
+
import type { Budget, EmbeddingTask, ScoringFilters, ScoredModel } from '../shared/types';
|
|
9
|
+
export interface OpenRouterSmartEmbeddingsConfig extends EmbeddingsParams {
|
|
10
|
+
apiKey: string;
|
|
11
|
+
budget: Budget;
|
|
12
|
+
task: EmbeddingTask;
|
|
13
|
+
supabaseUrl: string;
|
|
14
|
+
supabaseKey: string;
|
|
15
|
+
filters?: ScoringFilters;
|
|
16
|
+
options?: {
|
|
17
|
+
showSelectionDetails?: boolean;
|
|
18
|
+
overrideDimensions?: number;
|
|
19
|
+
};
|
|
20
|
+
modelOverride?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare class OpenRouterSmartEmbeddings extends Embeddings {
|
|
23
|
+
private apiKey;
|
|
24
|
+
private budget;
|
|
25
|
+
private task;
|
|
26
|
+
private supabaseUrl;
|
|
27
|
+
private supabaseKey;
|
|
28
|
+
private filters;
|
|
29
|
+
private options;
|
|
30
|
+
private modelOverride?;
|
|
31
|
+
private cachedModels;
|
|
32
|
+
private lastSelectedModel;
|
|
33
|
+
private lastContentAnalysis;
|
|
34
|
+
private static readonly MAX_BATCH_SIZE;
|
|
35
|
+
constructor(config: OpenRouterSmartEmbeddingsConfig);
|
|
36
|
+
embedDocuments(texts: string[]): Promise<number[][]>;
|
|
37
|
+
embedQuery(text: string): Promise<number[]>;
|
|
38
|
+
private selectModel;
|
|
39
|
+
private prepareTexts;
|
|
40
|
+
private callOpenRouter;
|
|
41
|
+
private fetchModels;
|
|
42
|
+
private getDefaultModels;
|
|
43
|
+
private getModelDimensions;
|
|
44
|
+
private getModelPrice;
|
|
45
|
+
getLastSelection(): ScoredModel | null;
|
|
46
|
+
getLastAnalysis(): ContentAnalysis | null;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=OpenRouterEmbeddings.class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenRouterEmbeddings.class.d.ts","sourceRoot":"","sources":["../../../nodes/OpenRouterSmartEmbedding/OpenRouterEmbeddings.class.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EAEb,cAAc,EACd,WAAW,EAEZ,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,+BAAgC,SAAQ,gBAAgB;IACvE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,aAAa,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,OAAO,CAAC,EAAE;QAAE,oBAAoB,CAAC,EAAE,OAAO,CAAC;QAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,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