All files / src/constants models.ts

87.09% Statements 54/62
100% Branches 0/0
0% Functions 0/2
87.09% Lines 54/62

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113                          1x         1x         1x         1x         1x         1x       1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                 1x                         1x      
/**
 * Model Default Constants - Single Source of Truth
 *
 * All model-related defaults should reference this file.
 * Backend (Rust) should use the same values in kernel_commands.rs
 */
 
// === Default Model Configuration ===
 
/**
 * Default model ID when user hasn't configured one
 * Using gpt-4o-mini as it's cost-effective and capable
 */
export const DEFAULT_MODEL_ID = 'gpt-4o-mini' as const;
 
/**
 * Default provider when user hasn't configured one
 */
export const DEFAULT_PROVIDER = 'openai' as const;
 
/**
 * Default max tokens for responses
 */
export const DEFAULT_MAX_TOKENS = 4096 as const;
 
/**
 * Default temperature for responses
 */
export const DEFAULT_TEMPERATURE = 0.7 as const;
 
/**
 * Default base URL for OpenAI API
 */
export const DEFAULT_OPENAI_BASE_URL = 'https://api.openai.com/v1' as const;
 
/**
 * Default base URL for Anthropic API
 */
export const DEFAULT_ANTHROPIC_BASE_URL = 'https://api.anthropic.com' as const;
 
// === Provider-Specific Defaults ===
 
export const PROVIDER_DEFAULTS = {
  openai: {
    baseUrl: 'https://api.openai.com/v1',
    defaultModel: 'gpt-4o-mini',
  },
  anthropic: {
    baseUrl: 'https://api.anthropic.com',
    defaultModel: 'claude-sonnet-4-20250514',
  },
  zhipu: {
    baseUrl: 'https://open.bigmodel.cn/api/paas/v4',
    defaultModel: 'glm-4-flash',
  },
  zhipu_coding: {
    baseUrl: 'https://open.bigmodel.cn/api/coding/paas/v4',
    defaultModel: 'glm-4-flash',
  },
  kimi: {
    baseUrl: 'https://api.moonshot.cn/v1',
    defaultModel: 'moonshot-v1-8k',
  },
  kimi_coding: {
    baseUrl: 'https://api.kimi.com/coding/v1',
    defaultModel: 'kimi-for-coding',
  },
  qwen: {
    baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
    defaultModel: 'qwen-turbo',
  },
  qwen_coding: {
    baseUrl: 'https://coding.dashscope.aliyuncs.com/v1',
    defaultModel: 'qwen3-coder-next',
  },
  deepseek: {
    baseUrl: 'https://api.deepseek.com/v1',
    defaultModel: 'deepseek-chat',
  },
  gemini: {
    baseUrl: 'https://generativelanguage.googleapis.com/v1beta',
    defaultModel: 'gemini-2.0-flash',
  },
  local: {
    baseUrl: 'http://localhost:11434/v1',
    defaultModel: 'llama3',
  },
} as const;
 
export type ProviderType = keyof typeof PROVIDER_DEFAULTS;
 
// === Helper Functions ===
 
/**
 * Get provider default configuration
 */
export function getProviderDefaults(provider: string): {
  baseUrl: string;
  defaultModel: string;
} {
  return PROVIDER_DEFAULTS[provider as ProviderType] || {
    baseUrl: DEFAULT_OPENAI_BASE_URL,
    defaultModel: DEFAULT_MODEL_ID,
  };
}
 
/**
 * Check if a provider is a coding plan provider
 */
export function isCodingProvider(provider: string): boolean {
  return provider.endsWith('-coding') || provider === 'zhipu-coding';
}