From cece8a91d5e4ad597a96cf131791aacb7a4c4629 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Thu, 30 Oct 2025 15:03:23 -0300 Subject: [PATCH] check if model is embedding by testing it (#332) --- src/services/models_service.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/services/models_service.py b/src/services/models_service.py index cbbc7c74..1b32219d 100644 --- a/src/services/models_service.py +++ b/src/services/models_service.py @@ -1,5 +1,6 @@ import httpx from typing import Dict, List +from api.provider_validation import test_embedding from utils.container_utils import transform_localhost_url from utils.logging_config import get_logger @@ -171,10 +172,12 @@ class ModelsService: has_tools = TOOL_CALLING_CAPABILITY in capabilities # Check if it's an embedding model - is_embedding = any( - embed_model in model_name.lower() - for embed_model in self.OLLAMA_EMBEDDING_MODELS - ) + try: + await test_embedding("ollama", endpoint=endpoint, embedding_model=model_name) + is_embedding = True + except Exception as e: + logger.warning(f"Failed to test embedding for model {model_name}: {str(e)}") + is_embedding = False if is_embedding: # Embedding models only need completion capability