-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-all-models.js
More file actions
125 lines (108 loc) · 3.98 KB
/
test-all-models.js
File metadata and controls
125 lines (108 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Test más exhaustivo con todas las combinaciones posibles
import { readFileSync } from 'fs';
const envContent = readFileSync('.env', 'utf-8');
const envLines = envContent.split('\n');
const envVars = {};
envLines.forEach(line => {
const [key, value] = line.split('=');
if (key && value) envVars[key.trim()] = value.trim();
});
const API_KEY = envVars.VITE_GEMINI_API_KEY;
console.log("🔑 API Key:", API_KEY ? `✅ (${API_KEY.substring(0, 10)}...)` : "❌ No encontrada");
console.log("\n🧪 Probando TODOS los modelos disponibles...\n");
// Lista exhaustiva de modelos a probar
const modelsToTry = [
// Gemini 2.0
"gemini-2.0-flash-exp",
"gemini-2.0-flash",
// Gemini 1.5 Flash variantes
"gemini-1.5-flash-latest",
"gemini-1.5-flash-001",
"gemini-1.5-flash-002",
"gemini-1.5-flash",
"gemini-1.5-flash-8b-latest",
"gemini-1.5-flash-8b",
// Gemini 1.5 Pro variantes
"gemini-1.5-pro-latest",
"gemini-1.5-pro-001",
"gemini-1.5-pro-002",
"gemini-1.5-pro",
// Gemini Pro legacy
"gemini-pro",
"gemini-pro-vision",
// Gemini 1.0
"gemini-1.0-pro-latest",
"gemini-1.0-pro-001",
"gemini-1.0-pro"
];
async function testModel(modelName) {
const url = `https://generativelanguage.googleapis.com/v1beta/models/${modelName}:generateContent?key=${API_KEY}`;
const requestBody = {
contents: [{
parts: [{
text: "Responde con la palabra: OK"
}]
}]
};
try {
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(requestBody)
});
if (response.ok) {
const data = await response.json();
const text = data.candidates[0].content.parts[0].text;
return { success: true, model: modelName, response: text.trim() };
} else {
const status = response.status;
let reason = "";
if (status === 429) reason = "Cuota excedida";
else if (status === 404) reason = "No encontrado";
else if (status === 403) reason = "Sin permisos";
else reason = `Error ${status}`;
return { success: false, model: modelName, error: reason };
}
} catch (error) {
return { success: false, model: modelName, error: error.message };
}
}
async function main() {
console.log("=".repeat(60));
console.log("🚀 TEST EXHAUSTIVO DE MODELOS GEMINI");
console.log("=".repeat(60) + "\n");
const results = [];
for (const model of modelsToTry) {
process.stdout.write(`⏳ ${model.padEnd(35)}... `);
const result = await testModel(model);
if (result.success) {
console.log(`✅ FUNCIONA!`);
results.push(result);
} else {
console.log(`❌ ${result.error}`);
}
// Pausa para no saturar la API
await new Promise(resolve => setTimeout(resolve, 300));
}
console.log("\n" + "=".repeat(60));
if (results.length > 0) {
console.log("✅ MODELOS FUNCIONALES ENCONTRADOS:");
console.log("=".repeat(60));
results.forEach((r, i) => {
console.log(`\n${i + 1}. ${r.model}`);
console.log(` Respuesta: "${r.response}"`);
});
console.log("\n" + "=".repeat(60));
console.log(`\n📝 Usa este en geminiService.js:\n`);
console.log(`const MODEL_NAME = "${results[0].model}";\n`);
} else {
console.log("❌ NO SE ENCONTRÓ NINGÚN MODELO FUNCIONAL");
console.log("=".repeat(60));
console.log("\n⚠️ Todas las API Keys probadas tienen cuota excedida.");
console.log("💡 Soluciones:");
console.log(" 1. Espera 24 horas para que se reinicie la cuota");
console.log(" 2. Crea una API Key en un proyecto NUEVO en Google AI Studio");
console.log(" 3. Habilita facturación en Google Cloud (tienes $300 gratis)\n");
}
}
main();