11const api_url_models = 'https://api.penguinai.tech/v1/models' ;
2- const api_url_chat_completions = 'https://api.penguinai.tech/v1/chat/completions ' ;
2+ const api_url_working = 'https://api.penguinai.tech/v1/api/working ' ;
33
44async function fetchAndGetReqModels ( ) {
55 try {
@@ -55,41 +55,30 @@ async function displayModels() {
5555 statusTable . appendChild ( row ) ;
5656 } ) ;
5757
58- checkModelStatusInBatches ( models ) ;
58+ checkModelStatuses ( models ) ;
5959}
6060
61- async function checkModelStatusInBatches ( models ) {
62- const batchSize = 1 ; // Process models one at a time
63- const delay = 5100 ; // 5 seconds in milliseconds
61+ async function checkModelStatuses ( models ) {
6462 let failed = 0 ;
6563 let checked = 0 ;
6664 const total = models . length ;
6765 const statusText = document . getElementById ( 'model-status-progress' ) ;
6866 let statusTextCopy = "Models Status:\n" ;
6967
70- for ( let i = 0 ; i < total ; i ++ ) {
71- const model = models [ i ] ;
68+ await Promise . all ( models . map ( async ( model ) => {
7269 const statusCell = document . getElementById ( `status-${ model . value } ` ) ;
7370
7471 try {
75- const response = await fetch ( api_url_chat_completions , {
76- method : 'POST' ,
77- headers : {
78- 'Content-Type' : 'application/json' ,
79- } ,
80- body : JSON . stringify ( {
81- model : model . value ,
82- messages : [ { role : "user" , content : "hi" } ]
83- } ) ,
84- } ) ;
72+ const response = await fetch ( `${ api_url_working } ?model=${ model . value } ` ) ;
73+ const status = await response . text ( ) ;
8574
8675 checked ++ ;
8776
88- if ( response . ok ) {
77+ if ( status . trim ( ) === 'True' ) {
8978 statusCell . textContent = '✅ Up' ; // Checkmark for successful status
9079 statusTextCopy += `${ model . text } >> ✅ Up\n` ;
9180 } else {
92- statusCell . textContent = ` ❌ Down` ;
81+ statusCell . textContent = ' ❌ Down' ;
9382 statusTextCopy += `${ model . text } >> ❌ Down\n` ;
9483 failed ++ ;
9584 }
@@ -104,20 +93,14 @@ async function checkModelStatusInBatches(models) {
10493 let failedProc = Math . round ( ( failed / total ) * 100 ) ;
10594 let checkedProc = Math . round ( ( checked / total ) * 100 ) ;
10695 statusText . textContent = `Total models: ${ total } | Checked: ${ checked } (${ checkedProc } %) | Successful: ${ total - failed } (${ successfulProc } %) | Failed: ${ failed } (${ failedProc } %)` ;
107-
108- // Add delay between requests
109- if ( i < total - 1 ) {
110- await new Promise ( resolve => setTimeout ( resolve , delay ) ) ;
111- }
112- }
96+ } ) ) ;
11397
11498 statusTextCopy += `\nTotal models: ${ total } | Checked: ${ checked } | Successful: ${ total - failed } | Failed: ${ failed } ` ;
11599 statusTextCopy += "\nCheck again here: https://mestai.online/status/" ;
116100
117101 statusText . innerHTML = `${ statusText . innerHTML } <br><br><button onclick="copyText(\`${ statusTextCopy } \`)">Copy result</button>` ;
118102}
119103
120-
121104function copyText ( textToCopy ) {
122105 navigator . clipboard . writeText ( textToCopy )
123106 . then ( ( ) => {
0 commit comments