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["operation"]}}',
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[\"operation\"] + \": \" + $parameter[\"model\"]}}",
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 operation = this.getNodeParameter("operation", i);
47
- if (operation === "chat") {
48
- const modelSource = this.getNodeParameter("modelSource", i, "fromList");
49
- let model;
50
- if (modelSource === "custom") {
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 using 'Custom (Manual Entry)' mode");
60
+ throw new Error("Custom model name is required when selecting 'โœ๏ธ Enter Custom Model Name'");
54
61
  }
55
- console.log(`๐Ÿ”ง Using custom model: ${model}`);
62
+ console.log(`โœ๏ธ Using manually entered model: ${model}`);
56
63
  }
57
64
  else {
58
- const selectedModel = this.getNodeParameter("model", i);
59
- if (selectedModel === "__manual__") {
60
- model = this.getNodeParameter("customModel", i);
61
- if (!model || model.trim() === "") {
62
- throw new Error("Custom model name is required when selecting 'โœ๏ธ Enter Custom Model Name'");
63
- }
64
- console.log(`โœ๏ธ Using manually entered model: ${model}`);
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
- model = selectedModel;
68
- console.log(`๐Ÿ“‹ Using model from list: ${model}`);
81
+ parsed = JSON.parse(messagesJson);
82
+ console.log('๐Ÿ“ฅ Parsed messages from JSON string');
69
83
  }
70
- }
71
- const messagesInputMode = this.getNodeParameter("messagesInputMode", i, "manual");
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
- catch (error) {
99
- throw new Error(`Failed to parse messages JSON: ${error instanceof Error ? error.message : "Unknown error"}`);
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
- else {
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
- if (messages.length === 0) {
122
- messages.push({
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
- console.log('๐Ÿ“ค Final messages being sent to API:', JSON.stringify(messages, null, 2));
128
- const advancedOptions = this.getNodeParameter("advancedOptions", i, {});
129
- let parsedTools = [];
130
- const tools = advancedOptions.tools;
131
- if (tools) {
132
- try {
133
- if (typeof tools === 'object' && Array.isArray(tools)) {
134
- parsedTools = tools;
135
- console.log('๐Ÿ“ฅ Received tools as direct array (no parsing needed)');
136
- }
137
- else if (typeof tools === 'string' && tools.trim()) {
138
- parsedTools = JSON.parse(tools);
139
- console.log('๐Ÿ“ฅ Parsed tools from JSON string');
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
- else if (response_format_ui && response_format_ui !== 'text') {
166
- response_format = { type: response_format_ui };
167
- console.log('๐Ÿ“‹ response_format from UI field:', JSON.stringify(response_format));
168
- }
169
- else if (advancedOptions.response_format && typeof advancedOptions.response_format === 'string') {
170
- try {
171
- response_format = JSON.parse(advancedOptions.response_format);
172
- console.log('๐Ÿ“‹ response_format from advancedOptions:', JSON.stringify(response_format));
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
- catch {
175
- console.log('โš ๏ธ Failed to parse response_format from advancedOptions');
145
+ else {
146
+ console.log('๐Ÿ“ฅ Tools field present but empty or invalid');
176
147
  }
177
148
  }
178
- if (response_format) {
179
- console.log('โœ… Final response_format:', JSON.stringify(response_format));
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
- else {
183
- console.log('โ„น๏ธ No response_format specified - using default text format');
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
- const modelMapping = {
186
- "gpt-4": "gpt-4o",
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
- if (frequency_penalty !== 0) {
208
- requestBody.frequency_penalty = frequency_penalty;
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
- if (presence_penalty !== 0) {
211
- requestBody.presence_penalty = presence_penalty;
230
+ catch {
231
+ requestBody.stop = stop;
212
232
  }
213
- if (user) {
214
- requestBody.user = user;
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
- if (stop) {
217
- try {
218
- requestBody.stop = JSON.parse(stop);
219
- }
220
- catch {
221
- requestBody.stop = stop;
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
- if (parsedTools.length > 0) {
225
- requestBody.tools = parsedTools;
226
- const tool_choice = advancedOptions.tool_choice || "auto";
227
- if (tool_choice !== "auto") {
228
- requestBody.tool_choice = tool_choice;
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
- if (response_format) {
232
- requestBody.response_format = response_format;
233
- }
234
- if (seed > 0) {
235
- requestBody.seed = seed;
273
+ catch (error) {
274
+ console.error('โŒ cleanJsonFromMarkdown - Error:', error);
275
+ return content;
236
276
  }
237
- console.log('๐Ÿš€ Sending request to GitHub Copilot API:');
238
- console.log(' Model:', copilotModel);
239
- console.log(' Messages count:', messages.length);
240
- console.log(' Request body:', JSON.stringify(requestBody, null, 2));
241
- const response = await (0, utils_1.makeApiRequest)(this, GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.ENDPOINTS.CHAT_COMPLETIONS, requestBody, false);
242
- const retriesUsed = ((_f = response._retryMetadata) === null || _f === void 0 ? void 0 : _f.retries) || 0;
243
- if (retriesUsed > 0) {
244
- console.log(`โ„น๏ธ Request completed with ${retriesUsed} retry(ies)`);
245
- }
246
- const cleanJsonFromMarkdown = (content) => {
247
- if (!content || typeof content !== 'string') {
248
- return content;
249
- }
250
- try {
251
- const trimmed = content.trim();
252
- console.log('๐Ÿงน cleanJsonFromMarkdown - Input length:', trimmed.length);
253
- const jsonBlockRegex = /^```(?:json)?\s*\n([\s\S]*?)\n```\s*$/;
254
- const match = trimmed.match(jsonBlockRegex);
255
- if (match && match[1]) {
256
- const extracted = match[1].trim();
257
- console.log('โœ… cleanJsonFromMarkdown - Extracted from markdown block');
258
- return extracted;
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
- catch (error) {
264
- console.error('โŒ cleanJsonFromMarkdown - Error:', error);
265
- return content;
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
- console.log('๐Ÿ”จ Building OpenAI response...');
269
- 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');
270
- const openAIResponse = {
271
- id: response.id || `chatcmpl-${Date.now()}`,
272
- object: response.object || "chat.completion",
273
- created: response.created || Math.floor(Date.now() / 1000),
274
- model: model,
275
- choices: response.choices.map((choice, choiceIndex) => {
276
- var _a;
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.12",
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.12",
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",