refactor: moved temperature method from base provider to model capabilities

docs: added AGENTS.md for onboarding Codex
This commit is contained in:
Fahad
2025-10-02 09:17:36 +04:00
parent 1dc25f6c3d
commit f461cb4519
4 changed files with 57 additions and 46 deletions

View File

@@ -1,6 +1,7 @@
"""Dataclass describing the feature set of a model exposed by a provider."""
from dataclasses import dataclass, field
from typing import Optional
from .provider_type import ProviderType
from .temperature import RangeTemperatureConstraint, TemperatureConstraint
@@ -33,6 +34,19 @@ class ModelCapabilities:
default_factory=lambda: RangeTemperatureConstraint(0.0, 2.0, 0.3)
)
def get_effective_temperature(self, requested_temperature: float) -> Optional[float]:
"""Return the temperature that should be sent to the provider.
Models that do not support temperature return ``None`` so that callers
can omit the parameter entirely. For supported models, the configured
constraint clamps the requested value into a provider-safe range.
"""
if not self.supports_temperature:
return None
return self.temperature_constraint.get_corrected_value(requested_temperature)
@staticmethod
def collect_aliases(model_configs: dict[str, "ModelCapabilities"]) -> dict[str, list[str]]:
"""Build a mapping of model name to aliases from capability configs."""