mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-04-20 03:02:51 -04:00
feat: add interactive setup wizard and model error handling
Add comprehensive setup command with provider selection, API key configuration, and model selection. Include error recovery for model-not-found scenarios with suggested alternatives and automatic retry functionality. Update Anthropic model list with latest versions and add provider metadata for better user experience.
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
} from '@google/generative-ai';
|
||||
import axios from 'axios';
|
||||
import { OpenAI } from 'openai';
|
||||
import { ModelNotFoundError } from '../utils/errors';
|
||||
import { removeContentTags } from '../utils/removeContentTags';
|
||||
import { AiEngine, AiEngineConfig } from './Engine';
|
||||
|
||||
@@ -76,6 +77,15 @@ export class GeminiEngine implements AiEngine {
|
||||
return removeContentTags(content, 'think');
|
||||
} catch (error) {
|
||||
const err = error as Error;
|
||||
|
||||
// Check for model not found errors
|
||||
if (err.message?.toLowerCase().includes('model') &&
|
||||
(err.message?.toLowerCase().includes('not found') ||
|
||||
err.message?.toLowerCase().includes('does not exist') ||
|
||||
err.message?.toLowerCase().includes('invalid'))) {
|
||||
throw new ModelNotFoundError(this.config.model, 'gemini', 404);
|
||||
}
|
||||
|
||||
if (
|
||||
axios.isAxiosError<{ error?: { message: string } }>(error) &&
|
||||
error.response?.status === 401
|
||||
@@ -84,6 +94,11 @@ export class GeminiEngine implements AiEngine {
|
||||
if (geminiError) throw new Error(geminiError?.message);
|
||||
}
|
||||
|
||||
// Check axios 404 errors
|
||||
if (axios.isAxiosError(error) && error.response?.status === 404) {
|
||||
throw new ModelNotFoundError(this.config.model, 'gemini', 404);
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user