n8n-nodes-github-copilot 3.31.24 → 3.31.25

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.
@@ -40,10 +40,22 @@ class GitHubCopilotOpenAI {
40
40
  const temperature = this.getNodeParameter("temperature", i, 1);
41
41
  const tools = this.getNodeParameter("tools", i, "");
42
42
  let messages = [];
43
+ let requestBodyFromJson = undefined;
43
44
  if (messagesInputMode === "json") {
44
45
  const messagesJson = this.getNodeParameter("messagesJson", i, "[]");
45
46
  try {
46
- messages = JSON.parse(messagesJson);
47
+ const parsed = JSON.parse(messagesJson);
48
+ if (Array.isArray(parsed)) {
49
+ messages = parsed;
50
+ }
51
+ else if (parsed.messages && Array.isArray(parsed.messages)) {
52
+ messages = parsed.messages;
53
+ requestBodyFromJson = parsed;
54
+ console.log('šŸ“„ Full OpenAI request body received:', JSON.stringify(parsed, null, 2));
55
+ }
56
+ else {
57
+ messages = parsed;
58
+ }
47
59
  }
48
60
  catch (error) {
49
61
  throw new Error(`Failed to parse messages JSON: ${error instanceof Error ? error.message : "Unknown error"}`);
@@ -81,13 +93,26 @@ class GitHubCopilotOpenAI {
81
93
  const seed = this.getNodeParameter("seed", i, 0);
82
94
  const advancedOptions = this.getNodeParameter("advancedOptions", i, {});
83
95
  let response_format = undefined;
84
- if (advancedOptions.response_format && typeof advancedOptions.response_format === 'string') {
96
+ if (requestBodyFromJson === null || requestBodyFromJson === void 0 ? void 0 : requestBodyFromJson.response_format) {
97
+ response_format = requestBodyFromJson.response_format;
98
+ console.log('šŸ“‹ response_format from JSON request body:', JSON.stringify(response_format));
99
+ }
100
+ else if (advancedOptions.response_format && typeof advancedOptions.response_format === 'string') {
85
101
  try {
86
102
  response_format = JSON.parse(advancedOptions.response_format);
103
+ console.log('šŸ“‹ response_format from advancedOptions:', JSON.stringify(response_format));
87
104
  }
88
105
  catch {
106
+ console.log('āš ļø Failed to parse response_format from advancedOptions');
89
107
  }
90
108
  }
109
+ if (response_format) {
110
+ console.log('āœ… Final response_format:', JSON.stringify(response_format));
111
+ console.log('šŸ” response_format.type:', response_format.type);
112
+ }
113
+ else {
114
+ console.log('ā„¹ļø No response_format specified');
115
+ }
91
116
  const modelMapping = {
92
117
  "gpt-4": "gpt-4o",
93
118
  "gpt-4o": "gpt-4o",
@@ -141,24 +166,43 @@ class GitHubCopilotOpenAI {
141
166
  return content;
142
167
  }
143
168
  };
169
+ console.log('šŸ”Ø Building OpenAI response...');
170
+ console.log('šŸ” response_format check:', (response_format === null || response_format === void 0 ? void 0 : response_format.type) === 'json_object' ? 'WILL PARSE JSON' : 'WILL KEEP AS STRING');
144
171
  const openAIResponse = {
145
172
  id: response.id || `chatcmpl-${Date.now()}`,
146
173
  object: response.object || "chat.completion",
147
174
  created: response.created || Math.floor(Date.now() / 1000),
148
175
  model: model,
149
- choices: response.choices.map((choice) => ({
150
- index: choice.index,
151
- message: {
152
- role: choice.message.role,
153
- ...(choice.message.content !== null && choice.message.content !== undefined && {
154
- content: (response_format === null || response_format === void 0 ? void 0 : response_format.type) === 'json_object'
155
- ? parseJsonContent(choice.message.content)
156
- : choice.message.content
157
- }),
158
- ...(choice.message.tool_calls && { tool_calls: choice.message.tool_calls }),
159
- },
160
- finish_reason: choice.finish_reason,
161
- })),
176
+ choices: response.choices.map((choice, choiceIndex) => {
177
+ var _a;
178
+ console.log(`\nšŸ“ Processing choice ${choiceIndex}:`);
179
+ console.log(' - role:', choice.message.role);
180
+ console.log(' - content type:', typeof choice.message.content);
181
+ console.log(' - content length:', ((_a = choice.message.content) === null || _a === void 0 ? void 0 : _a.length) || 0);
182
+ console.log(' - has tool_calls:', !!choice.message.tool_calls);
183
+ let processedContent = choice.message.content;
184
+ if (choice.message.content !== null && choice.message.content !== undefined) {
185
+ if ((response_format === null || response_format === void 0 ? void 0 : response_format.type) === 'json_object') {
186
+ console.log(' šŸ”„ Applying parseJsonContent...');
187
+ processedContent = parseJsonContent(choice.message.content);
188
+ console.log(' āœ… Processed content type:', typeof processedContent);
189
+ }
190
+ else {
191
+ console.log(' ā„¹ļø Keeping content as string');
192
+ }
193
+ }
194
+ return {
195
+ index: choice.index,
196
+ message: {
197
+ role: choice.message.role,
198
+ ...(choice.message.content !== null && choice.message.content !== undefined && {
199
+ content: processedContent
200
+ }),
201
+ ...(choice.message.tool_calls && { tool_calls: choice.message.tool_calls }),
202
+ },
203
+ finish_reason: choice.finish_reason,
204
+ };
205
+ }),
162
206
  usage: response.usage || {
163
207
  prompt_tokens: 0,
164
208
  completion_tokens: 0,
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "3.31.24",
3
+ "version": "3.31.25",
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.31.24",
3
+ "version": "3.31.25",
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",