affaan-m/ECC · error · NotImplementedError

must implement get_default_model

Error message

{self.__class__.__name__} must implement get_default_model

What it means

LLMProvider (base class) declares get_default_model() as abstract via a NotImplementedError raise. Any concrete provider that fails to override it will throw at call time with the provider's class name in the message.

Solutions

  1. Implement get_default_model() returning a model name string on the provider subclass
  2. Check which provider class name appears in the message and open its definition
  3. If the provider cannot supply a model, return a sensible default like 'gpt-4o-mini'

Example fix

// before
class MyProvider(LLMProvider):
    def generate(self, prompt): ...
// after
class MyProvider(LLMProvider):
    def get_default_model(self) -> str:
        return 'gpt-4o-mini'
    def generate(self, prompt): ...
Defensive patterns

Strategy: type-guard

Validate before calling

if not isinstance(getattr(provider, 'get_default_model', None), types.MethodType):
    raise TypeError(f'{type(provider).__name__} is missing get_default_model')

Type guard

def implements_default_model(p: object) -> bool:
    return callable(getattr(p, 'get_default_model', None)) and \
           type(p).get_default_model is not LLMProvider.get_default_model

Try / catch

try:
    model = provider.get_default_model()
except NotImplementedError as e:
    logger.error('provider %s does not implement get_default_model', type(provider).__name__)
    model = 'gpt-4o-mini'  # safe fallback

Prevention

When it happens

Trigger: Subclassing an LLM provider (subclass of the base in src/llm/core/interface.py) without defining get_default_model, then calling code that queries the provider's default model.

Common situations: Writing a new provider integration (e.g. a custom OpenAI-compatible endpoint) and implementing generate but forgetting the model accessor; upgrading the SDK where the base interface gained this requirement.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/908da0cd612dc079. Report an issue: GitHub.

Appendix: source

Thrown at src/llm/core/interface.py:30

    provider_type: ProviderType

    @abstractmethod
    def generate(self, input: LLMInput) -> LLMOutput: ...

    @abstractmethod
    def list_models(self) -> list[ModelInfo]: ...

    @abstractmethod
    def validate_config(self) -> bool: ...

    def supports_tools(self) -> bool:
        return True

    def supports_vision(self) -> bool:
        return False

    def get_default_model(self) -> str:
        raise NotImplementedError(f"{self.__class__.__name__} must implement get_default_model")


class LLMError(Exception):
    def __init__(
        self,
        message: str,
        provider: ProviderType | None = None,
        code: str | None = None,
        details: dict[str, Any] | None = None,
    ) -> None:
        super().__init__(message)
        self.message = message
        self.provider = provider
        self.code = code
        self.details = details or {}


class AuthenticationError(LLMError): ...

View on GitHub (pinned to 8321021c54)