(config: SerializedContinueConfig)
| 8 | * @returns An array of error messages if there are any. Otherwise, the config is valid. |
| 9 | */ |
| 10 | export function validateConfig(config: SerializedContinueConfig) { |
| 11 | const errors: ConfigValidationError[] = []; |
| 12 | |
| 13 | // Validate chat models |
| 14 | if (!Array.isArray(config.models)) { |
| 15 | errors.push({ |
| 16 | fatal: true, |
| 17 | message: "The 'models' field should be an array.", |
| 18 | }); |
| 19 | } else { |
| 20 | config.models.forEach((model, index) => { |
| 21 | if (typeof model.title !== "string" || model.title.trim() === "") { |
| 22 | errors.push({ |
| 23 | fatal: true, |
| 24 | message: `Model at index ${index} has an invalid or missing 'title'.`, |
| 25 | }); |
| 26 | } |
| 27 | if (typeof model.provider !== "string") { |
| 28 | errors.push({ |
| 29 | fatal: true, |
| 30 | message: `Model at index ${index} has an invalid 'provider'.`, |
| 31 | }); |
| 32 | } |
| 33 | |
| 34 | if (model.contextLength && model.completionOptions?.maxTokens) { |
| 35 | const difference = |
| 36 | model.contextLength - model.completionOptions.maxTokens; |
| 37 | |
| 38 | if (difference < 1000) { |
| 39 | errors.push({ |
| 40 | fatal: false, |
| 41 | message: `Model "${model.title}" has a contextLength of ${model.contextLength} and a maxTokens of ${model.completionOptions.maxTokens}. This leaves only ${difference} tokens for input context and will likely result in your inputs being truncated.`, |
| 42 | }); |
| 43 | } |
| 44 | } |
| 45 | }); |
| 46 | } |
| 47 | |
| 48 | // Validate tab autocomplete model(s) |
| 49 | if (config.tabAutocompleteModel) { |
| 50 | function validateTabAutocompleteModel(modelDescription: ModelDescription) { |
| 51 | const modelName = modelDescription.model.toLowerCase(); |
| 52 | const nonAutocompleteModels = [ |
| 53 | // "gpt", |
| 54 | // "claude", |
| 55 | "mistral", |
| 56 | "instruct", |
| 57 | ]; |
| 58 | |
| 59 | if ( |
| 60 | nonAutocompleteModels.some((m) => modelName.includes(m)) && |
| 61 | !modelName.includes("deepseek") && |
| 62 | !modelName.includes("codestral") && |
| 63 | !modelName.toLowerCase().includes("coder") |
| 64 | ) { |
| 65 | errors.push({ |
| 66 | fatal: false, |
| 67 | message: `${modelDescription.model} is not trained for tab-autocomplete, and will result in low-quality suggestions. See the docs to learn more about why: https://docs.continue.dev/features/tab-autocomplete#i-want-better-completions-should-i-use-gpt-4`, |
no test coverage detected