chore: create OpenAIMixin for inference providers with an OpenAI-compat API that need to implement openai_* methods

use demonstrated by refactoring OpenAIInferenceAdapter, NVIDIAInferenceAdapter (adds embedding support) and LlamaCompatInferenceAdapter
This commit is contained in:
Matthew Farrellee 2025-07-21 07:27:27 -04:00
parent ecd28f0085
commit 639bc912d5
6 changed files with 367 additions and 387 deletions

View file

@ -4,6 +4,7 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
import logging
from typing import Any
from pydantic import BaseModel, Field
@ -16,6 +17,8 @@ from llama_stack.providers.utils.inference import (
ALL_HUGGINGFACE_REPOS_TO_MODEL_DESCRIPTOR,
)
logger = logging.getLogger(__name__)
# TODO: this class is more confusing than useful right now. We need to make it
# more closer to the Model class.
@ -98,6 +101,9 @@ class ModelRegistryHelper(ModelsProtocolPrivate):
:param model: The model identifier to check.
:return: True if the model is available dynamically, False otherwise.
"""
logger.info(
f"check_model_availability is not implemented for {self.__class__.__name__}. Returning False by default."
)
return False
async def register_model(self, model: Model) -> Model: