review: collect model ids to include in raise error message

This commit is contained in:
Akram Ben Aissi 2025-10-08 22:51:59 +02:00
parent 24c6b01d16
commit 0ecfdc6dff

View file

@ -82,11 +82,12 @@ class VLLMInferenceAdapter(OpenAIMixin):
Skip the check when running without authentication.
"""
if not self.config.api_token:
try:
return model in [m.id async for m in self.client.models.list()]
except Exception as e:
log.warning(f"Failed to check model availability: {e}")
raise ValueError(f"Failed to check model availability: {e}") from e
model_ids = []
async for m in self.client.models.list():
if m.id == model: # Found exact match
return True
model_ids.append(m.id)
raise ValueError(f"Model '{model}' not found. Available models: {model_ids}")
return True
async def openai_chat_completion(