n8n-nodes-openrouter-selector 0.4.0 → 0.5.1
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/dist/nodes/OpenRouterChatModel/OpenRouterChatModel.class.d.ts +39 -0
- package/dist/nodes/OpenRouterChatModel/OpenRouterChatModel.class.d.ts.map +1 -0
- package/dist/nodes/OpenRouterChatModel/OpenRouterChatModel.class.js +244 -0
- package/dist/nodes/OpenRouterChatModel/OpenRouterChatModel.class.js.map +1 -0
- package/dist/nodes/OpenRouterChatModel/OpenRouterChatModel.node.d.ts +16 -0
- package/dist/nodes/OpenRouterChatModel/OpenRouterChatModel.node.d.ts.map +1 -0
- package/dist/nodes/OpenRouterChatModel/OpenRouterChatModel.node.js +143 -0
- package/dist/nodes/OpenRouterChatModel/OpenRouterChatModel.node.js.map +1 -0
- package/dist/nodes/OpenRouterChatModel/openrouter-chat.svg +10 -0
- package/package.json +2 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenRouter Chat Model Class
|
|
3
|
+
*
|
|
4
|
+
* Langchain-compatible BaseChatModel implementation for n8n AI Agent.
|
|
5
|
+
* Supports tool calling for AI Agent integration.
|
|
6
|
+
*/
|
|
7
|
+
import { BaseChatModel, type BaseChatModelCallOptions, type BindToolsInput } from '@langchain/core/language_models/chat_models';
|
|
8
|
+
import { BaseMessage, AIMessageChunk } from '@langchain/core/messages';
|
|
9
|
+
import type { CallbackManagerForLLMRun } from '@langchain/core/callbacks/manager';
|
|
10
|
+
import { ChatResult } from '@langchain/core/outputs';
|
|
11
|
+
import { Runnable } from '@langchain/core/runnables';
|
|
12
|
+
export interface OpenRouterChatModelConfig {
|
|
13
|
+
apiKey: string;
|
|
14
|
+
model: string;
|
|
15
|
+
temperature?: number;
|
|
16
|
+
maxTokens?: number;
|
|
17
|
+
topP?: number;
|
|
18
|
+
frequencyPenalty?: number;
|
|
19
|
+
presencePenalty?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare class OpenRouterChatModel extends BaseChatModel {
|
|
22
|
+
private apiKey;
|
|
23
|
+
private modelId;
|
|
24
|
+
private temperature;
|
|
25
|
+
private maxTokens;
|
|
26
|
+
private topP;
|
|
27
|
+
private frequencyPenalty;
|
|
28
|
+
private presencePenalty;
|
|
29
|
+
private boundTools;
|
|
30
|
+
constructor(config: OpenRouterChatModelConfig);
|
|
31
|
+
_llmType(): string;
|
|
32
|
+
bindTools(tools: BindToolsInput[], _kwargs?: Partial<BaseChatModelCallOptions>): Runnable<BaseMessage[], AIMessageChunk, BaseChatModelCallOptions>;
|
|
33
|
+
private convertToolToOpenRouterFormat;
|
|
34
|
+
private zodToJsonSchema;
|
|
35
|
+
private getZodType;
|
|
36
|
+
_generate(messages: BaseMessage[], options?: BaseChatModelCallOptions, _runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
|
|
37
|
+
private convertMessages;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=OpenRouterChatModel.class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenRouterChatModel.class.d.ts","sourceRoot":"","sources":["../../../nodes/OpenRouterChatModel/OpenRouterChatModel.class.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,aAAa,EACb,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACpB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAEL,WAAW,EAIX,cAAc,EACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,UAAU,EAAkB,MAAM,yBAAyB,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AA8CD,qBAAa,mBAAoB,SAAQ,aAAa;IACpD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,UAAU,CAAwB;gBAE9B,MAAM,EAAE,yBAAyB;IAW7C,QAAQ,IAAI,MAAM;IAIlB,SAAS,CACP,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,GAC1C,QAAQ,CAAC,WAAW,EAAE,EAAE,cAAc,EAAE,wBAAwB,CAAC;IAepE,OAAO,CAAC,6BAA6B;IAsBrC,OAAO,CAAC,eAAe;IA8CvB,OAAO,CAAC,UAAU;IAUZ,SAAS,CACb,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,CAAC,EAAE,wBAAwB,EAClC,WAAW,CAAC,EAAE,wBAAwB,GACrC,OAAO,CAAC,UAAU,CAAC;IAsFtB,OAAO,CAAC,eAAe;CAkCxB"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OpenRouter Chat Model Class
|
|
4
|
+
*
|
|
5
|
+
* Langchain-compatible BaseChatModel implementation for n8n AI Agent.
|
|
6
|
+
* Supports tool calling for AI Agent integration.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.OpenRouterChatModel = void 0;
|
|
10
|
+
const chat_models_1 = require("@langchain/core/language_models/chat_models");
|
|
11
|
+
const messages_1 = require("@langchain/core/messages");
|
|
12
|
+
class OpenRouterChatModel extends chat_models_1.BaseChatModel {
|
|
13
|
+
apiKey;
|
|
14
|
+
modelId;
|
|
15
|
+
temperature;
|
|
16
|
+
maxTokens;
|
|
17
|
+
topP;
|
|
18
|
+
frequencyPenalty;
|
|
19
|
+
presencePenalty;
|
|
20
|
+
boundTools = [];
|
|
21
|
+
constructor(config) {
|
|
22
|
+
super({});
|
|
23
|
+
this.apiKey = config.apiKey;
|
|
24
|
+
this.modelId = config.model;
|
|
25
|
+
this.temperature = config.temperature ?? 0.7;
|
|
26
|
+
this.maxTokens = config.maxTokens ?? 1000;
|
|
27
|
+
this.topP = config.topP ?? 1;
|
|
28
|
+
this.frequencyPenalty = config.frequencyPenalty ?? 0;
|
|
29
|
+
this.presencePenalty = config.presencePenalty ?? 0;
|
|
30
|
+
}
|
|
31
|
+
_llmType() {
|
|
32
|
+
return 'openrouter-chat';
|
|
33
|
+
}
|
|
34
|
+
bindTools(tools, _kwargs) {
|
|
35
|
+
const boundModel = new OpenRouterChatModel({
|
|
36
|
+
apiKey: this.apiKey,
|
|
37
|
+
model: this.modelId,
|
|
38
|
+
temperature: this.temperature,
|
|
39
|
+
maxTokens: this.maxTokens,
|
|
40
|
+
topP: this.topP,
|
|
41
|
+
frequencyPenalty: this.frequencyPenalty,
|
|
42
|
+
presencePenalty: this.presencePenalty,
|
|
43
|
+
});
|
|
44
|
+
boundModel.boundTools = tools.map((tool) => this.convertToolToOpenRouterFormat(tool));
|
|
45
|
+
return boundModel;
|
|
46
|
+
}
|
|
47
|
+
convertToolToOpenRouterFormat(tool) {
|
|
48
|
+
// Handle StructuredTool or similar tool interfaces
|
|
49
|
+
if (typeof tool === 'object' && tool !== null) {
|
|
50
|
+
const toolObj = tool;
|
|
51
|
+
if (toolObj.name && toolObj.description && toolObj.schema) {
|
|
52
|
+
return {
|
|
53
|
+
type: 'function',
|
|
54
|
+
function: {
|
|
55
|
+
name: toolObj.name,
|
|
56
|
+
description: toolObj.description,
|
|
57
|
+
parameters: this.zodToJsonSchema(toolObj.schema),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// Handle raw function definition
|
|
62
|
+
if ('type' in tool && tool.type === 'function') {
|
|
63
|
+
return tool;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
throw new Error(`Unsupported tool format: ${JSON.stringify(tool)}`);
|
|
67
|
+
}
|
|
68
|
+
zodToJsonSchema(schema) {
|
|
69
|
+
// If it's already a JSON schema object, return it
|
|
70
|
+
if (typeof schema === 'object' && schema !== null) {
|
|
71
|
+
const schemaObj = schema;
|
|
72
|
+
// Check if it has a jsonSchema property (some Zod schemas expose this)
|
|
73
|
+
if ('jsonSchema' in schemaObj) {
|
|
74
|
+
return schemaObj.jsonSchema;
|
|
75
|
+
}
|
|
76
|
+
// Check if it looks like a JSON schema already
|
|
77
|
+
if ('type' in schemaObj || 'properties' in schemaObj) {
|
|
78
|
+
return schemaObj;
|
|
79
|
+
}
|
|
80
|
+
// Try to get JSON schema from Zod
|
|
81
|
+
if (typeof schemaObj._def === 'object') {
|
|
82
|
+
// It's a Zod schema, try to convert
|
|
83
|
+
try {
|
|
84
|
+
const zodSchema = schemaObj;
|
|
85
|
+
if (zodSchema.shape) {
|
|
86
|
+
const properties = {};
|
|
87
|
+
const required = [];
|
|
88
|
+
for (const [key, value] of Object.entries(zodSchema.shape)) {
|
|
89
|
+
const fieldSchema = value;
|
|
90
|
+
properties[key] = {
|
|
91
|
+
type: this.getZodType(fieldSchema),
|
|
92
|
+
description: fieldSchema._def?.description || '',
|
|
93
|
+
};
|
|
94
|
+
// Check if field is required (not optional)
|
|
95
|
+
if (!fieldSchema._def?.typeName?.includes('Optional')) {
|
|
96
|
+
required.push(key);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties,
|
|
102
|
+
required: required.length > 0 ? required : undefined,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// Fall through to default
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Default fallback
|
|
112
|
+
return { type: 'object', properties: {} };
|
|
113
|
+
}
|
|
114
|
+
getZodType(schema) {
|
|
115
|
+
const typeName = schema._def?.typeName || '';
|
|
116
|
+
if (typeName.includes('String'))
|
|
117
|
+
return 'string';
|
|
118
|
+
if (typeName.includes('Number'))
|
|
119
|
+
return 'number';
|
|
120
|
+
if (typeName.includes('Boolean'))
|
|
121
|
+
return 'boolean';
|
|
122
|
+
if (typeName.includes('Array'))
|
|
123
|
+
return 'array';
|
|
124
|
+
if (typeName.includes('Object'))
|
|
125
|
+
return 'object';
|
|
126
|
+
return 'string';
|
|
127
|
+
}
|
|
128
|
+
async _generate(messages, options, _runManager) {
|
|
129
|
+
const openRouterMessages = this.convertMessages(messages);
|
|
130
|
+
const body = {
|
|
131
|
+
model: this.modelId,
|
|
132
|
+
messages: openRouterMessages,
|
|
133
|
+
temperature: this.temperature,
|
|
134
|
+
max_tokens: this.maxTokens,
|
|
135
|
+
top_p: this.topP,
|
|
136
|
+
frequency_penalty: this.frequencyPenalty,
|
|
137
|
+
presence_penalty: this.presencePenalty,
|
|
138
|
+
};
|
|
139
|
+
if (this.boundTools.length > 0) {
|
|
140
|
+
body.tools = this.boundTools;
|
|
141
|
+
body.tool_choice = 'auto';
|
|
142
|
+
}
|
|
143
|
+
if (options?.stop) {
|
|
144
|
+
body.stop = options.stop;
|
|
145
|
+
}
|
|
146
|
+
let response;
|
|
147
|
+
try {
|
|
148
|
+
response = await fetch('https://openrouter.ai/api/v1/chat/completions', {
|
|
149
|
+
method: 'POST',
|
|
150
|
+
headers: {
|
|
151
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
152
|
+
'Content-Type': 'application/json',
|
|
153
|
+
'HTTP-Referer': 'https://n8n.io',
|
|
154
|
+
'X-Title': 'n8n OpenRouter Chat Model',
|
|
155
|
+
},
|
|
156
|
+
body: JSON.stringify(body),
|
|
157
|
+
signal: options?.signal,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
catch (networkError) {
|
|
161
|
+
throw new Error(`Network error calling OpenRouter: ${networkError.message}`);
|
|
162
|
+
}
|
|
163
|
+
if (!response.ok) {
|
|
164
|
+
const error = await response.json().catch(() => ({}));
|
|
165
|
+
const errorMessage = error.error?.message || response.statusText;
|
|
166
|
+
throw new Error(`OpenRouter API Error: ${response.status} - ${errorMessage}`);
|
|
167
|
+
}
|
|
168
|
+
const data = await response.json();
|
|
169
|
+
const choice = data.choices[0];
|
|
170
|
+
const messageData = choice?.message;
|
|
171
|
+
let aiMessage;
|
|
172
|
+
if (messageData?.tool_calls && messageData.tool_calls.length > 0) {
|
|
173
|
+
// Create AIMessage with tool calls
|
|
174
|
+
aiMessage = new messages_1.AIMessage({
|
|
175
|
+
content: messageData.content || '',
|
|
176
|
+
tool_calls: messageData.tool_calls.map((tc) => ({
|
|
177
|
+
id: tc.id,
|
|
178
|
+
name: tc.function.name,
|
|
179
|
+
args: JSON.parse(tc.function.arguments),
|
|
180
|
+
type: 'tool_call',
|
|
181
|
+
})),
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
aiMessage = new messages_1.AIMessage(messageData?.content || '');
|
|
186
|
+
}
|
|
187
|
+
const generation = {
|
|
188
|
+
text: messageData?.content || '',
|
|
189
|
+
message: aiMessage,
|
|
190
|
+
generationInfo: {
|
|
191
|
+
finish_reason: choice?.finish_reason,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
return {
|
|
195
|
+
generations: [generation],
|
|
196
|
+
llmOutput: {
|
|
197
|
+
tokenUsage: data.usage ? {
|
|
198
|
+
promptTokens: data.usage.prompt_tokens,
|
|
199
|
+
completionTokens: data.usage.completion_tokens,
|
|
200
|
+
totalTokens: data.usage.total_tokens,
|
|
201
|
+
} : undefined,
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
convertMessages(messages) {
|
|
206
|
+
return messages.map((msg) => {
|
|
207
|
+
if (msg instanceof messages_1.SystemMessage) {
|
|
208
|
+
return { role: 'system', content: msg.content };
|
|
209
|
+
}
|
|
210
|
+
else if (msg instanceof messages_1.HumanMessage) {
|
|
211
|
+
return { role: 'user', content: msg.content };
|
|
212
|
+
}
|
|
213
|
+
else if (msg instanceof messages_1.AIMessage) {
|
|
214
|
+
const aiMsg = msg;
|
|
215
|
+
if (aiMsg.tool_calls && aiMsg.tool_calls.length > 0) {
|
|
216
|
+
return {
|
|
217
|
+
role: 'assistant',
|
|
218
|
+
content: aiMsg.content || null,
|
|
219
|
+
tool_calls: aiMsg.tool_calls.map((tc) => ({
|
|
220
|
+
id: tc.id || `call_${Math.random().toString(36).substr(2, 9)}`,
|
|
221
|
+
type: 'function',
|
|
222
|
+
function: {
|
|
223
|
+
name: tc.name,
|
|
224
|
+
arguments: JSON.stringify(tc.args),
|
|
225
|
+
},
|
|
226
|
+
})),
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return { role: 'assistant', content: aiMsg.content };
|
|
230
|
+
}
|
|
231
|
+
else if (msg instanceof messages_1.ToolMessage) {
|
|
232
|
+
return {
|
|
233
|
+
role: 'tool',
|
|
234
|
+
content: msg.content,
|
|
235
|
+
tool_call_id: msg.tool_call_id,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
// Default to user for unknown message types
|
|
239
|
+
return { role: 'user', content: msg.content };
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
exports.OpenRouterChatModel = OpenRouterChatModel;
|
|
244
|
+
//# sourceMappingURL=OpenRouterChatModel.class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenRouterChatModel.class.js","sourceRoot":"","sources":["../../../nodes/OpenRouterChatModel/OpenRouterChatModel.class.ts"],"names":[],"mappings":";A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|
+
*
|
|
4
|
+
* Langchain-compatible chat model node for n8n AI Agent system.
|
|
5
|
+
*/
|
|
6
|
+
import type { INodeType, INodeTypeDescription, ISupplyDataFunctions, SupplyData, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
|
7
|
+
export declare class OpenRouterChatModel implements INodeType {
|
|
8
|
+
description: INodeTypeDescription;
|
|
9
|
+
methods: {
|
|
10
|
+
loadOptions: {
|
|
11
|
+
getModels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=OpenRouterChatModel.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenRouterChatModel.node.d.ts","sourceRoot":"","sources":["../../../nodes/OpenRouterChatModel/OpenRouterChatModel.node.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,UAAU,EACV,qBAAqB,EACrB,oBAAoB,EAErB,MAAM,cAAc,CAAC;AAKtB,qBAAa,mBAAoB,YAAW,SAAS;IACnD,WAAW,EAAE,oBAAoB,CAmF/B;IAEF,OAAO;;4BAEmB,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;;MAgC/E;IAEI,UAAU,CAAC,IAAI,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAiBrF"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OpenRouter Chat Model Node
|
|
4
|
+
*
|
|
5
|
+
* Langchain-compatible chat model node for n8n AI Agent system.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.OpenRouterChatModel = void 0;
|
|
9
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
10
|
+
const OpenRouterChatModel_class_1 = require("./OpenRouterChatModel.class");
|
|
11
|
+
class OpenRouterChatModel {
|
|
12
|
+
description = {
|
|
13
|
+
displayName: 'OpenRouter Chat Model',
|
|
14
|
+
name: 'openRouterChatModel',
|
|
15
|
+
icon: 'file:openrouter-chat.svg',
|
|
16
|
+
group: ['transform'],
|
|
17
|
+
version: 1,
|
|
18
|
+
description: 'Use any OpenRouter model as chat model for AI Agents',
|
|
19
|
+
defaults: { name: 'OpenRouter Chat Model' },
|
|
20
|
+
codex: {
|
|
21
|
+
categories: ['AI'],
|
|
22
|
+
subcategories: { AI: ['Language Models', 'Root Nodes'] },
|
|
23
|
+
resources: {
|
|
24
|
+
primaryDocumentation: [{ url: 'https://github.com/ecolights/n8n-nodes-openrouter-selector' }],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
inputs: [],
|
|
28
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.AiLanguageModel],
|
|
29
|
+
outputNames: ['Model'],
|
|
30
|
+
credentials: [
|
|
31
|
+
{ name: 'openRouterApi', required: true },
|
|
32
|
+
],
|
|
33
|
+
properties: [
|
|
34
|
+
{
|
|
35
|
+
displayName: 'Model',
|
|
36
|
+
name: 'model',
|
|
37
|
+
type: 'options',
|
|
38
|
+
default: 'anthropic/claude-3.5-sonnet',
|
|
39
|
+
typeOptions: { loadOptionsMethod: 'getModels' },
|
|
40
|
+
description: 'The model to use for chat completions',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
displayName: 'Options',
|
|
44
|
+
name: 'options',
|
|
45
|
+
type: 'collection',
|
|
46
|
+
placeholder: 'Add Option',
|
|
47
|
+
default: {},
|
|
48
|
+
options: [
|
|
49
|
+
{
|
|
50
|
+
displayName: 'Temperature',
|
|
51
|
+
name: 'temperature',
|
|
52
|
+
type: 'number',
|
|
53
|
+
default: 0.7,
|
|
54
|
+
typeOptions: { minValue: 0, maxValue: 2, numberPrecision: 1 },
|
|
55
|
+
description: 'Controls randomness. Lower = more focused, higher = more creative.',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
displayName: 'Max Tokens',
|
|
59
|
+
name: 'maxTokens',
|
|
60
|
+
type: 'number',
|
|
61
|
+
default: 1000,
|
|
62
|
+
description: 'Maximum number of tokens to generate',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
displayName: 'Top P',
|
|
66
|
+
name: 'topP',
|
|
67
|
+
type: 'number',
|
|
68
|
+
default: 1,
|
|
69
|
+
typeOptions: { minValue: 0, maxValue: 1, numberPrecision: 2 },
|
|
70
|
+
description: 'Nucleus sampling parameter',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
displayName: 'Frequency Penalty',
|
|
74
|
+
name: 'frequencyPenalty',
|
|
75
|
+
type: 'number',
|
|
76
|
+
default: 0,
|
|
77
|
+
typeOptions: { minValue: -2, maxValue: 2, numberPrecision: 1 },
|
|
78
|
+
description: 'Reduces repetition of token sequences',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
displayName: 'Presence Penalty',
|
|
82
|
+
name: 'presencePenalty',
|
|
83
|
+
type: 'number',
|
|
84
|
+
default: 0,
|
|
85
|
+
typeOptions: { minValue: -2, maxValue: 2, numberPrecision: 1 },
|
|
86
|
+
description: 'Increases likelihood of new topics',
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
methods = {
|
|
93
|
+
loadOptions: {
|
|
94
|
+
async getModels() {
|
|
95
|
+
const defaultModels = [
|
|
96
|
+
{ name: 'Claude 3.5 Sonnet', value: 'anthropic/claude-3.5-sonnet' },
|
|
97
|
+
{ name: 'Claude 3 Opus', value: 'anthropic/claude-3-opus' },
|
|
98
|
+
{ name: 'GPT-4o', value: 'openai/gpt-4o' },
|
|
99
|
+
{ name: 'GPT-4o Mini', value: 'openai/gpt-4o-mini' },
|
|
100
|
+
{ name: 'Gemini 1.5 Pro', value: 'google/gemini-pro-1.5' },
|
|
101
|
+
{ name: 'Llama 3.1 70B', value: 'meta-llama/llama-3.1-70b-instruct' },
|
|
102
|
+
];
|
|
103
|
+
const credentials = await this.getCredentials('openRouterApi');
|
|
104
|
+
try {
|
|
105
|
+
const response = await this.helpers.httpRequest({
|
|
106
|
+
method: 'GET',
|
|
107
|
+
url: 'https://openrouter.ai/api/v1/models',
|
|
108
|
+
headers: { Authorization: `Bearer ${credentials.apiKey}` },
|
|
109
|
+
});
|
|
110
|
+
if (response?.data && Array.isArray(response.data)) {
|
|
111
|
+
return response.data
|
|
112
|
+
.filter((m) => !m.id.includes(':free'))
|
|
113
|
+
.map((m) => ({
|
|
114
|
+
name: m.name || m.id,
|
|
115
|
+
value: m.id,
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
return defaultModels;
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return defaultModels;
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
async supplyData(itemIndex) {
|
|
127
|
+
const credentials = await this.getCredentials('openRouterApi');
|
|
128
|
+
const model = this.getNodeParameter('model', itemIndex);
|
|
129
|
+
const options = this.getNodeParameter('options', itemIndex, {});
|
|
130
|
+
const chatModel = new OpenRouterChatModel_class_1.OpenRouterChatModel({
|
|
131
|
+
apiKey: credentials.apiKey,
|
|
132
|
+
model,
|
|
133
|
+
temperature: options.temperature,
|
|
134
|
+
maxTokens: options.maxTokens,
|
|
135
|
+
topP: options.topP,
|
|
136
|
+
frequencyPenalty: options.frequencyPenalty,
|
|
137
|
+
presencePenalty: options.presencePenalty,
|
|
138
|
+
});
|
|
139
|
+
return { response: chatModel };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.OpenRouterChatModel = OpenRouterChatModel;
|
|
143
|
+
//# sourceMappingURL=OpenRouterChatModel.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenRouterChatModel.node.js","sourceRoot":"","sources":["../../../nodes/OpenRouterChatModel/OpenRouterChatModel.node.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAWH,+CAAmD;AAEnD,2EAA8F;AAE9F,MAAa,mBAAmB;IAC9B,WAAW,GAAyB;QAClC,WAAW,EAAE,uBAAuB;QACpC,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,0BAA0B;QAChC,KAAK,EAAE,CAAC,WAAW,CAAC;QACpB,OAAO,EAAE,CAAC;QACV,WAAW,EAAE,sDAAsD;QACnE,QAAQ,EAAE,EAAE,IAAI,EAAE,uBAAuB,EAAE;QAE3C,KAAK,EAAE;YACL,UAAU,EAAE,CAAC,IAAI,CAAC;YAClB,aAAa,EAAE,EAAE,EAAE,EAAE,CAAC,iBAAiB,EAAE,YAAY,CAAC,EAAE;YACxD,SAAS,EAAE;gBACT,oBAAoB,EAAE,CAAC,EAAE,GAAG,EAAE,4DAA4D,EAAE,CAAC;aAC9F;SACF;QAED,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,CAAC,kCAAmB,CAAC,eAAe,CAAC;QAC9C,WAAW,EAAE,CAAC,OAAO,CAAC;QAEtB,WAAW,EAAE;YACX,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC1C;QAED,UAAU,EAAE;YACV;gBACE,WAAW,EAAE,OAAO;gBACpB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,6BAA6B;gBACtC,WAAW,EAAE,EAAE,iBAAiB,EAAE,WAAW,EAAE;gBAC/C,WAAW,EAAE,uCAAuC;aACrD;YACD;gBACE,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE,YAAY;gBACzB,OAAO,EAAE,EAAE;gBACX,OAAO,EAAE;oBACP;wBACE,WAAW,E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YACH,CAAC;SACF;KACF,CAAC;IAEF,KAAK,CAAC,UAAU,CAA6B,SAAiB;QAC5D,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;QAC/D,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAW,CAAC;QAClE,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAgB,CAAC;QAE/E,MAAM,SAAS,GAAG,IAAI,+CAAwB,CAAC;YAC7C,MAAM,EAAE,WAAW,CAAC,MAAgB;YACpC,KAAK;YACL,WAAW,EAAE,OAAO,CAAC,WAAiC;YACtD,SAAS,EAAE,OAAO,CAAC,SAA+B;YAClD,IAAI,EAAE,OAAO,CAAC,IAA0B;YACxC,gBAAgB,EAAE,OAAO,CAAC,gBAAsC;YAChE,eAAe,EAAE,OAAO,CAAC,eAAqC;SAC/D,CAAC,CAAC;QAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACjC,CAAC;CACF;AA3ID,kDA2IC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
|
|
2
|
+
<rect width="60" height="60" rx="12" fill="#6366f1"/>
|
|
3
|
+
<path d="M12 16h24c1.5 0 2.5 1 2.5 2.5v12c0 1.5-1 2.5-2.5 2.5H20l-5 4v-4h-3c-1.5 0-2.5-1-2.5-2.5v-12c0-1.5 1-2.5 2.5-2.5z" fill="white"/>
|
|
4
|
+
<circle cx="18" cy="24" r="2" fill="#6366f1"/>
|
|
5
|
+
<circle cx="24" cy="24" r="2" fill="#8b5cf6"/>
|
|
6
|
+
<circle cx="30" cy="24" r="2" fill="#ec4899"/>
|
|
7
|
+
<circle cx="46" cy="38" r="10" fill="white"/>
|
|
8
|
+
<path d="M42 35l4 3-4 3" stroke="#6366f1" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
|
9
|
+
<path d="M50 35l-4 3 4 3" stroke="#ec4899" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
|
10
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-openrouter-selector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "n8n community node for intelligent OpenRouter model selection based on task, budget, and benchmarks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dist/nodes/OpenRouterChatCompletion/OpenRouterChatCompletion.node.js",
|
|
45
45
|
"dist/nodes/OpenRouterSmartChat/OpenRouterSmartChat.node.js",
|
|
46
46
|
"dist/nodes/OpenRouterSmartEmbedding/OpenRouterSmartEmbedding.node.js",
|
|
47
|
-
"dist/nodes/
|
|
47
|
+
"dist/nodes/OpenRouterChatModel/OpenRouterChatModel.node.js"
|
|
48
48
|
]
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|