check if model is embedding by testing it (#332)

This commit is contained in:
Lucas Oliveira 2025-10-30 15:03:23 -03:00 committed by GitHub
parent 3ae13285e8
commit cece8a91d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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