Skip to content

feat: add support for Github Copilot as a provider #1564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

caezium
Copy link

@caezium caezium commented Jun 21, 2025

You can now authenticate with Github to use Github Copilot as a model provider.

  • Authenticate with one button in the bottom of the Api keys setting
  • Add model with Github Copilot selected as the provider
  • and use

#506

does not support streaming as it already bypasses CORS
does not support auto-getting available models

image image image image (why does typing a with 4.1 give me sometimes this language or chinese)

@logancyang
Copy link
Owner

bugbot run

cursor[bot]

This comment was marked as outdated.

@caezium
Copy link
Author

caezium commented Jun 24, 2025

bugbot run :(

@logancyang logancyang requested a review from Emt-lin June 24, 2025 18:52
@logancyang
Copy link
Owner

bugbot run

cursor[bot]

This comment was marked as outdated.

@caezium
Copy link
Author

caezium commented Jun 25, 2025

should be fixed

@logancyang
Copy link
Owner

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Refactoring Breaks Provider Validation

The createModelInstance method was refactored, introducing a call to the undefined this.getProviderConstructor(model), which causes a runtime error for all non-GitHub Copilot providers. This refactoring also removed critical validation checks for model existence and API key presence, leading to less informative errors or failures when API keys are missing for these providers.

src/LLMProviders/chatModelManager.ts#L363-L378

new Notice(`Failed to set chat model: ${e.message}`);
ChatModelManager.chatModel = null;
}
}
async createModelInstance(model: CustomModel): Promise<BaseChatModel> {
if (model.provider === ChatModelProviders.GITHUB_COPILOT) {
const provider = new GitHubCopilotProvider();
return new CopilotChatModel({ provider, modelName: model.name });
}
const AIConstructor = this.getProviderConstructor(model);
const config = await this.getModelConfig(model);
return new AIConstructor(config);
}

Fix in Cursor


Bug: Constructor Ignores Config, Provider Uninitialized

The ChatGitHubCopilot class's constructor ignores its config parameter, creating an unconfigured GitHubCopilotProvider. This suggests the class is either unused or incorrectly implemented.

src/LLMProviders/githubCopilotChatModel.ts#L84-L108

export class ChatGitHubCopilot {
private provider: GitHubCopilotProvider;
constructor(config: any) {
this.provider = new GitHubCopilotProvider();
}
async send(messages: { role: string; content: string }[], model = "gpt-4") {
return this.provider.sendChatMessage(messages, model);
}
getAuthState() {
return this.provider.getAuthState();
}
async startAuth() {
return this.provider.startDeviceCodeFlow();
}
async pollForAccessToken() {
return this.provider.pollForAccessToken();
}
async fetchCopilotToken() {
return this.provider.fetchCopilotToken();
}
resetAuth() {
this.provider.resetAuth();
}
}

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

@caezium
Copy link
Author

caezium commented Jun 25, 2025

omg mb

@caezium
Copy link
Author

caezium commented Jun 26, 2025

fixed. i tested the other models too. do i have to provide api keys for the integration test that keeps failing?

@Defiect
Copy link

Defiect commented Jul 2, 2025

Can't wait for this to get merged

@Emt-lin
Copy link
Collaborator

Emt-lin commented Jul 2, 2025

sorry, i will review the code later

@caezium
Copy link
Author

caezium commented Jul 2, 2025

ok ty, sorry if my code isn't perfect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants