mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-02 22:17:14 +00:00
feat(ui): add provider preset categories with helper function
- Add PresetCategory type (recommended/alternative) - Categorize OpenRouter as recommended, GLM/GLMT/Kimi as alternative - Add getPresetsByCategory() helper for filtering - Change GLM badge from 'Free' to 'Z.AI' for clarity
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
* Pre-configured templates for common API providers
|
* Pre-configured templates for common API providers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
export type PresetCategory = 'recommended' | 'alternative';
|
||||||
|
|
||||||
export interface ProviderPreset {
|
export interface ProviderPreset {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -16,11 +18,13 @@ export interface ProviderPreset {
|
|||||||
requiresApiKey: boolean;
|
requiresApiKey: boolean;
|
||||||
apiKeyPlaceholder: string;
|
apiKeyPlaceholder: string;
|
||||||
apiKeyHint?: string;
|
apiKeyHint?: string;
|
||||||
|
category: PresetCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const OPENROUTER_BASE_URL = 'https://openrouter.ai/api/v1';
|
export const OPENROUTER_BASE_URL = 'https://openrouter.ai/api/v1';
|
||||||
|
|
||||||
export const PROVIDER_PRESETS: ProviderPreset[] = [
|
export const PROVIDER_PRESETS: ProviderPreset[] = [
|
||||||
|
// Recommended - OpenRouter
|
||||||
{
|
{
|
||||||
id: 'openrouter',
|
id: 'openrouter',
|
||||||
name: 'OpenRouter',
|
name: 'OpenRouter',
|
||||||
@@ -34,18 +38,21 @@ export const PROVIDER_PRESETS: ProviderPreset[] = [
|
|||||||
requiresApiKey: true,
|
requiresApiKey: true,
|
||||||
apiKeyPlaceholder: 'sk-or-...',
|
apiKeyPlaceholder: 'sk-or-...',
|
||||||
apiKeyHint: 'Get your API key at openrouter.ai/keys',
|
apiKeyHint: 'Get your API key at openrouter.ai/keys',
|
||||||
|
category: 'recommended',
|
||||||
},
|
},
|
||||||
|
// Alternative providers - GLM/GLMT/Kimi
|
||||||
{
|
{
|
||||||
id: 'glm',
|
id: 'glm',
|
||||||
name: 'GLM',
|
name: 'GLM',
|
||||||
description: 'Claude via Z.AI (GitHub Copilot)',
|
description: 'Claude via Z.AI (GitHub Copilot)',
|
||||||
baseUrl: 'https://api.z.ai/api/anthropic',
|
baseUrl: 'https://api.z.ai/api/anthropic',
|
||||||
defaultProfileName: 'glm',
|
defaultProfileName: 'glm',
|
||||||
badge: 'Free',
|
badge: 'Z.AI',
|
||||||
defaultModel: 'glm-4.6',
|
defaultModel: 'glm-4.6',
|
||||||
requiresApiKey: true,
|
requiresApiKey: true,
|
||||||
apiKeyPlaceholder: 'ghp_...',
|
apiKeyPlaceholder: 'ghp_...',
|
||||||
apiKeyHint: 'Get your API key from Z.AI',
|
apiKeyHint: 'Get your API key from Z.AI',
|
||||||
|
category: 'alternative',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'glmt',
|
id: 'glmt',
|
||||||
@@ -58,6 +65,7 @@ export const PROVIDER_PRESETS: ProviderPreset[] = [
|
|||||||
requiresApiKey: true,
|
requiresApiKey: true,
|
||||||
apiKeyPlaceholder: 'ghp_...',
|
apiKeyPlaceholder: 'ghp_...',
|
||||||
apiKeyHint: 'Same API key as GLM',
|
apiKeyHint: 'Same API key as GLM',
|
||||||
|
category: 'alternative',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'kimi',
|
id: 'kimi',
|
||||||
@@ -70,9 +78,15 @@ export const PROVIDER_PRESETS: ProviderPreset[] = [
|
|||||||
requiresApiKey: true,
|
requiresApiKey: true,
|
||||||
apiKeyPlaceholder: 'sk-...',
|
apiKeyPlaceholder: 'sk-...',
|
||||||
apiKeyHint: 'Get your API key from Moonshot AI',
|
apiKeyHint: 'Get your API key from Moonshot AI',
|
||||||
|
category: 'alternative',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/** Get presets by category */
|
||||||
|
export function getPresetsByCategory(category: PresetCategory): ProviderPreset[] {
|
||||||
|
return PROVIDER_PRESETS.filter((p) => p.category === category);
|
||||||
|
}
|
||||||
|
|
||||||
/** Get preset by ID */
|
/** Get preset by ID */
|
||||||
export function getPresetById(id: string): ProviderPreset | undefined {
|
export function getPresetById(id: string): ProviderPreset | undefined {
|
||||||
return PROVIDER_PRESETS.find((p) => p.id === id);
|
return PROVIDER_PRESETS.find((p) => p.id === id);
|
||||||
|
|||||||
Reference in New Issue
Block a user