Add failsafe incase max_tokens is 0 or negative for a model (#1954)

This commit is contained in:
Neal Shah
2025-11-09 19:22:34 -05:00
committed by GitHub
parent 3c3367ca52
commit bb2c78ae2d

View File

@@ -403,6 +403,9 @@ class AIChatService extends BaseService {
parameters.max_tokens = Math.floor(Math.min(parameters.max_tokens ?? Number.POSITIVE_INFINITY,
max_allowed_output_tokens,
model_max_tokens - (Math.ceil(text.length / 4))));
if (parameters.max_tokens < 1) {
parameters.max_tokens = undefined;
}
}
try {
ret = await svc_driver.call_new_({