( error: Error, provider: string, currentModel: string )
| 45 | }; |
| 46 | |
| 47 | async function handleModelNotFoundError( |
| 48 | error: Error, |
| 49 | provider: string, |
| 50 | currentModel: string |
| 51 | ): Promise<string | null> { |
| 52 | console.log(chalk.red(`\n✖ Model '${currentModel}' not found\n`)); |
| 53 | |
| 54 | const suggestedModels = getSuggestedModels(provider, currentModel); |
| 55 | const recommended = |
| 56 | RECOMMENDED_MODELS[provider as keyof typeof RECOMMENDED_MODELS]; |
| 57 | |
| 58 | if (suggestedModels.length === 0) { |
| 59 | console.log( |
| 60 | chalk.yellow( |
| 61 | `No alternative models available. Run 'oco setup' to configure a different model.` |
| 62 | ) |
| 63 | ); |
| 64 | return null; |
| 65 | } |
| 66 | |
| 67 | const options: Array<{ value: string; label: string }> = []; |
| 68 | |
| 69 | // Add recommended first if available |
| 70 | if (recommended && suggestedModels.includes(recommended)) { |
| 71 | options.push({ |
| 72 | value: recommended, |
| 73 | label: `${recommended} (Recommended)` |
| 74 | }); |
| 75 | } |
| 76 | |
| 77 | // Add other suggestions |
| 78 | suggestedModels |
| 79 | .filter((m) => m !== recommended) |
| 80 | .forEach((model) => { |
| 81 | options.push({ value: model, label: model }); |
| 82 | }); |
| 83 | |
| 84 | options.push({ value: '__custom__', label: 'Enter custom model...' }); |
| 85 | |
| 86 | const selection = await select({ |
| 87 | message: 'Select an alternative model:', |
| 88 | options |
| 89 | }); |
| 90 | |
| 91 | if (isCancel(selection)) { |
| 92 | return null; |
| 93 | } |
| 94 | |
| 95 | let newModel: string; |
| 96 | if (selection === '__custom__') { |
| 97 | const { text } = await import('@clack/prompts'); |
| 98 | const customModel = await text({ |
| 99 | message: 'Enter model name:', |
| 100 | validate: (value) => { |
| 101 | if (!value || value.trim().length === 0) { |
| 102 | return 'Model name is required'; |
| 103 | } |
| 104 | return undefined; |
no test coverage detected
searching dependent graphs…