-
Notifications
You must be signed in to change notification settings - Fork 836
Add provider-level management for custom models to simplify setup #877
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
base: master
Are you sure you want to change the base?
Conversation
@PeterDaveHello 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: PeterDaveHello <3691490+PeterDaveHello@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a provider-level management system for OpenAI-compatible custom models, allowing users to configure multiple models under a single provider with shared API keys and base URLs. This simplifies setup for users who want to manage multiple models from the same provider (e.g., OpenRouter, LocalAI).
- New CustomProviders component with full CRUD operations for provider and model management
- Enhanced API service to support both provider-based and legacy custom model configurations
- Automatic migration from legacy custom model setups to the new provider system
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
src/utils/model-name-convert.mjs | Extends API mode generation to include provider models with proper metadata |
src/services/init-session.mjs | Adds provider-related session parameters for model identification |
src/services/apis/custom-api.mjs | Implements new provider-based API generation with legacy fallback |
src/popup/sections/GeneralPart.jsx | Updates dependencies to trigger re-renders when custom providers change |
src/popup/sections/CustomProviders.jsx | New comprehensive UI component for provider and model management |
src/popup/Popup.jsx | Integrates new Custom Providers tab into the popup interface |
src/config/index.mjs | Adds provider configuration schema, helper functions, and automatic migration |
src/background/index.mjs | Updates API execution logic to handle provider-based model selection |
src/_locales/en/main.json | Adds localization strings for the new provider management interface |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
{ | ||
id: '', | ||
name: '', | ||
baseUrl: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default configuration contains empty strings for required fields like id
, name
, and baseUrl
. This could lead to issues when the default is accidentally used. Consider using more descriptive placeholder values or null values that would fail fast if used incorrectly.
baseUrl: '', | |
id: null, | |
name: null, | |
baseUrl: null, |
Copilot uses AI. Check for mistakes.
}, [config.customProviders]) | ||
|
||
const generateProviderId = (name) => { | ||
return name.toLowerCase().replace(/[^a-z0-9]/g, '_') + '_' + Date.now() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ID generation function could create duplicate IDs if two providers with the same name are created within the same millisecond. Consider using a more robust ID generation method like crypto.randomUUID() or including additional entropy.
return name.toLowerCase().replace(/[^a-z0-9]/g, '_') + '_' + Date.now() | |
const generateProviderId = () => { | |
return crypto.randomUUID() |
Copilot uses AI. Check for mistakes.
}, [config.customProviders]) | ||
|
||
const generateProviderId = (name) => { | ||
return name.toLowerCase().replace(/[^a-z0-9]/g, '_') + '_' + Date.now() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The regex pattern [^a-z0-9]
will replace valid characters like hyphens with underscores, potentially making IDs less readable. Consider a more permissive pattern like [^a-z0-9_-]
to preserve common ID-friendly characters.
return name.toLowerCase().replace(/[^a-z0-9]/g, '_') + '_' + Date.now() | |
return name.toLowerCase().replace(/[^a-z0-9_-]/g, '_') + '_' + Date.now() |
Copilot uses AI. Check for mistakes.
|
||
// Create a provider from the legacy configuration | ||
const legacyProvider = { | ||
id: 'legacy_custom_' + Date.now(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migration function uses Date.now() for ID generation, which could create duplicate IDs if migration runs multiple times in quick succession. Consider using a more robust ID generation or checking for existing IDs.
Copilot uses AI. Check for mistakes.
This PR introduces provider-level management for OpenAI-compatible custom models, allowing users to configure multiple models under a single provider with shared API keys and base URLs.
Problem
Previously, each custom model required individual configuration of API key, URL, and model name, making it cumbersome to set up multiple models from the same provider (e.g., multiple models from OpenRouter or a local AI server).
Solution
Added a new Custom Providers system that allows users to:
Key Features
Provider Management UI
Example Configuration
Technical Implementation
customProviders
arrayBackward Compatibility
customApiKey
/customModelApiUrl
configurations continue to workBenefits
This addresses the core issue of configuration duplication while providing a scalable foundation for managing multiple custom model providers.
Fixes #874.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.