Skip to content

DelegationModelConfig

Base classes

Name Children Inherits
BaseModelConfig
llmling_models_config.configs
Base for model configurations.

⋔ Inheritance diagram

graph TD
  3498049208["configs.DelegationModelConfig"]
  3497727833["configs.BaseModelConfig"]
  330168112["schema.Schema"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  3497727833 --> 3498049208
  330168112 --> 3497727833
  3879467795 --> 330168112
  2751680898 --> 3879467795

🛈 DocStrings

Bases: BaseModelConfig

Configuration for delegation-based model selection.

Source code in src/llmling_models_config/configs.py
class DelegationModelConfig(BaseModelConfig):
    """Configuration for delegation-based model selection."""

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Delegation model"})

    type: Literal["delegation"] = Field(default="delegation", init=False)
    """Type identifier for delegation model."""

    selector_model: ModelId | str | BaseModelConfig = Field(
        examples=["openai:gpt-5-nano"],
        title="Selector model",
    )
    """Model responsible for selecting which model to use."""

    models: list[ModelId | str | BaseModelConfig] = Field(
        min_length=1,
        title="Available models",
        examples=[["openai:gpt-5-nano", "anthropic:claude-sonnet-4-5"]],
    )
    """List of available models to choose from."""

    selection_prompt: str = Field(
        examples=["Choose the best model for this task", "Select appropriate model"],
        title="Selection prompt",
    )
    """Prompt used to guide the selector model's decision."""

    model_descriptions: dict[str, str] | None = Field(
        default=None,
        title="Model descriptions",
        examples=[
            {
                "openai:gpt-5-nano": "A small, fast model",
                "anthropic:claude-sonnet-4-5": "A large, powerful model",
            }
        ],
    )
    """Optional descriptions of each model for selection purposes."""

    def get_model(self) -> DelegationMultiModel:
        from llmling_models.models import DelegationMultiModel

        # String ids stay strings: the selector answers with them.
        models = [_build_model(m) if isinstance(m, BaseModelConfig) else m for m in self.models]
        descriptions: dict[str | Model, str] | None = (
            {**self.model_descriptions} if self.model_descriptions else None
        )
        return DelegationMultiModel(
            selector_model=_build_model(self.selector_model),
            models=models,
            selection_prompt=self.selection_prompt,
            model_descriptions=descriptions,
        )

model_descriptions class-attribute instance-attribute

model_descriptions: dict[str, str] | None = Field(
    default=None,
    title="Model descriptions",
    examples=[
        {
            "openai:gpt-5-nano": "A small, fast model",
            "anthropic:claude-sonnet-4-5": "A large, powerful model",
        }
    ],
)

Optional descriptions of each model for selection purposes.

models class-attribute instance-attribute

models: list[ModelId | str | BaseModelConfig] = Field(
    min_length=1,
    title="Available models",
    examples=[["openai:gpt-5-nano", "anthropic:claude-sonnet-4-5"]],
)

List of available models to choose from.

selection_prompt class-attribute instance-attribute

selection_prompt: str = Field(
    examples=["Choose the best model for this task", "Select appropriate model"],
    title="Selection prompt",
)

Prompt used to guide the selector model's decision.

selector_model class-attribute instance-attribute

selector_model: ModelId | str | BaseModelConfig = Field(
    examples=["openai:gpt-5-nano"], title="Selector model"
)

Model responsible for selecting which model to use.

type class-attribute instance-attribute

type: Literal['delegation'] = Field(default='delegation', init=False)

Type identifier for delegation model.

:fa-brands-github: Show source on GitHub