File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -73,12 +73,13 @@ export abstract class BaseOpenAiCompatibleProvider<ModelName extends string>
7373 } = this . getModel ( )
7474
7575 const temperature = this . options . modelTemperature ?? this . defaultTemperature
76-
7776 // Ensure max_tokens doesn't exceed the model's configured limit
7877 // Users can override with modelMaxTokens, but it should not exceed the model's actual API limit
7978 const userMaxTokens = this . options . modelMaxTokens
80- const max_tokens = userMaxTokens ? Math . min ( userMaxTokens , modelMaxTokens ) : modelMaxTokens
81-
79+ const max_tokens =
80+ typeof userMaxTokens === "number" && userMaxTokens > 0 && typeof modelMaxTokens === "number"
81+ ? Math . min ( userMaxTokens , modelMaxTokens )
82+ : modelMaxTokens
8283 const params : OpenAI . Chat . Completions . ChatCompletionCreateParamsStreaming = {
8384 model,
8485 max_tokens,
You can’t perform that action at this time.
0 commit comments