Skip to content

Commit

Permalink
Update status.js
Browse files Browse the repository at this point in the history
  • Loading branch information
JustablockCode authored Dec 24, 2024
1 parent 3ce88f4 commit 3cca84d
Showing 1 changed file with 31 additions and 32 deletions.
63 changes: 31 additions & 32 deletions js/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,46 +59,45 @@ async function displayModels() {
}

async function checkModelStatusInBatches(models) {
const batchSize = 5;
const batchSize = 1; // Since the rate limit is 1 request every 5 seconds, process models sequentially
const delay = 5000; // 5 seconds in milliseconds
let failed = 0;
let checked = 0;
const total = models.length;
const statusText = document.getElementById('model-status-progress');
let statusTextCopy = "Models Status:\n";

for (let i = 0; i < total; i += batchSize) {
const batch = models.slice(i, i + batchSize);
await Promise.all(batch.map(async (model) => {
const statusCell = document.getElementById(`status-${model.value}`);
try {
const response = await fetch(api_url_chat_completions, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: model.value,
messages: [{ role: "user", content: "hi" }]
}),
});

checked++;

if (response.ok) {
statusCell.textContent = '✅ Up'; // Checkmark for successful status
statusTextCopy += `${model.text} >> ✅ Up\n`;
} else {
statusCell.textContent = `❌ Down`;
statusTextCopy += `${model.text} >> ❌ Down\n`;
failed++;
}
} catch (error) {
const errorMessage = error.message || 'Unknown error';
statusCell.textContent = `❌ Error: ${errorMessage}`;
statusTextCopy += `${model.text} >> ❌ Error: ${errorMessage}\n`;
for (let i = 0; i < total; i++) {
const model = models[i];
const statusCell = document.getElementById(`status-${model.value}`);
try {
const response = await fetch(api_url_chat_completions, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: model.value,
messages: [{ role: "user", content: "hi" }]
}),
});

checked++;

if (response.ok) {
statusCell.textContent = '✅ Up'; // Checkmark for successful status
statusTextCopy += `${model.text} >> ✅ Up\n`;
} else {
statusCell.textContent = `❌ Down`;
statusTextCopy += `${model.text} >> ❌ Down\n`;
failed++;
}
}));
} catch (error) {
const errorMessage = error.message || 'Unknown error';
statusCell.textContent = `❌ Error: ${errorMessage}`;
statusTextCopy += `${model.text} >> ❌ Error: ${errorMessage}\n`;
failed++;
}

let successfulProc = Math.round(((total - failed) / total) * 100);
let failedProc = Math.round((failed / total) * 100);
Expand Down

0 comments on commit 3cca84d

Please sign in to comment.