Update server.js
Browse files
server.js
CHANGED
|
@@ -30,7 +30,6 @@ function logError(providerId, reason) {
|
|
| 30 |
}
|
| 31 |
|
| 32 |
// --- NUEVOS PROVEEDORES PÚBLICOS (SIN API KEY) ---
|
| 33 |
-
// Se eliminaron los HF Spaces. Se añaden endpoints gratuitos compatibles con OpenAI.
|
| 34 |
const PROVIDERS = [
|
| 35 |
{
|
| 36 |
id: "pollinations-ai",
|
|
@@ -40,6 +39,10 @@ const PROVIDERS = [
|
|
| 40 |
{
|
| 41 |
id: "kepler-cloud",
|
| 42 |
url: "https://oai.endpoints.kepler.ai.cloud.ovh.net/v1/chat/completions"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
];
|
| 45 |
|
|
@@ -47,12 +50,12 @@ const PROVIDERS = [
|
|
| 47 |
// El límite real lo dictarán los proveedores según la IP que les reenviemos.
|
| 48 |
const MAX_PER_PROVIDER = 100;
|
| 49 |
const QUEUE_TIMEOUT = 25000;
|
| 50 |
-
let currentLoad = { "pollinations-ai": 0, "kepler-cloud": 0 };
|
| 51 |
|
| 52 |
// --- RATE LIMITING LOCAL (Protección de tu propio servidor) ---
|
| 53 |
const limiter = rateLimit({
|
| 54 |
windowMs: 60 * 1000,
|
| 55 |
-
max: 50, //
|
| 56 |
keyGenerator: (req) => req.ip,
|
| 57 |
message: { error: { message: "Estás enviando demasiadas peticiones. Espera un momento.", code: 429 } },
|
| 58 |
standardHeaders: true,
|
|
@@ -112,10 +115,13 @@ async function fetchAllModels() {
|
|
| 112 |
});
|
| 113 |
|
| 114 |
// Fallback: Si los proveedores gratuitos fallan al devolver la lista, inyectamos modelos estándar
|
|
|
|
| 115 |
if (allModels.length === 0) {
|
| 116 |
allModels = [
|
| 117 |
{ id: "gpt-4o", object: "model", type: "text", owned_by: "pollinations-ai" },
|
| 118 |
-
{ id: "claude-3-5-sonnet", object: "model", type: "text", owned_by: "pollinations-ai" }
|
|
|
|
|
|
|
| 119 |
];
|
| 120 |
}
|
| 121 |
|
|
|
|
| 30 |
}
|
| 31 |
|
| 32 |
// --- NUEVOS PROVEEDORES PÚBLICOS (SIN API KEY) ---
|
|
|
|
| 33 |
const PROVIDERS = [
|
| 34 |
{
|
| 35 |
id: "pollinations-ai",
|
|
|
|
| 39 |
{
|
| 40 |
id: "kepler-cloud",
|
| 41 |
url: "https://oai.endpoints.kepler.ai.cloud.ovh.net/v1/chat/completions"
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
id: "voids-api", // Nuevo proveedor que soporta Gemini sin Key
|
| 45 |
+
url: "https://api.voids.top/v1/chat/completions"
|
| 46 |
}
|
| 47 |
];
|
| 48 |
|
|
|
|
| 50 |
// El límite real lo dictarán los proveedores según la IP que les reenviemos.
|
| 51 |
const MAX_PER_PROVIDER = 100;
|
| 52 |
const QUEUE_TIMEOUT = 25000;
|
| 53 |
+
let currentLoad = { "pollinations-ai": 0, "kepler-cloud": 0, "voids-api": 0 };
|
| 54 |
|
| 55 |
// --- RATE LIMITING LOCAL (Protección de tu propio servidor) ---
|
| 56 |
const limiter = rateLimit({
|
| 57 |
windowMs: 60 * 1000,
|
| 58 |
+
max: 50, // 50 peticiones por minuto por IP
|
| 59 |
keyGenerator: (req) => req.ip,
|
| 60 |
message: { error: { message: "Estás enviando demasiadas peticiones. Espera un momento.", code: 429 } },
|
| 61 |
standardHeaders: true,
|
|
|
|
| 115 |
});
|
| 116 |
|
| 117 |
// Fallback: Si los proveedores gratuitos fallan al devolver la lista, inyectamos modelos estándar
|
| 118 |
+
// Ahora incluye Gemini explícitamente para que Ventarys AI lo ofrezca en la UI
|
| 119 |
if (allModels.length === 0) {
|
| 120 |
allModels = [
|
| 121 |
{ id: "gpt-4o", object: "model", type: "text", owned_by: "pollinations-ai" },
|
| 122 |
+
{ id: "claude-3-5-sonnet", object: "model", type: "text", owned_by: "pollinations-ai" },
|
| 123 |
+
{ id: "gemini-1.5-pro", object: "model", type: "text", owned_by: "voids-api" },
|
| 124 |
+
{ id: "gemini-1.5-flash", object: "model", type: "text", owned_by: "voids-api" }
|
| 125 |
];
|
| 126 |
}
|
| 127 |
|