mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-03 04:17:54 +00:00
feat(copilot): add model tier mapping support
- add opus_model, sonnet_model, haiku_model to CopilotConfig - update generateCopilotEnv to use tier-specific models - fall back to default model when tier not configured
This commit is contained in:
@@ -175,8 +175,12 @@ export interface CopilotConfig {
|
|||||||
rate_limit: number | null;
|
rate_limit: number | null;
|
||||||
/** Wait instead of error when rate limit is hit (default: true) */
|
/** Wait instead of error when rate limit is hit (default: true) */
|
||||||
wait_on_limit: boolean;
|
wait_on_limit: boolean;
|
||||||
/** Selected model (default: claude-opus-4-5-20250514) */
|
/** Default model ID (e.g., claude-opus-4-5-20250514) */
|
||||||
model: string;
|
model: string;
|
||||||
|
/** Model mapping for Claude tiers - maps opus/sonnet/haiku to specific models */
|
||||||
|
opus_model?: string;
|
||||||
|
sonnet_model?: string;
|
||||||
|
haiku_model?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,15 +31,23 @@ export async function getCopilotStatus(config: CopilotConfig): Promise<CopilotSt
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate environment variables for Claude Code to use copilot-api.
|
* Generate environment variables for Claude Code to use copilot-api.
|
||||||
|
* Uses model mapping for opus/sonnet/haiku tiers if configured.
|
||||||
*/
|
*/
|
||||||
export function generateCopilotEnv(config: CopilotConfig): Record<string, string> {
|
export function generateCopilotEnv(config: CopilotConfig): Record<string, string> {
|
||||||
|
// Use mapped models if configured, otherwise fall back to default model
|
||||||
|
const opusModel = config.opus_model || config.model;
|
||||||
|
const sonnetModel = config.sonnet_model || config.model;
|
||||||
|
const haikuModel = config.haiku_model || config.model;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ANTHROPIC_BASE_URL: `http://localhost:${config.port}`,
|
ANTHROPIC_BASE_URL: `http://localhost:${config.port}`,
|
||||||
ANTHROPIC_AUTH_TOKEN: 'dummy', // copilot-api handles auth internally
|
ANTHROPIC_AUTH_TOKEN: 'dummy', // copilot-api handles auth internally
|
||||||
ANTHROPIC_MODEL: config.model,
|
ANTHROPIC_MODEL: config.model,
|
||||||
ANTHROPIC_DEFAULT_SONNET_MODEL: config.model,
|
// Model tier mapping - allows different models for opus/sonnet/haiku
|
||||||
ANTHROPIC_SMALL_FAST_MODEL: config.model,
|
ANTHROPIC_DEFAULT_OPUS_MODEL: opusModel,
|
||||||
ANTHROPIC_DEFAULT_HAIKU_MODEL: config.model,
|
ANTHROPIC_DEFAULT_SONNET_MODEL: sonnetModel,
|
||||||
|
ANTHROPIC_SMALL_FAST_MODEL: haikuModel,
|
||||||
|
ANTHROPIC_DEFAULT_HAIKU_MODEL: haikuModel,
|
||||||
// Disable non-essential traffic to avoid rate limiting
|
// Disable non-essential traffic to avoid rate limiting
|
||||||
DISABLE_NON_ESSENTIAL_MODEL_CALLS: '1',
|
DISABLE_NON_ESSENTIAL_MODEL_CALLS: '1',
|
||||||
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1',
|
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1',
|
||||||
|
|||||||
Reference in New Issue
Block a user