Remove Gemini provider and fix ContentAssembly array bug
- Remove Gemini configuration from LLMManager (geo-blocked) - Fix elements.forEach error in ContentAssembly.js - Update provider count from 6 to 5 in tests - Add array validation in injectGeneratedContent 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
4f60de68d6
commit
a4dce39343
@ -87,7 +87,13 @@ function injectGeneratedContent(cleanXML, generatedContent, elements) {
|
|||||||
logSh('🔍 === DEBUG INJECTION MAPPING ===', 'DEBUG');
|
logSh('🔍 === DEBUG INJECTION MAPPING ===', 'DEBUG');
|
||||||
logSh(`XML reçu: ${cleanXML.length} caractères`, 'DEBUG');
|
logSh(`XML reçu: ${cleanXML.length} caractères`, 'DEBUG');
|
||||||
logSh(`Contenu généré: ${Object.keys(generatedContent).length} éléments`, 'DEBUG');
|
logSh(`Contenu généré: ${Object.keys(generatedContent).length} éléments`, 'DEBUG');
|
||||||
logSh(`Éléments fournis: ${elements.length} éléments`, 'DEBUG');
|
logSh(`Éléments fournis: ${elements ? elements.length : 'undefined'} éléments`, 'DEBUG');
|
||||||
|
|
||||||
|
// Fix: s'assurer que elements est un array
|
||||||
|
if (!Array.isArray(elements)) {
|
||||||
|
logSh(`⚠ Elements n'est pas un array, type: ${typeof elements}`, 'WARN');
|
||||||
|
elements = [];
|
||||||
|
}
|
||||||
|
|
||||||
// Debug: montrer le XML
|
// Debug: montrer le XML
|
||||||
logSh(`🔍 XML début: ${cleanXML}`, 'DEBUG');
|
logSh(`🔍 XML début: ${cleanXML}`, 'DEBUG');
|
||||||
|
|||||||
@ -25,7 +25,7 @@ const LLM_CONFIG = {
|
|||||||
timeout: 300000, // 5 minutes
|
timeout: 300000, // 5 minutes
|
||||||
retries: 3
|
retries: 3
|
||||||
},
|
},
|
||||||
|
|
||||||
claude: {
|
claude: {
|
||||||
apiKey: process.env.ANTHROPIC_API_KEY,
|
apiKey: process.env.ANTHROPIC_API_KEY,
|
||||||
endpoint: 'https://api.anthropic.com/v1/messages',
|
endpoint: 'https://api.anthropic.com/v1/messages',
|
||||||
@ -40,20 +40,7 @@ const LLM_CONFIG = {
|
|||||||
timeout: 300000, // 5 minutes
|
timeout: 300000, // 5 minutes
|
||||||
retries: 6
|
retries: 6
|
||||||
},
|
},
|
||||||
|
|
||||||
gemini: {
|
|
||||||
apiKey: process.env.GOOGLE_API_KEY,
|
|
||||||
endpoint: 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent',
|
|
||||||
model: 'gemini-2.5-flash',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
temperature: 0.7,
|
|
||||||
maxTokens: 6000,
|
|
||||||
timeout: 300000, // 5 minutes
|
|
||||||
retries: 3
|
|
||||||
},
|
|
||||||
|
|
||||||
deepseek: {
|
deepseek: {
|
||||||
apiKey: process.env.DEEPSEEK_API_KEY,
|
apiKey: process.env.DEEPSEEK_API_KEY,
|
||||||
endpoint: 'https://api.deepseek.com/v1/chat/completions',
|
endpoint: 'https://api.deepseek.com/v1/chat/completions',
|
||||||
@ -106,7 +93,7 @@ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction principale pour appeler n'importe quel LLM
|
* Fonction principale pour appeler n'importe quel LLM
|
||||||
* @param {string} llmProvider - claude|openai|gemini|deepseek|moonshot|mistral
|
* @param {string} llmProvider - claude|openai|deepseek|moonshot|mistral
|
||||||
* @param {string} prompt - Le prompt à envoyer
|
* @param {string} prompt - Le prompt à envoyer
|
||||||
* @param {object} options - Options personnalisées (température, tokens, etc.)
|
* @param {object} options - Options personnalisées (température, tokens, etc.)
|
||||||
* @param {object} personality - Personnalité pour contexte système
|
* @param {object} personality - Personnalité pour contexte système
|
||||||
@ -209,18 +196,6 @@ function buildRequestData(provider, prompt, options, personality) {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'gemini':
|
|
||||||
return {
|
|
||||||
contents: [{
|
|
||||||
parts: [{
|
|
||||||
text: `${systemPrompt}\n\n${prompt}`
|
|
||||||
}]
|
|
||||||
}],
|
|
||||||
generationConfig: {
|
|
||||||
temperature: temperature,
|
|
||||||
maxOutputTokens: maxTokens
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Format de requête non supporté pour ${provider}`);
|
throw new Error(`Format de requête non supporté pour ${provider}`);
|
||||||
@ -242,11 +217,8 @@ async function callWithRetry(provider, requestData, config) {
|
|||||||
headers[key] = config.headers[key].replace('{API_KEY}', config.apiKey);
|
headers[key] = config.headers[key].replace('{API_KEY}', config.apiKey);
|
||||||
});
|
});
|
||||||
|
|
||||||
// URL avec clé API pour Gemini (cas spécial)
|
// URL standard
|
||||||
let url = config.endpoint;
|
let url = config.endpoint;
|
||||||
if (provider === 'gemini') {
|
|
||||||
url += `?key=${config.apiKey}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -299,21 +271,6 @@ function parseResponse(provider, responseData) {
|
|||||||
case 'claude':
|
case 'claude':
|
||||||
return responseData.content[0].text.trim();
|
return responseData.content[0].text.trim();
|
||||||
|
|
||||||
case 'gemini':
|
|
||||||
const candidate = responseData.candidates[0];
|
|
||||||
|
|
||||||
// Vérifications multiples pour Gemini 2.5
|
|
||||||
if (candidate && candidate.content && candidate.content.parts && candidate.content.parts[0] && candidate.content.parts[0].text) {
|
|
||||||
return candidate.content.parts[0].text.trim();
|
|
||||||
} else if (candidate && candidate.text) {
|
|
||||||
return candidate.text.trim();
|
|
||||||
} else if (candidate && candidate.content && candidate.content.text) {
|
|
||||||
return candidate.content.text.trim();
|
|
||||||
} else {
|
|
||||||
// Debug : logger la structure complète
|
|
||||||
logSh('Gemini structure complète: ' + JSON.stringify(responseData), 'DEBUG');
|
|
||||||
return '[Gemini: pas de texte généré - problème modèle]';
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Parser non supporté pour ${provider}`);
|
throw new Error(`Parser non supporté pour ${provider}`);
|
||||||
}
|
}
|
||||||
@ -439,7 +396,7 @@ async function testLLMManager() {
|
|||||||
|
|
||||||
// Test des providers disponibles
|
// Test des providers disponibles
|
||||||
const available = getAvailableProviders();
|
const available = getAvailableProviders();
|
||||||
logSh('Providers disponibles: ' + available.join(', ') + ' (' + available.length + '/6)', 'INFO');
|
logSh('Providers disponibles: ' + available.join(', ') + ' (' + available.length + '/5)', 'INFO');
|
||||||
|
|
||||||
// Test d'appel simple sur chaque provider disponible
|
// Test d'appel simple sur chaque provider disponible
|
||||||
for (const provider of available) {
|
for (const provider of available) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user