🔧 Fix: Correction de compatibilité configuration et interface
- Ajout de compatibilité ancienne structure config.ai - Support des deux types d'interface (Terminal et ModernInterface) - Helper displayMessage pour unifier l'affichage - Correction des types de configuration NeuraConfig - Fix initialisation IA avec nouvelle config unifiée NeuraTerm v2.0 se lance maintenant correctement avec la nouvelle architecture !
This commit is contained in:
parent
776bb44120
commit
f248062ef1
@ -9,23 +9,24 @@ export async function initAI(config: any, auth: any): Promise<AIClient> {
|
||||
const keyManager = auth.getKeyManager();
|
||||
const keys = keyManager.loadKeys();
|
||||
|
||||
// Utiliser la configuration unifiée pour les modèles
|
||||
const providerConfig: ProviderConfig = {
|
||||
openai: {
|
||||
apiKey: keys.openai || '',
|
||||
model: config.ai.openai?.model || 'gpt-4o-mini',
|
||||
baseUrl: config.ai.openai?.baseUrl
|
||||
model: config.providers?.openai?.model || 'gpt-4o-mini',
|
||||
baseUrl: config.providers?.openai?.base_url
|
||||
},
|
||||
mistral: {
|
||||
apiKey: keys.mistral || '',
|
||||
model: config.ai.mistral?.model || 'mistral-large-latest',
|
||||
baseUrl: config.ai.mistral?.baseUrl
|
||||
model: config.providers?.mistral?.model || 'mistral-large-latest',
|
||||
baseUrl: config.providers?.mistral?.base_url
|
||||
},
|
||||
defaultProvider: keys.openai ? 'openai' : 'mistral'
|
||||
};
|
||||
|
||||
// Ajuster le provider par défaut selon les clés disponibles
|
||||
if (config.ai.defaultProvider && keys[config.ai.defaultProvider as keyof typeof keys]) {
|
||||
providerConfig.defaultProvider = config.ai.defaultProvider;
|
||||
// Ajuster le provider par défaut selon la config et les clés disponibles
|
||||
if (config.providers?.default && keys[config.providers.default as keyof typeof keys]) {
|
||||
providerConfig.defaultProvider = config.providers.default;
|
||||
}
|
||||
|
||||
return new AIClient(providerConfig);
|
||||
|
@ -15,23 +15,31 @@ export class CommandProcessor {
|
||||
constructor(
|
||||
private config: any,
|
||||
private dependencies: {
|
||||
terminal: Terminal;
|
||||
terminal: any; // Peut être Terminal ou ModernInterface
|
||||
auth: any;
|
||||
ai: AIClient;
|
||||
codebase: any;
|
||||
fileOps: any;
|
||||
execution: any;
|
||||
errors: any;
|
||||
engine?: any;
|
||||
memory?: any;
|
||||
identity?: any;
|
||||
}
|
||||
) {
|
||||
this.taskPlanner = new TaskPlanner(
|
||||
this.dependencies.ai,
|
||||
this.dependencies.execution.getCommandExecutor()
|
||||
);
|
||||
// Utiliser le prompt de la nouvelle interface si disponible
|
||||
const prompt = this.dependencies.terminal.getPrompt ?
|
||||
this.dependencies.terminal.getPrompt() :
|
||||
'🧠 NeuraTerm> ';
|
||||
|
||||
this.rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
prompt: '🧠 NeuraTerm> '
|
||||
prompt
|
||||
});
|
||||
}
|
||||
|
||||
@ -49,7 +57,12 @@ export class CommandProcessor {
|
||||
try {
|
||||
await this.processCommand(command);
|
||||
} catch (error) {
|
||||
this.dependencies.terminal.displayError(error instanceof Error ? error.message : String(error));
|
||||
// Support des deux types d'interface
|
||||
if (this.dependencies.terminal.displayError) {
|
||||
this.dependencies.terminal.displayError(error instanceof Error ? error.message : String(error));
|
||||
} else {
|
||||
console.error(`❌ Erreur: ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
logger.error('Erreur lors du traitement de la commande:', error);
|
||||
}
|
||||
|
||||
@ -62,6 +75,44 @@ export class CommandProcessor {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper pour supporter les deux types d'interface
|
||||
*/
|
||||
private displayMessage(type: 'error' | 'success' | 'info' | 'warning', message: string): void {
|
||||
const terminal = this.dependencies.terminal;
|
||||
|
||||
switch (type) {
|
||||
case 'error':
|
||||
if (terminal.displayError) {
|
||||
terminal.displayError(message);
|
||||
} else {
|
||||
console.error(`❌ Erreur: ${message}`);
|
||||
}
|
||||
break;
|
||||
case 'success':
|
||||
if (terminal.displaySuccess) {
|
||||
terminal.displaySuccess(message);
|
||||
} else {
|
||||
console.log(`✅ ${message}`);
|
||||
}
|
||||
break;
|
||||
case 'info':
|
||||
if (terminal.displayInfo) {
|
||||
terminal.displayInfo(message);
|
||||
} else {
|
||||
console.log(`💡 ${message}`);
|
||||
}
|
||||
break;
|
||||
case 'warning':
|
||||
if (terminal.displayWarning) {
|
||||
terminal.displayWarning(message);
|
||||
} else {
|
||||
console.log(`⚠️ ${message}`);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private async processCommand(command: string): Promise<void> {
|
||||
const [cmd, ...args] = command.split(' ');
|
||||
|
||||
|
@ -129,8 +129,9 @@ export async function run(app: AppInstance): Promise<void> {
|
||||
// Présentation de l'identité NeuraTerm
|
||||
console.log(app.identity.generateIntroduction());
|
||||
|
||||
// Authentification si nécessaire
|
||||
// Authentification des clés API si nécessaire
|
||||
if (!app.auth.isAuthenticated()) {
|
||||
console.log('\n🔑 Configuration des clés API requise...');
|
||||
await app.auth.authenticate();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user