n8n-nodes-github-copilot 3.27.5 → 3.28.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/dist/credentials/GitHubCopilotApi.credentials.d.ts +1 -1
- package/dist/credentials/GitHubCopilotApi.credentials.js +19 -19
- package/dist/credentials/GitHubCopilotOAuth2Api.credentials.backup.d.ts +1 -1
- package/dist/credentials/GitHubCopilotOAuth2Api.credentials.backup.js +71 -71
- package/dist/credentials/GitHubCopilotOAuth2Api.credentials.d.ts +1 -1
- package/dist/credentials/GitHubCopilotOAuth2Api.credentials.js +67 -67
- package/dist/credentials/GitHubCopilotOAuth2Api.credentials.oauth.d.ts +1 -9
- package/dist/credentials/GitHubCopilotOAuth2Api.credentials.oauth.js +38 -63
- package/dist/nodes/GitHubCopilot/GitHubCopilot.node.d.ts +1 -1
- package/dist/nodes/GitHubCopilot/GitHubCopilot.node.js +188 -181
- package/dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.d.ts +1 -1
- package/dist/nodes/GitHubCopilotChatAPI/GitHubCopilotChatAPI.node.js +38 -38
- package/dist/nodes/GitHubCopilotChatAPI/nodeProperties.d.ts +1 -1
- package/dist/nodes/GitHubCopilotChatAPI/nodeProperties.js +97 -97
- package/dist/nodes/GitHubCopilotChatAPI/utils/imageProcessor.d.ts +2 -2
- package/dist/nodes/GitHubCopilotChatAPI/utils/imageProcessor.js +16 -15
- package/dist/nodes/GitHubCopilotChatAPI/utils/index.d.ts +3 -3
- package/dist/nodes/GitHubCopilotChatAPI/utils/mediaDetection.d.ts +3 -3
- package/dist/nodes/GitHubCopilotChatAPI/utils/mediaDetection.js +20 -26
- package/dist/nodes/GitHubCopilotChatAPI/utils/modelCapabilities.d.ts +1 -1
- package/dist/nodes/GitHubCopilotChatAPI/utils/modelCapabilities.js +24 -24
- package/dist/nodes/GitHubCopilotChatAPI/utils/types.d.ts +4 -4
- package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.d.ts +1 -1
- package/dist/nodes/GitHubCopilotChatModel/GitHubCopilotChatModel.node.js +86 -82
- package/dist/nodes/GitHubCopilotOpenAI/GitHubCopilotOpenAI.node.d.ts +5 -0
- package/dist/nodes/GitHubCopilotOpenAI/GitHubCopilotOpenAI.node.js +142 -0
- package/dist/nodes/GitHubCopilotOpenAI/nodeProperties.d.ts +2 -0
- package/dist/nodes/GitHubCopilotOpenAI/nodeProperties.js +326 -0
- package/dist/nodes/GitHubCopilotOpenAI/utils/index.d.ts +2 -0
- package/dist/nodes/GitHubCopilotOpenAI/utils/index.js +24 -0
- package/dist/nodes/GitHubCopilotOpenAI/utils/openaiCompat.d.ts +95 -0
- package/dist/nodes/GitHubCopilotOpenAI/utils/openaiCompat.js +175 -0
- package/dist/nodes/GitHubCopilotOpenAI/utils/types.d.ts +101 -0
- package/dist/nodes/GitHubCopilotOpenAI/utils/types.js +2 -0
- package/dist/nodes/GitHubCopilotTest/GitHubCopilotTest.node.d.ts +1 -1
- package/dist/nodes/GitHubCopilotTest/GitHubCopilotTest.node.js +96 -94
- package/package.json +75 -74
|
@@ -14,7 +14,7 @@ async function processMediaFile(context, itemIndex, source, mediaFile, mediaUrl,
|
|
|
14
14
|
throw new Error(suggestImageConversion(imageResult.mimeType));
|
|
15
15
|
}
|
|
16
16
|
return {
|
|
17
|
-
type:
|
|
17
|
+
type: "image",
|
|
18
18
|
dataUrl: `data:${imageResult.mimeType};base64,${imageResult.data}`,
|
|
19
19
|
description: `Image file: ${imageResult.filename} (${Math.round(imageResult.size / 1024)}KB, ${imageResult.mimeType})`,
|
|
20
20
|
mimeType: imageResult.mimeType,
|
|
@@ -22,49 +22,43 @@ async function processMediaFile(context, itemIndex, source, mediaFile, mediaUrl,
|
|
|
22
22
|
}
|
|
23
23
|
catch (error) {
|
|
24
24
|
return {
|
|
25
|
-
type:
|
|
26
|
-
description: `Error processing image file: ${error instanceof Error ? error.message :
|
|
27
|
-
mimeType:
|
|
25
|
+
type: "unknown",
|
|
26
|
+
description: `Error processing image file: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
27
|
+
mimeType: "unknown",
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
function isImageMimeType(mimeType) {
|
|
32
|
-
const supportedFormats = [
|
|
33
|
-
'image/png',
|
|
34
|
-
'image/jpeg',
|
|
35
|
-
'image/jpg',
|
|
36
|
-
'image/gif',
|
|
37
|
-
'image/webp'
|
|
38
|
-
];
|
|
32
|
+
const supportedFormats = ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/webp"];
|
|
39
33
|
return supportedFormats.includes(mimeType.toLowerCase());
|
|
40
34
|
}
|
|
41
35
|
function validateImageFormat(mimeType) {
|
|
42
36
|
if (!isImageMimeType(mimeType)) {
|
|
43
|
-
const supportedFormats = [
|
|
37
|
+
const supportedFormats = ["PNG", "JPEG", "GIF", "WebP"];
|
|
44
38
|
return {
|
|
45
39
|
isValid: false,
|
|
46
|
-
error: `Unsupported image format: ${mimeType}. GitHub Copilot API only supports: ${supportedFormats.join(
|
|
40
|
+
error: `Unsupported image format: ${mimeType}. GitHub Copilot API only supports: ${supportedFormats.join(", ")}`,
|
|
47
41
|
};
|
|
48
42
|
}
|
|
49
43
|
return { isValid: true };
|
|
50
44
|
}
|
|
51
45
|
function getFileExtensionFromMimeType(mimeType) {
|
|
52
46
|
const mimeToExt = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
"image/png": "png",
|
|
48
|
+
"image/jpeg": "jpg",
|
|
49
|
+
"image/jpg": "jpg",
|
|
50
|
+
"image/gif": "gif",
|
|
51
|
+
"image/webp": "webp",
|
|
52
|
+
"image/bmp": "bmp",
|
|
53
|
+
"image/tiff": "tiff",
|
|
54
|
+
"image/svg+xml": "svg",
|
|
61
55
|
};
|
|
62
|
-
return mimeToExt[mimeType.toLowerCase()] ||
|
|
56
|
+
return mimeToExt[mimeType.toLowerCase()] || "unknown";
|
|
63
57
|
}
|
|
64
58
|
function suggestImageConversion(mimeType) {
|
|
65
59
|
const ext = getFileExtensionFromMimeType(mimeType);
|
|
66
|
-
const supportedFormats = [
|
|
67
|
-
return `Image format ${ext.toUpperCase()} is not supported by GitHub Copilot API. ` +
|
|
68
|
-
`Please convert your image to one of these formats: ${supportedFormats.join(
|
|
69
|
-
|
|
60
|
+
const supportedFormats = ["PNG", "JPEG", "GIF", "WebP"];
|
|
61
|
+
return (`Image format ${ext.toUpperCase()} is not supported by GitHub Copilot API. ` +
|
|
62
|
+
`Please convert your image to one of these formats: ${supportedFormats.join(", ")}. ` +
|
|
63
|
+
"Recommended: Convert to PNG or WebP for best compatibility.");
|
|
70
64
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModelCapabilities, ModelValidationResult } from
|
|
1
|
+
import { ModelCapabilities, ModelValidationResult } from "./types";
|
|
2
2
|
export declare const MODEL_CAPABILITIES: Record<string, ModelCapabilities>;
|
|
3
3
|
export declare function validateModelCapabilities(model: string, includeImage: boolean, includeAudio: boolean): ModelValidationResult;
|
|
4
4
|
export declare function getSupportedModels(requireImages?: boolean, requireAudio?: boolean): string[];
|
|
@@ -5,65 +5,65 @@ exports.validateModelCapabilities = validateModelCapabilities;
|
|
|
5
5
|
exports.getSupportedModels = getSupportedModels;
|
|
6
6
|
exports.getModelInfo = getModelInfo;
|
|
7
7
|
exports.MODEL_CAPABILITIES = {
|
|
8
|
-
|
|
8
|
+
"gpt-5": {
|
|
9
9
|
supportsImages: true,
|
|
10
10
|
supportsAudio: false,
|
|
11
11
|
maxContextTokens: 200000,
|
|
12
|
-
description:
|
|
12
|
+
description: "OpenAI GPT-5 with image support via GitHub Copilot API",
|
|
13
13
|
},
|
|
14
|
-
|
|
14
|
+
"gpt-5-mini": {
|
|
15
15
|
supportsImages: true,
|
|
16
16
|
supportsAudio: false,
|
|
17
17
|
maxContextTokens: 128000,
|
|
18
|
-
description:
|
|
18
|
+
description: "OpenAI GPT-5 Mini with image support via GitHub Copilot API",
|
|
19
19
|
},
|
|
20
|
-
|
|
20
|
+
"gpt-4.1-copilot": {
|
|
21
21
|
supportsImages: true,
|
|
22
22
|
supportsAudio: false,
|
|
23
23
|
maxContextTokens: 128000,
|
|
24
|
-
description:
|
|
24
|
+
description: "OpenAI GPT-4.1 with image support via GitHub Copilot API",
|
|
25
25
|
},
|
|
26
|
-
|
|
26
|
+
"claude-opus-4.1": {
|
|
27
27
|
supportsImages: false,
|
|
28
28
|
supportsAudio: false,
|
|
29
29
|
maxContextTokens: 200000,
|
|
30
|
-
description:
|
|
30
|
+
description: "Anthropic Claude Opus 4.1 - Text only via GitHub Copilot API",
|
|
31
31
|
},
|
|
32
|
-
|
|
32
|
+
"claude-3.5-sonnet": {
|
|
33
33
|
supportsImages: false,
|
|
34
34
|
supportsAudio: false,
|
|
35
35
|
maxContextTokens: 200000,
|
|
36
|
-
description:
|
|
36
|
+
description: "Anthropic Claude 3.5 Sonnet - Text only via GitHub Copilot API",
|
|
37
37
|
},
|
|
38
|
-
|
|
38
|
+
"gemini-2.5-pro": {
|
|
39
39
|
supportsImages: true,
|
|
40
40
|
supportsAudio: false,
|
|
41
41
|
maxContextTokens: 1000000,
|
|
42
|
-
description:
|
|
42
|
+
description: "Google Gemini 2.5 Pro with image support via GitHub Copilot API",
|
|
43
43
|
},
|
|
44
|
-
|
|
44
|
+
"gemini-2.0-flash": {
|
|
45
45
|
supportsImages: true,
|
|
46
46
|
supportsAudio: true,
|
|
47
47
|
maxContextTokens: 1000000,
|
|
48
|
-
description:
|
|
48
|
+
description: "Google Gemini 2.0 Flash with multimodal support via GitHub Copilot API",
|
|
49
49
|
},
|
|
50
|
-
|
|
50
|
+
"grok-code-fast-1": {
|
|
51
51
|
supportsImages: false,
|
|
52
52
|
supportsAudio: false,
|
|
53
53
|
maxContextTokens: 128000,
|
|
54
|
-
description:
|
|
54
|
+
description: "xAI Grok Code Fast 1 - Text only via GitHub Copilot API",
|
|
55
55
|
},
|
|
56
|
-
|
|
56
|
+
o3: {
|
|
57
57
|
supportsImages: false,
|
|
58
58
|
supportsAudio: false,
|
|
59
59
|
maxContextTokens: 200000,
|
|
60
|
-
description:
|
|
60
|
+
description: "OpenAI o3 - Text only via GitHub Copilot API",
|
|
61
61
|
},
|
|
62
|
-
|
|
62
|
+
"o3-mini": {
|
|
63
63
|
supportsImages: false,
|
|
64
64
|
supportsAudio: false,
|
|
65
65
|
maxContextTokens: 128000,
|
|
66
|
-
description:
|
|
66
|
+
description: "OpenAI o3-mini - Text only via GitHub Copilot API",
|
|
67
67
|
},
|
|
68
68
|
};
|
|
69
69
|
function validateModelCapabilities(model, includeImage, includeAudio) {
|
|
@@ -85,11 +85,11 @@ function validateModelCapabilities(model, includeImage, includeAudio) {
|
|
|
85
85
|
isValid = false;
|
|
86
86
|
errorMessage = `Model ${model} does not support audio input. Please disable audio upload or choose a different model (e.g., GPT-5, Gemini 2.5 Pro).`;
|
|
87
87
|
}
|
|
88
|
-
if (model.includes(
|
|
89
|
-
warnings.push(
|
|
88
|
+
if (model.includes("claude") && (includeImage || includeAudio)) {
|
|
89
|
+
warnings.push("Claude models typically work best with text-only input via GitHub Copilot API.");
|
|
90
90
|
}
|
|
91
|
-
if (model.includes(
|
|
92
|
-
warnings.push(
|
|
91
|
+
if (model.includes("grok") && (includeImage || includeAudio)) {
|
|
92
|
+
warnings.push("Grok models are optimized for coding tasks and work best with text input.");
|
|
93
93
|
}
|
|
94
94
|
return {
|
|
95
95
|
isValid,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IExecuteFunctions } from
|
|
2
|
-
import { CopilotResponse } from
|
|
1
|
+
import { IExecuteFunctions } from "n8n-workflow";
|
|
2
|
+
import { CopilotResponse } from "../../../shared/utils/GitHubCopilotApiUtils";
|
|
3
3
|
export { CopilotResponse };
|
|
4
4
|
export interface ChatMessage {
|
|
5
|
-
role:
|
|
5
|
+
role: "system" | "user" | "assistant";
|
|
6
6
|
content: string | Array<ChatMessageContent>;
|
|
7
7
|
}
|
|
8
8
|
export interface ChatMessageContent {
|
|
@@ -15,7 +15,7 @@ export interface ChatMessageContent {
|
|
|
15
15
|
export interface FileProcessOptions {
|
|
16
16
|
context: IExecuteFunctions;
|
|
17
17
|
itemIndex: number;
|
|
18
|
-
source:
|
|
18
|
+
source: "manual" | "url" | "binary";
|
|
19
19
|
filePath?: string;
|
|
20
20
|
url?: string;
|
|
21
21
|
binaryProperty?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INodeType, INodeTypeDescription, ISupplyDataFunctions, SupplyData } from
|
|
1
|
+
import { INodeType, INodeTypeDescription, ISupplyDataFunctions, SupplyData } from "n8n-workflow";
|
|
2
2
|
export declare class GitHubCopilotChatModel implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
4
|
supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData>;
|
|
@@ -7,144 +7,144 @@ const GitHubCopilotEndpoints_1 = require("../../shared/utils/GitHubCopilotEndpoi
|
|
|
7
7
|
class GitHubCopilotChatModel {
|
|
8
8
|
constructor() {
|
|
9
9
|
this.description = {
|
|
10
|
-
displayName:
|
|
11
|
-
name:
|
|
12
|
-
icon:
|
|
13
|
-
group: [
|
|
10
|
+
displayName: "GitHub Copilot Chat Model",
|
|
11
|
+
name: "gitHubCopilotChatModel",
|
|
12
|
+
icon: "file:../../shared/icons/copilot.svg",
|
|
13
|
+
group: ["transform"],
|
|
14
14
|
version: 1,
|
|
15
|
-
description:
|
|
15
|
+
description: "GitHub Copilot chat model for AI workflows - access GPT-5, Claude, Gemini and more using your Copilot subscription",
|
|
16
16
|
defaults: {
|
|
17
|
-
name:
|
|
17
|
+
name: "GitHub Copilot Chat Model",
|
|
18
18
|
},
|
|
19
19
|
codex: {
|
|
20
|
-
categories: [
|
|
20
|
+
categories: ["AI"],
|
|
21
21
|
subcategories: {
|
|
22
|
-
AI: [
|
|
23
|
-
|
|
22
|
+
AI: ["Language Models", "Root Nodes"],
|
|
23
|
+
"Language Models": ["Chat Models (Recommended)"],
|
|
24
24
|
},
|
|
25
25
|
resources: {
|
|
26
26
|
primaryDocumentation: [
|
|
27
27
|
{
|
|
28
|
-
url:
|
|
28
|
+
url: "https://docs.github.com/copilot/using-github-copilot/using-github-copilot-chat",
|
|
29
29
|
},
|
|
30
30
|
],
|
|
31
31
|
},
|
|
32
32
|
},
|
|
33
33
|
inputs: [],
|
|
34
34
|
outputs: ["ai_languageModel"],
|
|
35
|
-
outputNames: [
|
|
35
|
+
outputNames: ["Model"],
|
|
36
36
|
credentials: [
|
|
37
37
|
{
|
|
38
|
-
name:
|
|
38
|
+
name: "githubCopilotApi",
|
|
39
39
|
required: true,
|
|
40
40
|
displayOptions: {
|
|
41
41
|
show: {
|
|
42
|
-
credentialType: [
|
|
42
|
+
credentialType: ["githubCopilotApi"],
|
|
43
43
|
},
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
|
-
name:
|
|
47
|
+
name: "githubCopilotOAuth2Api",
|
|
48
48
|
required: true,
|
|
49
49
|
displayOptions: {
|
|
50
50
|
show: {
|
|
51
|
-
credentialType: [
|
|
51
|
+
credentialType: ["githubCopilotOAuth2Api"],
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
54
|
},
|
|
55
55
|
],
|
|
56
56
|
properties: [
|
|
57
57
|
{
|
|
58
|
-
displayName:
|
|
59
|
-
name:
|
|
60
|
-
type:
|
|
58
|
+
displayName: "Credential Type",
|
|
59
|
+
name: "credentialType",
|
|
60
|
+
type: "options",
|
|
61
61
|
options: [
|
|
62
62
|
{
|
|
63
|
-
name:
|
|
64
|
-
value:
|
|
65
|
-
description:
|
|
63
|
+
name: "GitHub Copilot API (Manual Token)",
|
|
64
|
+
value: "githubCopilotApi",
|
|
65
|
+
description: "Use manual GitHub CLI token",
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
|
-
name:
|
|
69
|
-
value:
|
|
70
|
-
description:
|
|
68
|
+
name: "GitHub Copilot OAuth2 (with Helper)",
|
|
69
|
+
value: "githubCopilotOAuth2Api",
|
|
70
|
+
description: "Use OAuth2 credential with helper script",
|
|
71
71
|
},
|
|
72
72
|
],
|
|
73
|
-
default:
|
|
74
|
-
description:
|
|
73
|
+
default: "githubCopilotApi",
|
|
74
|
+
description: "Type of credential to use for GitHub Copilot authentication",
|
|
75
75
|
},
|
|
76
76
|
{
|
|
77
|
-
displayName:
|
|
78
|
-
name:
|
|
79
|
-
type:
|
|
77
|
+
displayName: "Model",
|
|
78
|
+
name: "model",
|
|
79
|
+
type: "options",
|
|
80
80
|
default: GitHubCopilotModels_1.DEFAULT_MODELS.GENERAL,
|
|
81
|
-
description:
|
|
81
|
+
description: "The GitHub Copilot model to use",
|
|
82
82
|
options: GitHubCopilotModels_1.GitHubCopilotModelsManager.toN8nOptions(),
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
|
-
displayName:
|
|
86
|
-
name:
|
|
87
|
-
placeholder:
|
|
88
|
-
description:
|
|
89
|
-
type:
|
|
85
|
+
displayName: "Options",
|
|
86
|
+
name: "options",
|
|
87
|
+
placeholder: "Add Option",
|
|
88
|
+
description: "Additional options for the GitHub Copilot model",
|
|
89
|
+
type: "collection",
|
|
90
90
|
default: {},
|
|
91
91
|
options: [
|
|
92
92
|
{
|
|
93
|
-
displayName:
|
|
94
|
-
name:
|
|
93
|
+
displayName: "Temperature",
|
|
94
|
+
name: "temperature",
|
|
95
95
|
default: 0.7,
|
|
96
96
|
typeOptions: { maxValue: 2, minValue: 0, numberPrecision: 1 },
|
|
97
|
-
description:
|
|
98
|
-
type:
|
|
97
|
+
description: "Controls randomness in output. Lower values make responses more focused.",
|
|
98
|
+
type: "number",
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
|
-
displayName:
|
|
102
|
-
name:
|
|
101
|
+
displayName: "Maximum Number of Tokens",
|
|
102
|
+
name: "maxTokens",
|
|
103
103
|
default: 1000,
|
|
104
|
-
description:
|
|
105
|
-
type:
|
|
104
|
+
description: "The maximum number of tokens to generate",
|
|
105
|
+
type: "number",
|
|
106
106
|
typeOptions: {
|
|
107
107
|
maxValue: 32768,
|
|
108
108
|
},
|
|
109
109
|
},
|
|
110
110
|
{
|
|
111
|
-
displayName:
|
|
112
|
-
name:
|
|
111
|
+
displayName: "Top P",
|
|
112
|
+
name: "topP",
|
|
113
113
|
default: 1,
|
|
114
114
|
typeOptions: { maxValue: 1, minValue: 0, numberPrecision: 2 },
|
|
115
|
-
description:
|
|
116
|
-
type:
|
|
115
|
+
description: "Controls diversity of output by nucleus sampling",
|
|
116
|
+
type: "number",
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
|
-
displayName:
|
|
120
|
-
name:
|
|
121
|
-
type:
|
|
119
|
+
displayName: "Enable Vision",
|
|
120
|
+
name: "enableVision",
|
|
121
|
+
type: "boolean",
|
|
122
122
|
default: true,
|
|
123
|
-
description:
|
|
123
|
+
description: "Whether to enable image processing capabilities",
|
|
124
124
|
},
|
|
125
125
|
{
|
|
126
|
-
displayName:
|
|
127
|
-
name:
|
|
128
|
-
type:
|
|
129
|
-
default:
|
|
130
|
-
description:
|
|
126
|
+
displayName: "System Message",
|
|
127
|
+
name: "systemMessage",
|
|
128
|
+
type: "string",
|
|
129
|
+
default: "",
|
|
130
|
+
description: "System message to set the behavior of the assistant",
|
|
131
131
|
typeOptions: {
|
|
132
132
|
rows: 3,
|
|
133
133
|
},
|
|
134
134
|
},
|
|
135
135
|
{
|
|
136
|
-
displayName:
|
|
137
|
-
name:
|
|
138
|
-
type:
|
|
136
|
+
displayName: "Auto Retry on 403 Error",
|
|
137
|
+
name: "enableRetry",
|
|
138
|
+
type: "boolean",
|
|
139
139
|
default: true,
|
|
140
|
-
description:
|
|
140
|
+
description: "Automatically retry requests when hitting TPM (Transactions Per Minute) quota limits (HTTP 403)",
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
|
-
displayName:
|
|
144
|
-
name:
|
|
145
|
-
type:
|
|
143
|
+
displayName: "Max Retry Attempts",
|
|
144
|
+
name: "maxRetries",
|
|
145
|
+
type: "number",
|
|
146
146
|
default: 3,
|
|
147
|
-
description:
|
|
147
|
+
description: "Maximum number of retry attempts for 403 errors",
|
|
148
148
|
displayOptions: {
|
|
149
149
|
show: {
|
|
150
150
|
enableRetry: [true],
|
|
@@ -158,23 +158,26 @@ class GitHubCopilotChatModel {
|
|
|
158
158
|
}
|
|
159
159
|
async supplyData(itemIndex) {
|
|
160
160
|
var _a;
|
|
161
|
-
const model = this.getNodeParameter(
|
|
162
|
-
const options = this.getNodeParameter(
|
|
161
|
+
const model = this.getNodeParameter("model", itemIndex);
|
|
162
|
+
const options = this.getNodeParameter("options", itemIndex, {});
|
|
163
163
|
const modelInfo = GitHubCopilotModels_1.GitHubCopilotModelsManager.getModelByValue(model);
|
|
164
|
-
const credentialType = this.getNodeParameter(
|
|
165
|
-
const credentials = await this.getCredentials(credentialType);
|
|
164
|
+
const credentialType = this.getNodeParameter("credentialType", 0, "githubCopilotApi");
|
|
165
|
+
const credentials = (await this.getCredentials(credentialType));
|
|
166
166
|
const token = (credentials.accessToken ||
|
|
167
167
|
credentials.access_token ||
|
|
168
168
|
((_a = credentials.oauthTokenData) === null || _a === void 0 ? void 0 : _a.access_token) ||
|
|
169
169
|
credentials.token);
|
|
170
170
|
if (!token) {
|
|
171
|
-
console.error(
|
|
172
|
-
throw new Error(
|
|
171
|
+
console.error("❌ Available OAuth2 credential properties:", Object.keys(credentials));
|
|
172
|
+
throw new Error("GitHub Copilot: No access token found in OAuth2 credentials. Available properties: " +
|
|
173
|
+
Object.keys(credentials).join(", "));
|
|
173
174
|
}
|
|
174
|
-
const tokenPrefix = token.substring(0, Math.min(4, token.indexOf(
|
|
175
|
+
const tokenPrefix = token.substring(0, Math.min(4, token.indexOf("_") + 1)) || token.substring(0, 4);
|
|
175
176
|
const tokenSuffix = token.substring(Math.max(0, token.length - 5));
|
|
176
177
|
console.log(`🔍 GitHub Copilot ChatModel OAuth2 Debug: Using token ${tokenPrefix}...${tokenSuffix}`);
|
|
177
|
-
if (!token.startsWith(
|
|
178
|
+
if (!token.startsWith("gho_") &&
|
|
179
|
+
!token.startsWith("ghu_") &&
|
|
180
|
+
!token.startsWith("github_pat_")) {
|
|
178
181
|
console.warn(`⚠️ Unexpected token format: ${tokenPrefix}...${tokenSuffix}. Trying API call anyway.`);
|
|
179
182
|
}
|
|
180
183
|
const safeModel = modelInfo ? model : GitHubCopilotModels_1.DEFAULT_MODELS.GENERAL;
|
|
@@ -184,22 +187,23 @@ class GitHubCopilotChatModel {
|
|
|
184
187
|
temperature: options.temperature || 0.7,
|
|
185
188
|
maxTokens: Math.min(options.maxTokens || 1000, (safeModelInfo === null || safeModelInfo === void 0 ? void 0 : safeModelInfo.capabilities.maxOutputTokens) || 4096),
|
|
186
189
|
topP: options.topP || 1,
|
|
187
|
-
maxRetries: options.enableRetry !== false ?
|
|
190
|
+
maxRetries: options.enableRetry !== false ? options.maxRetries || 3 : 0,
|
|
188
191
|
configuration: {
|
|
189
192
|
baseURL: GitHubCopilotEndpoints_1.GITHUB_COPILOT_API.BASE_URL,
|
|
190
193
|
apiKey: token,
|
|
191
194
|
defaultHeaders: {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
...(options.enableVision &&
|
|
198
|
-
|
|
199
|
-
|
|
195
|
+
"User-Agent": "GitHubCopilotChat/1.0.0 n8n/3.10.1",
|
|
196
|
+
Accept: "application/json",
|
|
197
|
+
"Editor-Version": "vscode/1.85.0",
|
|
198
|
+
"Editor-Plugin-Version": "copilot-chat/0.12.0",
|
|
199
|
+
"X-Request-Id": `n8n-chatmodel-${Date.now()}-${Math.random().toString(36).substring(7)}`,
|
|
200
|
+
...(options.enableVision &&
|
|
201
|
+
(safeModelInfo === null || safeModelInfo === void 0 ? void 0 : safeModelInfo.capabilities.vision) && {
|
|
202
|
+
"Copilot-Vision-Request": "true",
|
|
203
|
+
"Copilot-Media-Request": "true",
|
|
200
204
|
}),
|
|
201
205
|
},
|
|
202
|
-
}
|
|
206
|
+
},
|
|
203
207
|
};
|
|
204
208
|
const chatModel = new openai_1.ChatOpenAI(modelConfig);
|
|
205
209
|
return {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from "n8n-workflow";
|
|
2
|
+
export declare class GitHubCopilotOpenAI implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|