@@ -366,19 +366,26 @@ function Client:fetch_models()
366366 local provider = self .providers [provider_name ]
367367 if not provider .disabled and provider .get_models then
368368 notify .publish (notify .STATUS , ' Fetching models from ' .. provider_name )
369- local headers = self :authenticate (provider_name )
369+ local ok , headers = pcall (self .authenticate , self , provider_name )
370+ if not ok then
371+ log .warn (' Failed to authenticate with ' .. provider_name .. ' : ' .. headers )
372+ goto continue
373+ end
370374 local ok , provider_models = pcall (provider .get_models , headers )
371- if ok then
372- for _ , model in ipairs (provider_models ) do
373- model .provider = provider_name
374- if models [model .id ] then
375- model .id = model .id .. ' :' .. provider_name
376- end
377- models [model .id ] = model
378- end
379- else
375+ if not ok then
380376 log .warn (' Failed to fetch models from ' .. provider_name .. ' : ' .. provider_models )
377+ goto continue
381378 end
379+
380+ for _ , model in ipairs (provider_models ) do
381+ model .provider = provider_name
382+ if models [model .id ] then
383+ model .id = model .id .. ' :' .. provider_name
384+ end
385+ models [model .id ] = model
386+ end
387+
388+ :: continue::
382389 end
383390 end
384391
@@ -401,19 +408,26 @@ function Client:fetch_agents()
401408 local provider = self .providers [provider_name ]
402409 if not provider .disabled and provider .get_agents then
403410 notify .publish (notify .STATUS , ' Fetching agents from ' .. provider_name )
404- local headers = self :authenticate (provider_name )
411+ local ok , headers = pcall (self .authenticate , self , provider_name )
412+ if not ok then
413+ log .warn (' Failed to authenticate with ' .. provider_name .. ' : ' .. headers )
414+ goto continue
415+ end
405416 local ok , provider_agents = pcall (provider .get_agents , headers )
406- if ok then
407- for _ , agent in ipairs (provider_agents ) do
408- agent .provider = provider_name
409- if agents [agent .id ] then
410- agent .id = agent .id .. ' :' .. provider_name
411- end
412- agents [agent .id ] = agent
413- end
414- else
417+ if not ok then
415418 log .warn (' Failed to fetch agents from ' .. provider_name .. ' : ' .. provider_agents )
419+ goto continue
416420 end
421+
422+ for _ , agent in ipairs (provider_agents ) do
423+ agent .provider = provider_name
424+ if agents [agent .id ] then
425+ agent .id = agent .id .. ' :' .. provider_name
426+ end
427+ agents [agent .id ] = agent
428+ end
429+
430+ :: continue::
417431 end
418432 end
419433
0 commit comments