fix(providers): make max_tokens and max_completion_tokens mutually exclusive (#2491)
* fix(providers): make max_tokens and max_completion_tokens mutually exclusive * docs: document supports_max_completion_tokens ProviderSpec option
This commit is contained in:
@@ -243,11 +243,14 @@ class OpenAICompatProvider(LLMProvider):
|
||||
kwargs: dict[str, Any] = {
|
||||
"model": model_name,
|
||||
"messages": self._sanitize_messages(self._sanitize_empty_content(messages)),
|
||||
"max_tokens": max(1, max_tokens),
|
||||
"max_completion_tokens": max(1, max_tokens),
|
||||
"temperature": temperature,
|
||||
}
|
||||
|
||||
if spec and getattr(spec, "supports_max_completion_tokens", False):
|
||||
kwargs["max_completion_tokens"] = max(1, max_tokens)
|
||||
else:
|
||||
kwargs["max_tokens"] = max(1, max_tokens)
|
||||
|
||||
if spec:
|
||||
model_lower = model_name.lower()
|
||||
for pattern, overrides in spec.model_overrides:
|
||||
|
||||
@@ -49,6 +49,7 @@ class ProviderSpec:
|
||||
|
||||
# gateway behavior
|
||||
strip_model_prefix: bool = False # strip "provider/" before sending to gateway
|
||||
supports_max_completion_tokens: bool = False
|
||||
|
||||
# per-model param overrides, e.g. (("kimi-k2.5", {"temperature": 1.0}),)
|
||||
model_overrides: tuple[tuple[str, dict[str, Any]], ...] = ()
|
||||
|
||||
Reference in New Issue
Block a user