Skip to content

fix(deepseek): send the max tokens of structured requests as max_tokens - #1064

Open
skybleak333 wants to merge 1 commit into
prism-php:mainfrom
skybleak333:fix/deepseek-structured-max-tokens
Open

skybleak333 wants to merge 1 commit into
prism-php:mainfrom
skybleak333:fix/deepseek-structured-max-tokens

Conversation

@skybleak333

Copy link
Copy Markdown

Description

The DeepSeek structured handler sent withMaxTokens() as max_completion_tokens, while the text and stream handlers send max_tokens. DeepSeek's chat completion API only documents max_tokens and ignores the other one, so a structured request had no output limit. With thinking on (the default for current models), DeepSeek's own default allows up to 64K output tokens, so the limit that was meant to cap the cost did nothing.

People who checked it against the live API saw the same: with max_completion_tokens: 5 DeepSeek returned 76 tokens and finish_reason: stop, with max_tokens: 5 it stopped at 5 with length (earendil-works/pi#8018, and elastic/elasticsearch#122218 for the same parameter).

The structured handler now sends max_tokens like the others. New test checks the request has max_tokens and no max_completion_tokens; it fails without the change. The full suite, PHPStan, Pint and Rector pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant