Skip to content

ModelSettings

Base classes

Name Children Inherits
Schema
schemez.schema
Base class for configuration models.

â‹” Inheritance diagram

graph TD
  666099940["configs.ModelSettings"]
  330168112["schema.Schema"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  330168112 --> 666099940
  3879467795 --> 330168112
  2751680898 --> 3879467795

🛈 DocStrings

Bases: Schema

Settings to configure an LLM.

Source code in src/llmling_models_config/configs.py
class ModelSettings(Schema):
    """Settings to configure an LLM."""

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Model settings"})

    max_output_tokens: int | None = Field(
        default=None,
        examples=[1024, 2048, 4096],
        title="Maximum output tokens",
    )
    """The maximum number of tokens to generate."""

    temperature: float | None = Field(
        default=None,
        ge=0.0,
        le=2.0,
        examples=[0.7, 1.0, 1.5],
        title="Temperature",
    )
    """Amount of randomness in the response (0.0 - 2.0)."""

    top_p: float | None = Field(
        default=None,
        ge=0.0,
        le=1.0,
        examples=[0.9, 0.95, 1.0],
        title="Top-p (nucleus sampling)",
    )
    """An alternative to sampling with temperature, called nucleus sampling."""

    timeout: float | None = Field(
        default=None,
        ge=0.0,
        examples=[30.0, 60.0, 120.0],
        title="Request timeout",
    )
    """Override the client-level default timeout for a request, in seconds."""

    parallel_tool_calls: bool | None = Field(
        default=None,
        title="Allow parallel tool calls",
    )
    """Whether to allow parallel tool calls."""

    seed: int | None = Field(default=None, examples=[42, 123, 999], title="Random seed")
    """The random seed to use for the model."""

    presence_penalty: float | None = Field(
        default=None,
        ge=-2.0,
        le=2.0,
        examples=[0.0, 0.5, 1.0],
        title="Presence penalty",
    )
    """Penalize new tokens based on whether they have appeared in the text so far."""

    frequency_penalty: float | None = Field(
        default=None,
        ge=-2.0,
        le=2.0,
        examples=[0.0, 0.5, 1.0],
        title="Frequency penalty",
    )
    """Penalize new tokens based on their existing frequency in the text so far."""

    logit_bias: dict[str, int] | None = Field(
        default=None,
        title="Logit bias",
        examples=[{"5678": -100}, {"1234": 100}],
    )
    """Modify the likelihood of specified tokens appearing in the completion."""

    def to_dict(self) -> dict[str, Any]:
        """Convert to TypedDict format for pydantic-ai."""
        return {k: v for k, v in self.model_dump().items() if v is not None}

frequency_penalty class-attribute instance-attribute

frequency_penalty: float | None = Field(
    default=None, ge=-2.0, le=2.0, examples=[0.0, 0.5, 1.0], title="Frequency penalty"
)

Penalize new tokens based on their existing frequency in the text so far.

logit_bias class-attribute instance-attribute

logit_bias: dict[str, int] | None = Field(
    default=None, title="Logit bias", examples=[{"5678": -100}, {"1234": 100}]
)

Modify the likelihood of specified tokens appearing in the completion.

max_output_tokens class-attribute instance-attribute

max_output_tokens: int | None = Field(
    default=None, examples=[1024, 2048, 4096], title="Maximum output tokens"
)

The maximum number of tokens to generate.

parallel_tool_calls class-attribute instance-attribute

parallel_tool_calls: bool | None = Field(default=None, title='Allow parallel tool calls')

Whether to allow parallel tool calls.

presence_penalty class-attribute instance-attribute

presence_penalty: float | None = Field(
    default=None, ge=-2.0, le=2.0, examples=[0.0, 0.5, 1.0], title="Presence penalty"
)

Penalize new tokens based on whether they have appeared in the text so far.

seed class-attribute instance-attribute

seed: int | None = Field(default=None, examples=[42, 123, 999], title='Random seed')

The random seed to use for the model.

temperature class-attribute instance-attribute

temperature: float | None = Field(
    default=None, ge=0.0, le=2.0, examples=[0.7, 1.0, 1.5], title="Temperature"
)

Amount of randomness in the response (0.0 - 2.0).

timeout class-attribute instance-attribute

timeout: float | None = Field(
    default=None, ge=0.0, examples=[30.0, 60.0, 120.0], title="Request timeout"
)

Override the client-level default timeout for a request, in seconds.

top_p class-attribute instance-attribute

top_p: float | None = Field(
    default=None, ge=0.0, le=1.0, examples=[0.9, 0.95, 1.0], title="Top-p (nucleus sampling)"
)

An alternative to sampling with temperature, called nucleus sampling.

to_dict

to_dict() -> dict[str, Any]

Convert to TypedDict format for pydantic-ai.

Source code in src/llmling_models_config/configs.py
def to_dict(self) -> dict[str, Any]:
    """Convert to TypedDict format for pydantic-ai."""
    return {k: v for k, v in self.model_dump().items() if v is not None}

:fa-brands-github: Show source on GitHub