| 1 | import { ConfigYaml } from "@continuedev/config-yaml"; |
| 2 | |
| 3 | export const LOCAL_ONBOARDING_PROVIDER_TITLE = "Ollama"; |
| 4 | export const LOCAL_ONBOARDING_FIM_MODEL = "qwen2.5-coder:1.5b-base"; |
| 5 | export const LOCAL_ONBOARDING_FIM_TITLE = "Qwen2.5-Coder 1.5B"; |
| 6 | export const LOCAL_ONBOARDING_CHAT_MODEL = "llama3.1:8b"; |
| 7 | export const LOCAL_ONBOARDING_CHAT_TITLE = "Llama 3.1 8B"; |
| 8 | export const LOCAL_ONBOARDING_EMBEDDINGS_MODEL = "nomic-embed-text:latest"; |
| 9 | export const LOCAL_ONBOARDING_EMBEDDINGS_TITLE = "Nomic Embed"; |
| 10 | |
| 11 | const ANTHROPIC_MODEL_CONFIG = { |
| 12 | slugs: ["anthropic/claude-3-7-sonnet", "anthropic/claude-4-sonnet"], |
| 13 | apiKeyInputName: "ANTHROPIC_API_KEY", |
| 14 | }; |
| 15 | const OPENAI_MODEL_CONFIG = { |
| 16 | slugs: ["openai/gpt-4.1", "openai/o3", "openai/gpt-4.1-mini"], |
| 17 | apiKeyInputName: "OPENAI_API_KEY", |
| 18 | }; |
| 19 | |
| 20 | // TODO: These need updating on the hub |
| 21 | const GEMINI_MODEL_CONFIG = { |
| 22 | slugs: ["google/gemini-2.5-pro", "google/gemini-2.0-flash"], |
| 23 | apiKeyInputName: "GEMINI_API_KEY", |
| 24 | }; |
| 25 | |
| 26 | /** |
| 27 | * We set the "best" chat + autocopmlete models by default |
| 28 | * whenever a user doesn't have a config.json |
| 29 | */ |
| 30 | export function setupBestConfig(config: ConfigYaml): ConfigYaml { |
| 31 | return { |
| 32 | ...config, |
| 33 | models: config.models, |
| 34 | }; |
| 35 | } |
| 36 | |
| 37 | export function setupLocalConfig(config: ConfigYaml): ConfigYaml { |
| 38 | return { |
| 39 | ...config, |
| 40 | models: [ |
| 41 | { |
| 42 | name: LOCAL_ONBOARDING_CHAT_TITLE, |
| 43 | provider: "ollama", |
| 44 | model: LOCAL_ONBOARDING_CHAT_MODEL, |
| 45 | roles: ["chat", "edit", "apply"], |
| 46 | }, |
| 47 | { |
| 48 | name: LOCAL_ONBOARDING_FIM_TITLE, |
| 49 | provider: "ollama", |
| 50 | model: LOCAL_ONBOARDING_FIM_MODEL, |
| 51 | roles: ["autocomplete"], |
| 52 | }, |
| 53 | { |
| 54 | name: LOCAL_ONBOARDING_EMBEDDINGS_TITLE, |
| 55 | provider: "ollama", |
| 56 | model: LOCAL_ONBOARDING_EMBEDDINGS_MODEL, |
| 57 | roles: ["embed"], |
| 58 | }, |
| 59 | ...(config.models ?? []), |
| 60 | ], |
| 61 | }; |
| 62 | } |
| 63 | |
| 64 | export function setupQuickstartConfig(config: ConfigYaml): ConfigYaml { |
| 65 | return config; |
| 66 | } |
| 67 | |
| 68 | export function setupProviderConfig( |
| 69 | config: ConfigYaml, |
| 70 | provider: string, |
| 71 | apiKey: string, |
| 72 | ): ConfigYaml { |
| 73 | let newModels; |
| 74 | |
| 75 | switch (provider) { |
| 76 | case "openai": |
| 77 | newModels = OPENAI_MODEL_CONFIG.slugs.map((slug) => ({ |
| 78 | uses: slug, |
| 79 | with: { |
| 80 | [OPENAI_MODEL_CONFIG.apiKeyInputName]: apiKey, |
| 81 | }, |
| 82 | })); |
| 83 | break; |
| 84 | case "anthropic": |
| 85 | newModels = ANTHROPIC_MODEL_CONFIG.slugs.map((slug) => ({ |
| 86 | uses: slug, |
| 87 | with: { |
| 88 | [ANTHROPIC_MODEL_CONFIG.apiKeyInputName]: apiKey, |
| 89 | }, |
| 90 | })); |
| 91 | break; |
| 92 | case "gemini": |
| 93 | newModels = GEMINI_MODEL_CONFIG.slugs.map((slug) => ({ |
| 94 | uses: slug, |
| 95 | with: { |
| 96 | [GEMINI_MODEL_CONFIG.apiKeyInputName]: apiKey, |
| 97 | }, |
| 98 | })); |
| 99 | break; |
| 100 | default: |
| 101 | throw new Error(`Unknown provider: ${provider}`); |
| 102 | } |
| 103 | |
| 104 | return { |
| 105 | ...config, |
| 106 | models: [...(config.models ?? []), ...newModels], |
| 107 | }; |
| 108 | } |