n8n-nodes-github-copilot 3.38.12 โ 3.38.14
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.
|
@@ -14,7 +14,7 @@ class GitHubCopilotEmbeddings {
|
|
|
14
14
|
icon: "file:../../shared/icons/copilot.svg",
|
|
15
15
|
group: ["transform"],
|
|
16
16
|
version: 1,
|
|
17
|
-
subtitle: '={{$parameter["
|
|
17
|
+
subtitle: '={{$parameter["model"]}}',
|
|
18
18
|
description: "Generate text embeddings using GitHub Copilot API",
|
|
19
19
|
defaults: {
|
|
20
20
|
name: "GitHub Copilot Embeddings",
|
|
@@ -28,21 +28,6 @@ class GitHubCopilotEmbeddings {
|
|
|
28
28
|
},
|
|
29
29
|
],
|
|
30
30
|
properties: [
|
|
31
|
-
{
|
|
32
|
-
displayName: "Operation",
|
|
33
|
-
name: "operation",
|
|
34
|
-
type: "options",
|
|
35
|
-
noDataExpression: true,
|
|
36
|
-
options: [
|
|
37
|
-
{
|
|
38
|
-
name: "Generate Embeddings",
|
|
39
|
-
value: "generate",
|
|
40
|
-
description: "Generate vector embeddings for text input",
|
|
41
|
-
action: "Generate embeddings for text",
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
default: "generate",
|
|
45
|
-
},
|
|
46
31
|
{
|
|
47
32
|
displayName: "Model",
|
|
48
33
|
name: "model",
|
|
@@ -231,7 +216,6 @@ class GitHubCopilotEmbeddings {
|
|
|
231
216
|
const returnData = [];
|
|
232
217
|
for (let i = 0; i < items.length; i++) {
|
|
233
218
|
try {
|
|
234
|
-
const operation = this.getNodeParameter("operation", i);
|
|
235
219
|
const selectedModel = this.getNodeParameter("model", i);
|
|
236
220
|
let model;
|
|
237
221
|
if (selectedModel === "__manual__") {
|
|
@@ -322,7 +306,6 @@ class GitHubCopilotEmbeddings {
|
|
|
322
306
|
returnData.push({
|
|
323
307
|
json: {
|
|
324
308
|
error: error instanceof Error ? error.message : "Unknown error occurred",
|
|
325
|
-
operation: this.getNodeParameter("operation", i),
|
|
326
309
|
},
|
|
327
310
|
pairedItem: { item: i },
|
|
328
311
|
});
|
|
@@ -14,7 +14,7 @@ class GitHubCopilotOpenAI {
|
|
|
14
14
|
icon: "file:../../shared/icons/copilot.svg",
|
|
15
15
|
group: ["transform"],
|
|
16
16
|
version: 1,
|
|
17
|
-
subtitle: "={{$parameter[\"
|
|
17
|
+
subtitle: "={{$parameter[\"model\"]}}",
|
|
18
18
|
description: "OpenAI-compatible GitHub Copilot Chat API with full support for messages, tools, and all OpenAI parameters",
|
|
19
19
|
defaults: {
|
|
20
20
|
name: "GitHub Copilot OpenAI",
|
|
@@ -43,286 +43,292 @@ class GitHubCopilotOpenAI {
|
|
|
43
43
|
const returnData = [];
|
|
44
44
|
for (let i = 0; i < items.length; i++) {
|
|
45
45
|
try {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (
|
|
46
|
+
const modelSource = this.getNodeParameter("modelSource", i, "fromList");
|
|
47
|
+
let model;
|
|
48
|
+
if (modelSource === "custom") {
|
|
49
|
+
model = this.getNodeParameter("customModel", i);
|
|
50
|
+
if (!model || model.trim() === "") {
|
|
51
|
+
throw new Error("Custom model name is required when using 'Custom (Manual Entry)' mode");
|
|
52
|
+
}
|
|
53
|
+
console.log(`๐ง Using custom model: ${model}`);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const selectedModel = this.getNodeParameter("model", i);
|
|
57
|
+
if (selectedModel === "__manual__") {
|
|
51
58
|
model = this.getNodeParameter("customModel", i);
|
|
52
59
|
if (!model || model.trim() === "") {
|
|
53
|
-
throw new Error("Custom model name is required when
|
|
60
|
+
throw new Error("Custom model name is required when selecting 'โ๏ธ Enter Custom Model Name'");
|
|
54
61
|
}
|
|
55
|
-
console.log(
|
|
62
|
+
console.log(`โ๏ธ Using manually entered model: ${model}`);
|
|
56
63
|
}
|
|
57
64
|
else {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
model = selectedModel;
|
|
66
|
+
console.log(`๐ Using model from list: ${model}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const messagesInputMode = this.getNodeParameter("messagesInputMode", i, "manual");
|
|
70
|
+
let messages = [];
|
|
71
|
+
let requestBodyFromJson = undefined;
|
|
72
|
+
if (messagesInputMode === "json") {
|
|
73
|
+
const messagesJson = this.getNodeParameter("messagesJson", i, "[]");
|
|
74
|
+
try {
|
|
75
|
+
let parsed;
|
|
76
|
+
if (typeof messagesJson === 'object') {
|
|
77
|
+
parsed = messagesJson;
|
|
78
|
+
console.log('๐ฅ Received messages as direct object/array (no parsing needed)');
|
|
65
79
|
}
|
|
66
80
|
else {
|
|
67
|
-
|
|
68
|
-
console.log(
|
|
81
|
+
parsed = JSON.parse(messagesJson);
|
|
82
|
+
console.log('๐ฅ Parsed messages from JSON string');
|
|
69
83
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
let messages = [];
|
|
73
|
-
let requestBodyFromJson = undefined;
|
|
74
|
-
if (messagesInputMode === "json") {
|
|
75
|
-
const messagesJson = this.getNodeParameter("messagesJson", i, "[]");
|
|
76
|
-
try {
|
|
77
|
-
let parsed;
|
|
78
|
-
if (typeof messagesJson === 'object') {
|
|
79
|
-
parsed = messagesJson;
|
|
80
|
-
console.log('๐ฅ Received messages as direct object/array (no parsing needed)');
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
parsed = JSON.parse(messagesJson);
|
|
84
|
-
console.log('๐ฅ Parsed messages from JSON string');
|
|
85
|
-
}
|
|
86
|
-
if (Array.isArray(parsed)) {
|
|
87
|
-
messages = parsed;
|
|
88
|
-
}
|
|
89
|
-
else if (parsed.messages && Array.isArray(parsed.messages)) {
|
|
90
|
-
messages = parsed.messages;
|
|
91
|
-
requestBodyFromJson = parsed;
|
|
92
|
-
console.log('๐ฅ Full OpenAI request body received:', JSON.stringify(parsed, null, 2));
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
messages = parsed;
|
|
96
|
-
}
|
|
84
|
+
if (Array.isArray(parsed)) {
|
|
85
|
+
messages = parsed;
|
|
97
86
|
}
|
|
98
|
-
|
|
99
|
-
|
|
87
|
+
else if (parsed.messages && Array.isArray(parsed.messages)) {
|
|
88
|
+
messages = parsed.messages;
|
|
89
|
+
requestBodyFromJson = parsed;
|
|
90
|
+
console.log('๐ฅ Full OpenAI request body received:', JSON.stringify(parsed, null, 2));
|
|
100
91
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const messagesParam = this.getNodeParameter("messages", i, {
|
|
104
|
-
message: [],
|
|
105
|
-
});
|
|
106
|
-
console.log('๐ฅ Manual mode - messagesParam:', JSON.stringify(messagesParam, null, 2));
|
|
107
|
-
if (messagesParam.message && Array.isArray(messagesParam.message)) {
|
|
108
|
-
for (const msg of messagesParam.message) {
|
|
109
|
-
const message = {
|
|
110
|
-
role: msg.role,
|
|
111
|
-
content: msg.content,
|
|
112
|
-
};
|
|
113
|
-
if (msg.type && msg.type !== 'text') {
|
|
114
|
-
message.type = msg.type;
|
|
115
|
-
}
|
|
116
|
-
messages.push(message);
|
|
117
|
-
}
|
|
92
|
+
else {
|
|
93
|
+
messages = parsed;
|
|
118
94
|
}
|
|
119
|
-
console.log('๐ฅ Manual mode - parsed messages:', JSON.stringify(messages, null, 2));
|
|
120
95
|
}
|
|
121
|
-
|
|
122
|
-
messages.
|
|
123
|
-
role: "user",
|
|
124
|
-
content: "Hello! How can you help me?",
|
|
125
|
-
});
|
|
96
|
+
catch (error) {
|
|
97
|
+
throw new Error(`Failed to parse messages JSON: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
126
98
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
const messagesParam = this.getNodeParameter("messages", i, {
|
|
102
|
+
message: [],
|
|
103
|
+
});
|
|
104
|
+
console.log('๐ฅ Manual mode - messagesParam:', JSON.stringify(messagesParam, null, 2));
|
|
105
|
+
if (messagesParam.message && Array.isArray(messagesParam.message)) {
|
|
106
|
+
for (const msg of messagesParam.message) {
|
|
107
|
+
const message = {
|
|
108
|
+
role: msg.role,
|
|
109
|
+
content: msg.content,
|
|
110
|
+
};
|
|
111
|
+
if (msg.type && (msg.type === 'text' || msg.type === 'image_url')) {
|
|
112
|
+
message.type = msg.type;
|
|
140
113
|
}
|
|
114
|
+
messages.push(message);
|
|
141
115
|
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
throw new Error(`Failed to parse tools JSON: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
let max_tokens = advancedOptions.max_tokens || 4096;
|
|
147
|
-
if (!max_tokens || max_tokens <= 0 || isNaN(max_tokens)) {
|
|
148
|
-
max_tokens = 4096;
|
|
149
|
-
console.log('โ ๏ธ Invalid max_tokens value, using default: 4096');
|
|
150
|
-
}
|
|
151
|
-
const temperature = (_a = advancedOptions.temperature) !== null && _a !== void 0 ? _a : 1;
|
|
152
|
-
const top_p = (_b = advancedOptions.top_p) !== null && _b !== void 0 ? _b : 1;
|
|
153
|
-
const frequency_penalty = (_c = advancedOptions.frequency_penalty) !== null && _c !== void 0 ? _c : 0;
|
|
154
|
-
const presence_penalty = (_d = advancedOptions.presence_penalty) !== null && _d !== void 0 ? _d : 0;
|
|
155
|
-
const seed = advancedOptions.seed || 0;
|
|
156
|
-
const stream = (_e = advancedOptions.stream) !== null && _e !== void 0 ? _e : false;
|
|
157
|
-
const user = advancedOptions.user || undefined;
|
|
158
|
-
const stop = advancedOptions.stop || undefined;
|
|
159
|
-
const response_format_ui = advancedOptions.response_format || "text";
|
|
160
|
-
let response_format = undefined;
|
|
161
|
-
if (requestBodyFromJson === null || requestBodyFromJson === void 0 ? void 0 : requestBodyFromJson.response_format) {
|
|
162
|
-
response_format = requestBodyFromJson.response_format;
|
|
163
|
-
console.log('๐ response_format from JSON request body:', JSON.stringify(response_format));
|
|
164
116
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
117
|
+
console.log('๐ฅ Manual mode - parsed messages:', JSON.stringify(messages, null, 2));
|
|
118
|
+
}
|
|
119
|
+
if (messages.length === 0) {
|
|
120
|
+
messages.push({
|
|
121
|
+
role: "user",
|
|
122
|
+
content: "Hello! How can you help me?",
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
console.log('๐ค Final messages being sent to API:', JSON.stringify(messages, null, 2));
|
|
126
|
+
const advancedOptions = this.getNodeParameter("advancedOptions", i, {});
|
|
127
|
+
let parsedTools = [];
|
|
128
|
+
const tools = advancedOptions.tools;
|
|
129
|
+
if (tools) {
|
|
130
|
+
try {
|
|
131
|
+
if (typeof tools === 'object' && Array.isArray(tools) && tools.length > 0) {
|
|
132
|
+
parsedTools = tools;
|
|
133
|
+
console.log('๐ฅ Received tools as direct array (no parsing needed)');
|
|
134
|
+
}
|
|
135
|
+
else if (typeof tools === 'string' && tools.trim()) {
|
|
136
|
+
const parsed = JSON.parse(tools);
|
|
137
|
+
if (Array.isArray(parsed) && parsed.length > 0) {
|
|
138
|
+
parsedTools = parsed;
|
|
139
|
+
console.log('๐ฅ Parsed tools from JSON string');
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
console.log('๐ฅ Tools string parsed but empty or not an array');
|
|
143
|
+
}
|
|
173
144
|
}
|
|
174
|
-
|
|
175
|
-
console.log('
|
|
145
|
+
else {
|
|
146
|
+
console.log('๐ฅ Tools field present but empty or invalid');
|
|
176
147
|
}
|
|
177
148
|
}
|
|
178
|
-
|
|
179
|
-
console.log('
|
|
180
|
-
console.log('๐ response_format.type:', response_format.type);
|
|
149
|
+
catch (error) {
|
|
150
|
+
console.log('โ ๏ธ Failed to parse tools, ignoring:', error instanceof Error ? error.message : "Unknown error");
|
|
181
151
|
}
|
|
182
|
-
|
|
183
|
-
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
console.log('๐ฅ No tools specified');
|
|
155
|
+
}
|
|
156
|
+
let max_tokens = advancedOptions.max_tokens || 4096;
|
|
157
|
+
if (!max_tokens || max_tokens <= 0 || isNaN(max_tokens)) {
|
|
158
|
+
max_tokens = 4096;
|
|
159
|
+
console.log('โ ๏ธ Invalid max_tokens value, using default: 4096');
|
|
160
|
+
}
|
|
161
|
+
const temperature = (_a = advancedOptions.temperature) !== null && _a !== void 0 ? _a : 1;
|
|
162
|
+
const top_p = (_b = advancedOptions.top_p) !== null && _b !== void 0 ? _b : 1;
|
|
163
|
+
const frequency_penalty = (_c = advancedOptions.frequency_penalty) !== null && _c !== void 0 ? _c : 0;
|
|
164
|
+
const presence_penalty = (_d = advancedOptions.presence_penalty) !== null && _d !== void 0 ? _d : 0;
|
|
165
|
+
const seed = advancedOptions.seed || 0;
|
|
166
|
+
const stream = (_e = advancedOptions.stream) !== null && _e !== void 0 ? _e : false;
|
|
167
|
+
const user = advancedOptions.user || undefined;
|
|
168
|
+
const stop = advancedOptions.stop || undefined;
|
|
169
|
+
const response_format_ui = advancedOptions.response_format || "text";
|
|
170
|
+
let response_format = undefined;
|
|
171
|
+
if (requestBodyFromJson === null || requestBodyFromJson === void 0 ? void 0 : requestBodyFromJson.response_format) {
|
|
172
|
+
response_format = requestBodyFromJson.response_format;
|
|
173
|
+
console.log('๐ response_format from JSON request body:', JSON.stringify(response_format));
|
|
174
|
+
}
|
|
175
|
+
else if (response_format_ui && response_format_ui !== 'text') {
|
|
176
|
+
response_format = { type: response_format_ui };
|
|
177
|
+
console.log('๐ response_format from UI field:', JSON.stringify(response_format));
|
|
178
|
+
}
|
|
179
|
+
else if (advancedOptions.response_format && typeof advancedOptions.response_format === 'string') {
|
|
180
|
+
try {
|
|
181
|
+
response_format = JSON.parse(advancedOptions.response_format);
|
|
182
|
+
console.log('๐ response_format from advancedOptions:', JSON.stringify(response_format));
|
|
184
183
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
"gpt-4o": "gpt-4o",
|
|
188
|
-
"gpt-4o-mini": "gpt-4o-mini",
|
|
189
|
-
"gpt-4-turbo": "gpt-4o",
|
|
190
|
-
"claude-3-5-sonnet": "claude-3.5-sonnet",
|
|
191
|
-
"claude-3.5-sonnet-20241022": "claude-3.5-sonnet",
|
|
192
|
-
"o1": "o1",
|
|
193
|
-
"o1-preview": "o1-preview",
|
|
194
|
-
"o1-mini": "o1-mini",
|
|
195
|
-
};
|
|
196
|
-
const copilotModel = modelMapping[model] || model;
|
|
197
|
-
const requestBody = {
|
|
198
|
-
model: copilotModel,
|
|
199
|
-
messages,
|
|
200
|
-
stream,
|
|
201
|
-
temperature,
|
|
202
|
-
max_tokens,
|
|
203
|
-
};
|
|
204
|
-
if (top_p !== 1) {
|
|
205
|
-
requestBody.top_p = top_p;
|
|
184
|
+
catch {
|
|
185
|
+
console.log('โ ๏ธ Failed to parse response_format from advancedOptions');
|
|
206
186
|
}
|
|
207
|
-
|
|
208
|
-
|
|
187
|
+
}
|
|
188
|
+
if (response_format) {
|
|
189
|
+
console.log('โ
Final response_format:', JSON.stringify(response_format));
|
|
190
|
+
console.log('๐ response_format.type:', response_format.type);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
console.log('โน๏ธ No response_format specified - using default text format');
|
|
194
|
+
}
|
|
195
|
+
const modelMapping = {
|
|
196
|
+
"gpt-4": "gpt-4o",
|
|
197
|
+
"gpt-4o": "gpt-4o",
|
|
198
|
+
"gpt-4o-mini": "gpt-4o-mini",
|
|
199
|
+
"gpt-4-turbo": "gpt-4o",
|
|
200
|
+
"claude-3-5-sonnet": "claude-3.5-sonnet",
|
|
201
|
+
"claude-3.5-sonnet-20241022": "claude-3.5-sonnet",
|
|
202
|
+
"o1": "o1",
|
|
203
|
+
"o1-preview": "o1-preview",
|
|
204
|
+
"o1-mini": "o1-mini",
|
|
205
|
+
};
|
|
206
|
+
const copilotModel = modelMapping[model] || model;
|
|
207
|
+
const requestBody = {
|
|
208
|
+
model: copilotModel,
|
|
209
|
+
messages,
|
|
210
|
+
stream,
|
|
211
|
+
temperature,
|
|
212
|
+
max_tokens,
|
|
213
|
+
};
|
|
214
|
+
if (top_p !== 1) {
|
|
215
|
+
requestBody.top_p = top_p;
|
|
216
|
+
}
|
|
217
|
+
if (frequency_penalty !== 0) {
|
|
218
|
+
requestBody.frequency_penalty = frequency_penalty;
|
|
219
|
+
}
|
|
220
|
+
if (presence_penalty !== 0) {
|
|
221
|
+
requestBody.presence_penalty = presence_penalty;
|
|
222
|
+
}
|
|
223
|
+
if (user) {
|
|
224
|
+
requestBody.user = user;
|
|
225
|
+
}
|
|
226
|
+
if (stop) {
|
|
227
|
+
try {
|
|
228
|
+
requestBody.stop = JSON.parse(stop);
|
|
209
229
|
}
|
|
210
|
-
|
|
211
|
-
requestBody.
|
|
230
|
+
catch {
|
|
231
|
+
requestBody.stop = stop;
|
|
212
232
|
}
|
|
213
|
-
|
|
214
|
-
|
|
233
|
+
}
|
|
234
|
+
if (parsedTools.length > 0) {
|
|
235
|
+
requestBody.tools = parsedTools;
|
|
236
|
+
const tool_choice = advancedOptions.tool_choice || "auto";
|
|
237
|
+
if (tool_choice !== "auto") {
|
|
238
|
+
requestBody.tool_choice = tool_choice;
|
|
215
239
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
240
|
+
}
|
|
241
|
+
if (response_format) {
|
|
242
|
+
requestBody.response_format = response_format;
|
|
243
|
+
}
|
|
244
|
+
if (seed > 0) {
|
|
245
|
+
requestBody.seed = seed;
|
|
246
|
+
}
|
|
247
|
+
console.log('๐ Sending request to GitHub Copilot API:');
|
|
248
|
+
console.log(' Model:', copilotModel);
|
|
249
|
+
console.log(' Messages count:', messages.length);
|
|
250
|
+
console.log(' Request body:', JSON.stringify(requestBody, null, 2));
|
|
251
|
+
const response = await (0, utils_1.makeApiRequest)(this, GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.ENDPOINTS.CHAT_COMPLETIONS, requestBody, false);
|
|
252
|
+
const retriesUsed = ((_f = response._retryMetadata) === null || _f === void 0 ? void 0 : _f.retries) || 0;
|
|
253
|
+
if (retriesUsed > 0) {
|
|
254
|
+
console.log(`โน๏ธ Request completed with ${retriesUsed} retry(ies)`);
|
|
255
|
+
}
|
|
256
|
+
const cleanJsonFromMarkdown = (content) => {
|
|
257
|
+
if (!content || typeof content !== 'string') {
|
|
258
|
+
return content;
|
|
223
259
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
260
|
+
try {
|
|
261
|
+
const trimmed = content.trim();
|
|
262
|
+
console.log('๐งน cleanJsonFromMarkdown - Input length:', trimmed.length);
|
|
263
|
+
const jsonBlockRegex = /^```(?:json)?\s*\n([\s\S]*?)\n```\s*$/;
|
|
264
|
+
const match = trimmed.match(jsonBlockRegex);
|
|
265
|
+
if (match && match[1]) {
|
|
266
|
+
const extracted = match[1].trim();
|
|
267
|
+
console.log('โ
cleanJsonFromMarkdown - Extracted from markdown block');
|
|
268
|
+
return extracted;
|
|
229
269
|
}
|
|
270
|
+
console.log('โน๏ธ cleanJsonFromMarkdown - No markdown block found, returning as is');
|
|
271
|
+
return trimmed;
|
|
230
272
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (seed > 0) {
|
|
235
|
-
requestBody.seed = seed;
|
|
273
|
+
catch (error) {
|
|
274
|
+
console.error('โ cleanJsonFromMarkdown - Error:', error);
|
|
275
|
+
return content;
|
|
236
276
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
console.log('โ
|
|
258
|
-
|
|
277
|
+
};
|
|
278
|
+
console.log('๐จ Building OpenAI response...');
|
|
279
|
+
console.log('๐ response_format check:', (response_format === null || response_format === void 0 ? void 0 : response_format.type) === 'json_object' ? 'WILL CLEAN MARKDOWN' : 'WILL KEEP AS IS');
|
|
280
|
+
const openAIResponse = {
|
|
281
|
+
id: response.id || `chatcmpl-${Date.now()}`,
|
|
282
|
+
object: response.object || "chat.completion",
|
|
283
|
+
created: response.created || Math.floor(Date.now() / 1000),
|
|
284
|
+
model: model,
|
|
285
|
+
choices: response.choices.map((choice, choiceIndex) => {
|
|
286
|
+
var _a;
|
|
287
|
+
console.log(`\n๐ Processing choice ${choiceIndex}:`);
|
|
288
|
+
console.log(' - role:', choice.message.role);
|
|
289
|
+
console.log(' - content type:', typeof choice.message.content);
|
|
290
|
+
console.log(' - content length:', ((_a = choice.message.content) === null || _a === void 0 ? void 0 : _a.length) || 0);
|
|
291
|
+
console.log(' - has tool_calls:', !!choice.message.tool_calls);
|
|
292
|
+
let processedContent = choice.message.content;
|
|
293
|
+
if (choice.message.content !== null && choice.message.content !== undefined) {
|
|
294
|
+
if ((response_format === null || response_format === void 0 ? void 0 : response_format.type) === 'json_object') {
|
|
295
|
+
console.log(' ๐งน Applying cleanJsonFromMarkdown (keeping as string)...');
|
|
296
|
+
processedContent = cleanJsonFromMarkdown(choice.message.content);
|
|
297
|
+
console.log(' โ
Processed content type:', typeof processedContent);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
console.log(' โน๏ธ Keeping content as is');
|
|
259
301
|
}
|
|
260
|
-
console.log('โน๏ธ cleanJsonFromMarkdown - No markdown block found, returning as is');
|
|
261
|
-
return trimmed;
|
|
262
302
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
303
|
+
const choiceObj = {
|
|
304
|
+
index: choice.index,
|
|
305
|
+
message: {
|
|
306
|
+
role: choice.message.role,
|
|
307
|
+
content: processedContent,
|
|
308
|
+
refusal: choice.message.refusal || null,
|
|
309
|
+
annotations: choice.message.annotations || [],
|
|
310
|
+
},
|
|
311
|
+
logprobs: choice.logprobs || null,
|
|
312
|
+
finish_reason: choice.finish_reason,
|
|
313
|
+
};
|
|
314
|
+
if (choice.message.tool_calls && choice.message.tool_calls.length > 0) {
|
|
315
|
+
choiceObj.message.tool_calls = choice.message.tool_calls;
|
|
266
316
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
console.log(`\n๐ Processing choice ${choiceIndex}:`);
|
|
278
|
-
console.log(' - role:', choice.message.role);
|
|
279
|
-
console.log(' - content type:', typeof choice.message.content);
|
|
280
|
-
console.log(' - content length:', ((_a = choice.message.content) === null || _a === void 0 ? void 0 : _a.length) || 0);
|
|
281
|
-
console.log(' - has tool_calls:', !!choice.message.tool_calls);
|
|
282
|
-
let processedContent = choice.message.content;
|
|
283
|
-
if (choice.message.content !== null && choice.message.content !== undefined) {
|
|
284
|
-
if ((response_format === null || response_format === void 0 ? void 0 : response_format.type) === 'json_object') {
|
|
285
|
-
console.log(' ๐งน Applying cleanJsonFromMarkdown (keeping as string)...');
|
|
286
|
-
processedContent = cleanJsonFromMarkdown(choice.message.content);
|
|
287
|
-
console.log(' โ
Processed content type:', typeof processedContent);
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
console.log(' โน๏ธ Keeping content as is');
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
const choiceObj = {
|
|
294
|
-
index: choice.index,
|
|
295
|
-
message: {
|
|
296
|
-
role: choice.message.role,
|
|
297
|
-
content: processedContent,
|
|
298
|
-
refusal: choice.message.refusal || null,
|
|
299
|
-
annotations: choice.message.annotations || [],
|
|
300
|
-
},
|
|
301
|
-
logprobs: choice.logprobs || null,
|
|
302
|
-
finish_reason: choice.finish_reason,
|
|
303
|
-
};
|
|
304
|
-
if (choice.message.tool_calls && choice.message.tool_calls.length > 0) {
|
|
305
|
-
choiceObj.message.tool_calls = choice.message.tool_calls;
|
|
306
|
-
}
|
|
307
|
-
return choiceObj;
|
|
308
|
-
}),
|
|
309
|
-
usage: response.usage || {
|
|
310
|
-
prompt_tokens: 0,
|
|
311
|
-
completion_tokens: 0,
|
|
312
|
-
total_tokens: 0,
|
|
313
|
-
},
|
|
314
|
-
};
|
|
315
|
-
if (response.system_fingerprint) {
|
|
316
|
-
openAIResponse.system_fingerprint = response.system_fingerprint;
|
|
317
|
-
}
|
|
318
|
-
returnData.push({
|
|
319
|
-
json: openAIResponse,
|
|
320
|
-
pairedItem: { item: i },
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
throw new Error(`Unknown operation: ${operation}`);
|
|
317
|
+
return choiceObj;
|
|
318
|
+
}),
|
|
319
|
+
usage: response.usage || {
|
|
320
|
+
prompt_tokens: 0,
|
|
321
|
+
completion_tokens: 0,
|
|
322
|
+
total_tokens: 0,
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
if (response.system_fingerprint) {
|
|
326
|
+
openAIResponse.system_fingerprint = response.system_fingerprint;
|
|
325
327
|
}
|
|
328
|
+
returnData.push({
|
|
329
|
+
json: openAIResponse,
|
|
330
|
+
pairedItem: { item: i },
|
|
331
|
+
});
|
|
326
332
|
}
|
|
327
333
|
catch (error) {
|
|
328
334
|
if (this.continueOnFail()) {
|
|
@@ -3,20 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.nodeProperties = void 0;
|
|
4
4
|
const ModelProperties_1 = require("../../shared/properties/ModelProperties");
|
|
5
5
|
exports.nodeProperties = [
|
|
6
|
-
{
|
|
7
|
-
displayName: "Operation",
|
|
8
|
-
name: "operation",
|
|
9
|
-
type: "options",
|
|
10
|
-
noDataExpression: true,
|
|
11
|
-
options: [
|
|
12
|
-
{
|
|
13
|
-
name: "Chat Completion",
|
|
14
|
-
value: "chat",
|
|
15
|
-
description: "Send messages to GitHub Copilot Chat API with full OpenAI compatibility",
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
default: "chat",
|
|
19
|
-
},
|
|
20
6
|
...ModelProperties_1.CHAT_MODEL_PROPERTIES,
|
|
21
7
|
{
|
|
22
8
|
displayName: "Messages Input Mode",
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-github-copilot",
|
|
3
|
-
"version": "3.38.
|
|
3
|
+
"version": "3.38.14",
|
|
4
4
|
"description": "n8n community node for GitHub Copilot with CLI integration, Chat API access, and AI Chat Model for workflows - access GPT-5, Claude, Gemini and more using your Copilot subscription",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/sufficit/n8n-nodes-github-copilot",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-github-copilot",
|
|
3
|
-
"version": "3.38.
|
|
3
|
+
"version": "3.38.14",
|
|
4
4
|
"description": "n8n community node for GitHub Copilot with CLI integration, Chat API access, and AI Chat Model for workflows - access GPT-5, Claude, Gemini and more using your Copilot subscription",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/sufficit/n8n-nodes-github-copilot",
|